diff --git a/GNUmakefile b/GNUmakefile index c70aaa09..70a92d1d 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,6 +3,9 @@ default: build build: go build -v ./... +install: build + go install -v ./... + # See https://golangci-lint.run/ lint: golangci-lint run @@ -19,4 +22,4 @@ test: testacc: TF_ACC=1 go test -v -cover -timeout 120m ./... -.PHONY: build lint generate fmt test testacc +.PHONY: build install lint generate fmt test testacc diff --git a/README.md b/README.md index a02612bd..8fbec86a 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,9 @@ The remainder of this document will focus on the development aspects of the prov * [GNU Make](https://www.gnu.org/software/make/) * [golangci-lint](https://golangci-lint.run/usage/install/#local-installation) (optional) -## Building +## Development + +### Building 1. `git clone` this repository and `cd` into its directory 2. `make` will trigger the Golang build @@ -51,14 +53,41 @@ and associate it with the release version. Read more about how this works on the Use `make generate` to ensure the documentation is regenerated with any changes. +### Using a development build + +If [running tests and acceptance tests](#testing) isn't enough, it's possible to set up a local terraform configuration +to use a development builds of the provider. This can be achieved by leveraging the Terraform CLI +[configuration file development overrides](https://www.terraform.io/cli/config/config-file#development-overrides-for-provider-developers). + +First, use `make install` to place a fresh development build of the provider in your [`${GOBIN}`](https://pkg.go.dev/cmd/go#hdr-Compile_and_install_packages_and_dependencies) (defaults to `${GOPATH}/bin` or `${HOME}/go/bin` if `${GOPATH}` is not set). Repeat +this every time you make changes to the provider locally. + +Then, in your `${HOME}/.terraformrc` (Unix) / `%APPDATA%\terraform.rc` (Windows), a `provider_installation` that contains +the following `dev_overrides`: + +```hcl +provider_installation { + dev_overrides { + "hashicorp/tls" = "${GOBIN}" //< replace `${GOBIN}` with the actual path on your system + } + + direct {} +} +``` + +Note that it's also possible to use a dedicated Terraform configuration file and invoke `terraform` while setting +the environment variable `TF_CLI_CONFIG_FILE=my_terraform_config_file`. + +Once the `dev_overrides` are in place, any local execution of `terraform plan` and `terraform apply` will +use the version of the provider found in the given `${GOBIN}` directory, +instead of the one indicated in your terraform configuration. ## Releasing -The release process is automated via GitHub Actions, -and it's defined in the Workflow [release.yml](./.github/workflows/release.yml). +The release process is automated via GitHub Actions, and it's defined in the Workflow +[release.yml](./.github/workflows/release.yml). -Each release is cut by pushing a [semantically versioned](https://semver.org/) -tag to the default branch. +Each release is cut by pushing a [semantically versioned](https://semver.org/) tag to the default branch. ## License