Skip to content

Added Cluster Manager Resource #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 54 commits into
base: feature/release-testing
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
293a721
Adding changelog.md
Sep 21, 2020
9fed2b7
Adding github actions workflows
Sep 21, 2020
fa5f7eb
Change Docs URL refs to 'latest' as not everyone has access to 8.1.0 …
yorokobi Sep 24, 2020
3df5973
Adding test.yml (#10)
anushjay Sep 24, 2020
5e5f936
Fix HEC input use_ack attribute type
Sep 25, 2020
1a73b4c
auth token support
Sep 28, 2020
709f78d
v1.2.0 changelog
Sep 29, 2020
4307127
Fix authorization header
Sep 30, 2020
d852476
v1.2.1 changelog
Sep 30, 2020
ba28b27
Initial GitHub actions docker testing integration
nstonesplunk Oct 1, 2020
67d160a
merge tests
nstonesplunk Oct 2, 2020
6f14616
Adding splunk service container
Oct 2, 2020
bd4011d
Adding TF examples
Oct 5, 2020
f26d82b
Merge pull request #19 from splunk/feature/docker-compose-testing-2
nstonesplunk Oct 5, 2020
978e53c
Make search_indexes_allowed and search_indexes_default be lists. Reso…
bedinger Oct 6, 2020
a09ea4e
Add dispatch_index_earliest and dispatch_index_latest arguments for s…
asvoboda Oct 2, 2020
1183f9d
v1.3.0 changelog
Oct 6, 2020
5ef0d3e
Add support for admin/SAML-groups API endpoint (#23)
bedinger Oct 7, 2020
bbc6fbb
v1.3.1 changelog
Oct 7, 2020
7b376ba
Adding new saved searches email attributes (#25)
anushjay Oct 21, 2020
1bf99a7
v1.3.2 changelog
Oct 21, 2020
2dffc36
fix saved search ID docs (#31)
zscholl Nov 12, 2020
3b9864c
Fix url encoding for searchers (#29)
zscholl Nov 13, 2020
d334379
Add linting action & fix linting errors (#30)
zscholl Nov 13, 2020
15f4e13
Update go module path
Nov 13, 2020
5379955
v1.3.3 changelog
Nov 13, 2020
edc7ec5
Changed module path to point to Splunk github repository (#37)
bhayes-zd Nov 16, 2020
2828de5
Add slack actions (#33)
zscholl Nov 18, 2020
9cd4176
v1.3.4 changelog
Nov 18, 2020
d131a98
Add email message field for reports & alerts (#38)
zscholl Dec 1, 2020
f0e0a3c
v1.3.5 changelog
Dec 1, 2020
2b1d524
Pass HEC token as input (#44)
anushjay Dec 8, 2020
f9fb156
v1.3.6 changelog
Dec 8, 2020
db4b031
bugfix: http client overrides default transport and no longer support…
jamesmoriarty Dec 11, 2020
8397e9e
v1.3.7 changelog
Dec 11, 2020
7282f9f
inital update
Dec 11, 2020
49b2be6
second
Dec 11, 2020
c638920
third
Dec 12, 2020
0ed0aaa
fourth
Dec 12, 2020
9143505
fixed typo
Dec 12, 2020
0246547
fifth
Dec 12, 2020
678e1de
working state
Dec 12, 2020
d4d8a8e
working
Dec 14, 2020
1548519
fixed internal validation error
Dec 14, 2020
82b4166
fixed services url
Dec 14, 2020
52b0bba
testing Read operation fix
Dec 14, 2020
8034100
metrics index param fix + metrics index test (#50)
nstonesplunk Jan 5, 2021
f37163b
v1.3.8 changelog
Jan 5, 2021
1c1963e
Create dashboards and panels (#47)
Jan 6, 2021
6da7697
changelog v1.3.9
Jan 6, 2021
a57650b
Adding Support to README
Feb 3, 2021
6263c2e
final version
Feb 4, 2021
221ee4f
merging conflicts
Feb 12, 2021
3f427d2
added cluster manager resource
Feb 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 19 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
pull_request:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.29
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (paultyng/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release
on:
push:
tags:
- 'v*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
-
name: Import GPG key
id: import_gpg
uses: paultyng/[email protected]
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:
name: Build and test
runs-on: ubuntu-latest

services:
splunk:
image: splunk/splunk:latest
env:
SPLUNK_START_ARGS: --accept-license
SPLUNK_PASSWORD: password
ports:
- 8000:8000
- 8089:8089

steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi

- name: Build
run: go build -v .

- name: Test
run: TF_ACC=1 SPLUNK_HOME=/opt/splunk SPLUNK_URL=localhost:8089 SPLUNK_USERNAME=admin SPLUNK_PASSWORD=password go test ./... -v
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Ignore dist file
.idea
.terraform
dist
terraform-provider-splunk
terraform.tfstate
terraform.tfstate.backup
*.log
.DS_Store
.vscode
54 changes: 54 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## 1.3.9 (January 6, 2021)
* Support to create dashboards and views resource #45

## 1.3.8 (January 5, 2021)
* Fix: Unable to create a Metric index (#48)
* Fix: TestAccCreateSplunkIndex is randomly failing (#39)

## 1.3.7 (December 8, 2020)
* Fix: http client overrides default transport and no longer supports environment proxy settings. (#46)

## 1.3.6 (December 8, 2020)
* Fix: Pass HEC token as input with http event collector resource

## 1.3.5 (December 1, 2020)
Add email message field for reports & alerts #38

## 1.3.4 (November 18, 2020)
* Fix: Adding Slack actions to saved_searches resource #33
* Revert go mod path update

## 1.3.3 (November 13, 2020)
* Fix: Fix URL encoding for resource names #32
* Enhancements: Added linting `golangci-lint`
* go mod path update to `github.com/terraform-providers/terraform-provider-splunk`

## 1.3.2 (October 21, 2020)
* Fix: Feature Request for saved search to support additional attributes #24
* Fix: `saved_search` default is_visible to true #3

## 1.3.1 (October 6, 2020)
* Support for admin/SAML-groups API endpoint #23

## 1.3.0 (October 6, 2020)
* Fix: authorization/roles srchIndexesAllowed and srchIndexesDefault should be lists #20
* Fix: Support for saved_search argument dispatch.index_earliest #15
* github action workflow for integration tests
* Additional examples in the examples folder

## 1.2.1 (September 30, 2020)
* Bug fix for authorization header

## 1.2.0 (September 29, 2020)
* Change provider configuration - support for splunk auth token

## 1.1.0 (September 25, 2020)
* Change HTTP inputs resource attribute types (`use_ack` and `use_deployment_server`) to `int`
* Creating examples folder
* Adding AWS firehose + Splunk integration example under `examples/aws`

## 1.0.2 (September 21, 2020)
* Adding Github actions workflow

## 1.0.1 (September 21, 2020)
* Adding CHANGELOG.MD
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,4 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------

This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.
defined by the Mozilla Public License, v. 2.0.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ default: build

fmt:
go fmt ./...
@terraform fmt
@terraform fmt -recursive

build:
go build -o terraform-provider-splunk .
Expand All @@ -34,4 +34,4 @@ plan:
@terraform plan

apply:
@terraform apply -auto-approve
@terraform apply -auto-approve
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@

### Building The Provider

Clone the repository: https://git.splunk.com/projects/GSA/repos/terraform-provider-splunk
Clone the [repository](https://github.com/splunk/terraform-provider-splunk/)

Create go src directory and setup $GOPATH

Build the provider: `make build`

### Developing The Provider
* Use the Splunk REST API manual: https://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTprolog to design resource schemas for the provider.
* Use the [Splunk REST API manual](https://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTprolog) to design resource schemas for the provider.
* Add a resource_x_test.go file to test the new resources' CRUD operations
* Before merging your changes lint your code by running `make fmt`
* Test the provider with the existing suite of provider tests before merging your changes
* Build the provider and test the new resources' CRUD and import operations before merging your changes
* Add all necessary documentation in the docs folder
* As per [best practices](https://www.terraform.io/docs/extend/best-practices/versioning.html), update changelog.md and version as required

### Testing The Provider
* To run unit tests: `make test`
Expand All @@ -37,20 +38,26 @@ Build the provider: `make build`
* For importing existing resources use `terraform import`
* To remove all terraform managed resources use `terraform destroy`

**NOTE:** When developing or testing with terraform `>= 0.13` you must replace the provider location from remote (registry.terraform.io) to local build.
**NOTE:** When developing and testing local provider builds, if terraform version `>= 0.13` you would have to replace the provider binaries in the `.terraform` folder with your local build. [Follow these guidelines](https://github.com/hashicorp/terraform/blob/master/website/upgrade-guides/0-13.html.markdown)

Follow guidelines: https://github.com/hashicorp/terraform/blob/master/website/upgrade-guides/0-13.html.markdown
### Contributions
We are open to contributions!
<p>Please follow development guidelines and feel free to open a PR against the `master` branch with your changes. The PR should trigger the GitHub actions to run
both the unit and acceptance tests. Once all tests have passed, our team will review, make suggestions, approve, and merge the PR.
After merging, our team will update the changelog.MD file and create a version tag that should automatically create a new release.</p>

#### Examples
* Use the `example.tf` provided in the repo to run `terraform plan` and `terraform apply` to apply configuration
* Modify `provider "splunk"` resource block with proper instance details
* To update values modify the `example.tf` file and execute `terraform plan` and `terraform apply`
* The examples folder contains a few basic splunk provider examples, run `terraform init` and `terraform apply` to apply these example configuration.
* Resource examples are also available in their respective docs/resources folder

**NOTE:** Create a resource block first before importing resources (USAGE: https://www.terraform.io/docs/import/usage.html)
**NOTE:** Create a resource block first before importing resources. Docs on the import [usage](https://www.terraform.io/docs/import/usage.html)

#### Notes and Troubleshooting
* When conflicts arise during resource creation, import the resource first using `terraform import` command and make modifications to the resource.
* Testing errors mentioning `too many open files` may be related to `ulimits` on your machine. Check current and increase the maximum number of open files `1024` using `ulimits -n 1024`
* Testing errors mentioning `too many open files` may be related to `ulimit` on your machine. Check current and increase the maximum number of open files `1024` using `ulimit -n 1024`
* If conf files are edited or deleted <b>manually</b>, restart Splunk to ensure state consistency before applying or reapplying a template.
* Splunk environments with numerous indexes, saved searches, knowledge objects, etc. may cause issues with the provided tests. To avoid these errors, use a fresh or lightly configured Splunk environment.

### Support
Use the [GitHub issue tracker](https://github.com/splunk/terraform-provider-splunk/issues) to submit bugs or request features.
[Splunk Ideas](https://ideas.splunk.com/) is another place for your suggestions and [Splunk Answers](https://community.splunk.com/t5/Community/ct-p/en-us) for questions.
11 changes: 9 additions & 2 deletions client/acl.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package client

import (
"github.com/google/go-querystring/query"
"github.com/splunk/terraform-provider-splunk/client/models"
"net/http"
"strings"
"terraform-provider-splunk/client/models"

"github.com/google/go-querystring/query"
)

//https://docs.splunk.com/Documentation/Splunk/8.0.4/RESTUM/RESTusing#Access_Control_List
Expand All @@ -23,6 +24,9 @@ func (client *Client) GetAcl(owner, app, name string, resources ...string) (*htt

func (client *Client) UpdateAcl(owner, app, name string, acl *models.ACLObject, resources ...string) error {
values, err := query.Values(&acl)
if err != nil {
return err
}
// remove app from url values during POST
values.Del("app")
values.Del("perms[read]")
Expand All @@ -45,6 +49,9 @@ func (client *Client) UpdateAcl(owner, app, name string, acl *models.ACLObject,

func (client *Client) Move(owner, app, name string, acl *models.ACLObject, resources ...string) error {
values, err := query.Values(&acl)
if err != nil {
return err
}
// Adding resources
resourcePath := []string{"servicesNS", owner, app}
resourcePath = append(resourcePath, resources...)
Expand Down
59 changes: 59 additions & 0 deletions client/admin_saml_groups.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package client

import (
"github.com/splunk/terraform-provider-splunk/client/models"
"net/http"

"github.com/google/go-querystring/query"
)

func (client *Client) CreateAdminSAMLGroups(name string, adminSAMLGroupsObject *models.AdminSAMLGroupsObject) error {
values, err := query.Values(adminSAMLGroupsObject)
if err != nil {
return err
}

endpoint := client.BuildSplunkURL(nil, "services", "admin", "SAML-groups")
resp, err := client.Post(endpoint, values)
if err != nil {
return err
}
defer resp.Body.Close()
return nil
}

func (client *Client) ReadAdminSAMLGroups(name string) (*http.Response, error) {
endpoint := client.BuildSplunkURL(nil, "services", "admin", "SAML-groups", name)
resp, err := client.Get(endpoint)
if err != nil {
return nil, err
}

return resp, nil
}

func (client *Client) UpdateAdminSAMLGroups(name string, adminSAMLGroupsObject *models.AdminSAMLGroupsObject) error {
values, err := query.Values(&adminSAMLGroupsObject)
if err != nil {
return err
}
// Not required for updates
values.Del("name")
endpoint := client.BuildSplunkURL(nil, "services", "admin", "SAML-groups", name)
resp, err := client.Post(endpoint, values)
if err != nil {
return err
}
defer resp.Body.Close()
return nil
}

func (client *Client) DeleteAdminSAMLGroups(name string) (*http.Response, error) {
endpoint := client.BuildSplunkURL(nil, "services", "admin", "SAML-groups", name)
resp, err := client.Delete(endpoint)
if err != nil {
return nil, err
}

return resp, nil
}
8 changes: 7 additions & 1 deletion client/apps_local.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package client

import (
"github.com/splunk/terraform-provider-splunk/client/models"
"net/http"
"terraform-provider-splunk/client/models"

"github.com/google/go-querystring/query"
)

func (client *Client) CreateAppsLocalObject(app string, localAppObject *models.AppsLocalObject) error {
values, err := query.Values(localAppObject)
if err != nil {
return err
}
endpoint := client.BuildSplunkURL(nil, "servicesNS", "nobody", "system", "apps", "local")
resp, err := client.Post(endpoint, values)
if err != nil {
Expand All @@ -29,6 +32,9 @@ func (client *Client) ReadAppsLocalObject(app string) (*http.Response, error) {

func (client *Client) UpdateAppsLocalObject(app string, localAppObject *models.AppsLocalObject) error {
values, err := query.Values(&localAppObject)
if err != nil {
return err
}
values.Del("name") // Handler does not support "name" argument
values.Del("update") // Handler does not support "udpate" argument
values.Del("filename") // Handler does not support "filename" argument
Expand Down
Loading