A modern (protocol 6) Terraform provider for the demo inventory service (work-in-progress).
This Terraform provider code for the inventory service is a proof of concept used primarily for teaching.
Build provider
Run the following command to build & install the provider
make
Test provider
make test
make testacc
- If you want to test out the provider with the
terraform
CLI.
- Edit
$HOME/.terraformrc
and point "superorbital/inventory" to your ${GOBIN} directory.
provider_installation {
dev_overrides {
"superorbital/inventory" = "/home/me/go/path/bin/"
}
direct {}
}
And then create and test a few runs based on the files under examples. NOTE: You should not run terraform init
when using dev_overrides.
Documentation
Documentation is generated with tfplugindocs and exists in the docs directory.
make generate
Release
- Make sure that you update the auto-generated documentation and then commit any changes!
make generate
Then go ahead and create a new release in Github. This will kick of the Github action to handle the rest. Release tags should use semantic versioning and look something like this v1.0.2
.
Pre-Commit Hooks
Install
Local Install (macOS)
- IMPORTANT: All developers committing any code to this repo, should have these pre-commit hooks installed locally. Github actions may also run these at some point, but it is generally faster and easier to run them locally, in most cases.
brew install pre-commit jq shellcheck shfmt git-secrets go-critic golangci-lint
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.15.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
go install github.com/BurntSushi/toml/cmd/tomlv@master
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
go install github.com/orijtech/structslop/cmd/structslop
go install github.com/sqs/goreturns@latest
go install golang.org/x/lint/golint@latest
go install golang.org/x/tools/cmd/goimports@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install mvdan.cc/gofumpt@latest
mkdir -p ${HOME}/.git-template/hooks
git config --global init.templateDir ${HOME}/.git-template
- Close and reopen your terminal
- Make sure that you run these commands from the root of this git repo!
cd terraform-provider-inventory
pre-commit init-templatedir -t pre-commit ${HOME}/.git-template
pre-commit install
pre-commit run -a
git diff
Checks
See:
Configuring Hooks