This repository is built on the Terraform Plugin Framework.
Build the provider using the Go install
command:
go install
This will build the provider and put the provider binary in the $GOPATH/bin
directory.
Add the following to your .terraformrc
to test with a local version of the provider:
provider_installation {
dev_overrides {
"registry.terraform.io/grafana/grafana-adaptive-metrics" = "/$GOPATH/bin"
}
# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}
go build -gcflags "all=-N -l" -o terraform-provider-grafana-adaptive-metrics .
dlv exec --accept-multiclient --listen=:2345 --continue --headless ./terraform-provider-grafana-adaptive-metrics -- -debug`
dlv
command will output something that starts with TF_REATTACH_PROVIDERS
; prepend that to the terraform command you're testing. For example:
TF_REATTACH_PROVIDERS='{"registry.terraform.io/my-org/my-provider":{"Protocol":"grpc","Pid":3382870,"Test":true,"Addr":{"Network":"unix","String":"/tmp/plugin713096927"}}}' terraform plan
In order to run the full suite of Acceptance tests, run make testacc
.
make testacc
Acceptance tests expect the GRAFANA_AM_API_URL
and GRAFANA_AM_API_KEY
environment variables to be set.
To generate or update documentation, run go generate
.
Note: the installed version of terraform must match your system architecture. If you attempt running the docs generator on an Apple Silicon machine while the amd64 terraform binary is installed, you will receive this error:
Error executing command: unable to generate website: error exporting provider schema from Terraform: unable to run terraform init on provider: exit status 1
Error: Incompatible provider version
Provider registry.terraform.io/hashicorp/adaptive-metrics v0.0.1 does not
have a package available for your current platform, darwin_amd64.
The terraform registry automatically indexes all GitHub releases in this repo. To publish a new release:
First, choose the appropriate version according to semver, then:
git tag <version>
git push origin <version>
At this point a github action will create and sign the release, then the registry will index it.