From 8e81f5faf4e08f5713f62620109f807c2c24f5f4 Mon Sep 17 00:00:00 2001 From: Hasan Hakkaev Date: Mon, 3 Oct 2022 13:11:41 +0200 Subject: [PATCH] corrected readme and taskfile --- README.md | 59 ++++++++++++++++----------------------- Taskfile.yaml | 34 ++++++---------------- scripts/setup_influxdb.sh | 1 + 3 files changed, 34 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 0e3fd6e..8cd253b 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,6 @@ The InfluxDB v2 provider allows Terraform to manage ## How to use -### Download the provider - - cd examples - mkdir -p terraform.d/plugins/lancey.fr/influx/influxdb-v2/0.3.0/linux_amd64/ - cd terraform.d/plugins/lancey.fr/influx/influxdb-v2/0.3.0/linux_amd64/ - wget https://github.com/hasanhakkaev/terraform-provider-influxdb-v2/releases/download/v0.3.0/terraform-provider-influxdb-v2_v0.3.0-v0.3.0-linux-amd64.tar.gz - tar xvzf terraform-provider-influxdb-v2_v0.3.0-v0.3.0-linux-amd64.tar.gz && rm -rf terraform-provider-influxdb-v2_v0.3.0-v0.3.0-linux-amd64.tar.gz - filename=$(echo terraform-provider-influxdb-v2*) - chmod +x $filename - mv "$filename" "${filename%.*}" #### Terraform 0.13.x @@ -24,8 +14,8 @@ Add this snippet to your code: terraform { required_providers { influxdb-v2 = { - source = "lancey.fr/influx/influxdb-v2" - version = "0.3.0" + source = "hasanhakkaev/influxdb-v2" + version = "0.4.4" } } } @@ -49,7 +39,6 @@ The provider configuration block accepts the following arguments: A token can be acquired by executing the *onboarding* process, which is possible using: * influx GUI, API or command line (manually) -* the dedicated provider (terraform) available [here](https://github.com/hasanhakkaev/terraform-provider-influxdb-v2-onboarding) ### Available functionalities @@ -59,53 +48,53 @@ Influxdb v2 api documentation is available [here](https://v2.docs.influxdata.com #### Data sources * ready (status of the influxdb-v2 instance) +* organization (get an organization by name) #### Resources * bucket - * authorization (tokens) +* organization ### Examples Find examples in `examples/`. To run them: -```bash -source ./start_influxdb.sh -terraform init -terraform apply -./stop_influxdb.sh -``` - -## Dev -In case you need to update the influx client, run `go get github.com/influxdata/influxdb-client-go@`. -Also don't forget to run `go mod tidy` from time to time to remove useless dependencies. -### Test +## Development +### Requirements + + TaskFile (https://taskfile.dev/) + Precommit framework (https://pre-commit.com/) + Docker (https://www.docker.com/) + Go 1.16^ (https://golang.org/doc/install) + Terraform 0.13^ (https://www.terraform.io/downloads.html) + InfluxDB 2.0^ (https://docs.influxdata.com/influxdb/v2.0/install/) -First execute this command to check fmt requirements: - ```bash -make fmt +# Run Task init to download dependencies +task init ``` -Then execute this command to run the provider unit tests: +### Test + +First execute this command to lint and format the code: ```bash -make test +task lint ``` -And finally to run acceptance tests, execute these commands (requires `docker` and `jq`): +To run acceptance tests, execute these commands (requires `docker` and `jq`): ```bash -source ./scripts/setup_influxdb.sh -make testacc -make stop-influx +task start-influx +task test +task stop-influx ``` ### Build ```bash -go build -o terraform-provider-influxdb-v2 +task build ``` diff --git a/Taskfile.yaml b/Taskfile.yaml index e74fa9f..065f330 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -28,16 +28,10 @@ tasks: - go.sum generates: - ' go build -v -o {{.BINARY_FOLDER}}/terraform-provider-{{.NAME}}_{{.VERSION}}' - - dev: - deps: - - install-dev-override - test: desc: Run unit tests cmds: - go test -tags=unit -v -cover ./... - docs: desc: Update the generated documentation cmds: @@ -50,7 +44,6 @@ tasks: - go.sum generates: - docs/**/*.md - lint: desc: Run linters deps: @@ -70,23 +63,14 @@ tasks: status: - which golangci-lint - golangci-lint version | grep {{.GOLANGCI_LINT_VERSION}} - - install-dev-override: - desc: Set up an override allowing a local version of the provider to be used + start-influx: + desc: Start InfluxDB cmds: - - mkdir -p {{.INSTALL_PATH}}\terraform-provider-{{.NAME}}_{{.VERSION}}_! - #- go build -v -o {{.INSTALL_PATH}}\terraform-provider-{{.NAME}}_{{.VERSION}} - vars: - INSTALL_PATH: '{{if eq OS "windows"}} - %APPDATA%\terraform.d\plugins\registry.terraform.io\{{.NAMESPACE}}\{{.NAME}}\{{.VERSION}}\{{OS}}_{{ARCH}} - {{else if eq OS "darwin" }} - unix-command - {{else}} - linux-command - {{end}}' - - uninstall-dev-override: - desc: Remove any local terraform overrides and binaries for local development + - ./scripts/setup-influxdb.sh + status: + - while ! $(curl -sS 'http://localhost:8086/ready' | grep -q ready); do echo 'Waiting for influx...'; sleep 1; done + stop-influx: + desc: Stop InfluxDB cmds: - - rm ~/.terraformrc - - rm -rf ./bin \ No newline at end of file + - docker stop tf_acc_tests_influxdb + - docker rm tf_acc_tests_influxdb \ No newline at end of file diff --git a/scripts/setup_influxdb.sh b/scripts/setup_influxdb.sh index 8fe1256..bcbd0e5 100755 --- a/scripts/setup_influxdb.sh +++ b/scripts/setup_influxdb.sh @@ -16,4 +16,5 @@ export INFLUXDB_V2_URL="http://localhost:8086" export INFLUXDB_V2_TOKEN="$token" export INFLUXDB_V2_BUCKET_ID="$bucketid" export INFLUXDB_V2_ORG_ID="$orgid" +export TF_ACC=1