Skip to content

Commit

Permalink
corrected readme and taskfile
Browse files Browse the repository at this point in the history
  • Loading branch information
hhakkaev-rewe committed Oct 3, 2022
1 parent c0dfc0d commit 8e81f5f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 60 deletions.
59 changes: 24 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
}
}
}
Expand All @@ -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

Expand All @@ -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@<commit sha>`.
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
```
34 changes: 9 additions & 25 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -50,7 +44,6 @@ tasks:
- go.sum
generates:
- docs/**/*.md

lint:
desc: Run linters
deps:
Expand All @@ -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
- docker stop tf_acc_tests_influxdb
- docker rm tf_acc_tests_influxdb
1 change: 1 addition & 0 deletions scripts/setup_influxdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8e81f5f

Please sign in to comment.