-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add bonsai_space (GetByPath) and bonsai_spaces (List) data sources. * Add docs gen tooling; refactor spaces and examples a bit. * Add Space Acceptance tests. * Add pre-commit task for docs * Bump timeout-minutes on build * Add details about usage * Update commented out test output
- Loading branch information
Showing
22 changed files
with
855 additions
and
50 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,48 +11,89 @@ on: | |
paths-ignore: | ||
- 'README.md' | ||
|
||
# Testing only needs permissions to read the repository contents. | ||
permissions: | ||
contents: read | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
||
env: | ||
GOPRIVATE: github.com/omc | ||
|
||
jobs: | ||
# Ensure project builds before running testing matrix | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
timeout-minutes: 15 | ||
steps: | ||
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | ||
- uses: actions/[email protected].5 | ||
- uses: actions/[email protected].1 | ||
with: | ||
go-version-file: 'go.mod' | ||
cache: true | ||
- name: Install Task | ||
uses: arduino/setup-task@v2 | ||
with: | ||
version: "3.x" | ||
- name: Check out code into the Go module directory | ||
uses: actions/[email protected] | ||
- name: Add SSH Go Module Private Key | ||
env: | ||
SSH_AUTH_SOCK: /tmp/ssh_agent.sock | ||
run: | | ||
mkdir -p ~/.ssh | ||
ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
ssh-agent -a $SSH_AUTH_SOCK > /dev/null | ||
ssh-add - <<< "${{ secrets.GO_MODULE_PRIVATE_KEY }}" | ||
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV | ||
- name: Setup access for private go modules | ||
run: | | ||
git config --global url."ssh://[email protected]/".insteadOf https://github.com/ | ||
- run: go mod download | ||
- run: go build -v . | ||
- name: Run linters | ||
- name: Build | ||
run: task build | ||
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@82d40c283aeb1f2b6595839195e95c2d6a49081b # v5.0.0 | ||
with: | ||
version: latest | ||
- name: Run additional linters | ||
run: task lint | ||
|
||
generate: | ||
# source: https://github.com/vercel/terraform-provider-vercel | ||
# source license: MPL-2.0 | ||
docs: | ||
name: Docs Test | ||
timeout-minutes: 5 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | ||
- name: Set up Go | ||
uses: actions/[email protected].1 | ||
with: | ||
go-version-file: 'go.mod' | ||
cache: true | ||
# Temporarily download Terraform 1.8 prerelease for function documentation support. | ||
# When Terraform 1.8.0 final is released, this can be removed. | ||
- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1 | ||
go-version: "1.22" | ||
id: go | ||
- name: Install Task | ||
uses: arduino/setup-task@v2 | ||
with: | ||
terraform_version: '1.8.0-alpha20240216' | ||
terraform_wrapper: false | ||
- run: go generate ./... | ||
- name: git diff | ||
version: "3.x" | ||
- name: Add SSH Go Module Private Key | ||
env: | ||
SSH_AUTH_SOCK: /tmp/ssh_agent.sock | ||
run: | | ||
mkdir -p ~/.ssh | ||
ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
ssh-agent -a $SSH_AUTH_SOCK > /dev/null | ||
ssh-add - <<< "${{ secrets.GO_MODULE_PRIVATE_KEY }}" | ||
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV | ||
- name: Setup access for private go modules | ||
run: | | ||
git diff --compact-summary --exit-code || \ | ||
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1) | ||
git config --global url."ssh://[email protected]/".insteadOf https://github.com/ | ||
- name: Check out code into the Go module directory | ||
uses: actions/[email protected] | ||
- name: Check if docs are up-to-date | ||
run: | | ||
task docs | ||
git diff | ||
BADDOCS=$(git status --porcelain) | ||
test -z "$BADDOCS" || (echo -e "documentation needs regenerating using task docs: $BADDOCS"; exit 1) | ||
# Run acceptance tests in a matrix with Terraform CLI versions | ||
test: | ||
|
@@ -63,23 +104,35 @@ jobs: | |
strategy: | ||
fail-fast: false | ||
matrix: | ||
opentofu: | ||
- '1.6.*' | ||
- '1.7.*' | ||
# list whatever Terraform versions here you would like to support | ||
terraform: | ||
- '1.0.*' | ||
- '1.1.*' | ||
- '1.2.*' | ||
- '1.3.*' | ||
- '1.4.*' | ||
- '1.7.*' | ||
- '1.8.*' | ||
steps: | ||
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | ||
- uses: actions/[email protected].5 | ||
- uses: actions/[email protected].1 | ||
with: | ||
go-version-file: 'go.mod' | ||
cache: true | ||
- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1 | ||
with: | ||
terraform_version: ${{ matrix.terraform }} | ||
terraform_wrapper: false | ||
- name: Add SSH Go Module Private Key | ||
env: | ||
SSH_AUTH_SOCK: /tmp/ssh_agent.sock | ||
run: | | ||
mkdir -p ~/.ssh | ||
ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
ssh-agent -a $SSH_AUTH_SOCK > /dev/null | ||
ssh-add - <<< "${{ secrets.GO_MODULE_PRIVATE_KEY }}" | ||
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV | ||
- name: Setup access for private go modules | ||
run: | | ||
git config --global url."ssh://[email protected]/".insteadOf https://github.com/ | ||
- run: go mod download | ||
- env: | ||
TF_ACC: "1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
30130b5de9de24c4ab560530998ab6f4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# source: https://github.com/vercel/terraform-provider-vercel | ||
# source license: MPL-2.0 | ||
|
||
# https://taskfile.dev | ||
version: "3" | ||
|
||
tasks: | ||
build: | ||
desc: "Build the provider binary" | ||
deps: | ||
- install-goreleaser | ||
cmds: | ||
- goreleaser build --single-target --skip=validate --clean --snapshot | ||
sources: | ||
- "**/*.go" | ||
- go.mod | ||
- go.sum | ||
generates: | ||
- terraform-provider-bonsai | ||
|
||
test: | ||
desc: "Run acceptance tests against the provider" | ||
env: | ||
TF_ACC: "1" | ||
cmds: | ||
- go test ./... {{.CLI_ARGS}} | ||
|
||
install-tfplugindocs: | ||
desc: "Install the tfplugindocs tool" | ||
cmds: | ||
- go install github.com/hashicorp/terraform-plugin-docs/cmd/[email protected] | ||
status: | ||
- which tfplugindocs | ||
|
||
install-goreleaser: | ||
desc: "Install goreleaser" | ||
cmds: | ||
- go install github.com/goreleaser/goreleaser@latest | ||
status: | ||
- which goreleaser | ||
|
||
docs: | ||
desc: "Update the docs generated from description fields" | ||
deps: | ||
- install-tfplugindocs | ||
cmds: | ||
- tfplugindocs | ||
- sed -i.bak 's/bonsai Provider/Bonsai Provider/g' docs/index.md | ||
- rm docs/index.md.bak | ||
sources: | ||
- "internal/**/*.go" | ||
- "main.go" | ||
- "examples/**/*.tf" | ||
- "examples/**/*.sh" | ||
generates: | ||
- docs/**/*.md | ||
|
||
install-staticcheck: | ||
desc: "Install the staticheck tool" | ||
cmds: | ||
- go install honnef.co/go/tools/cmd/[email protected] | ||
status: | ||
- which staticcheck | ||
|
||
install-providerlint: | ||
desc: "Install tfproviderlint tool" | ||
cmds: | ||
- go install github.com/bflad/tfproviderlint/cmd/tfproviderlint@latest | ||
status: | ||
- which tfproviderlint | ||
|
||
lint: | ||
desc: "Run linters against the provider" | ||
deps: | ||
- install-staticcheck | ||
- install-providerlint | ||
cmds: | ||
- staticcheck -tags it ./... | ||
- tfproviderlint -R018=false ./... | ||
- cmd: | | ||
export BADFMT=$(gofmt -s -l .) | ||
test -z "$BADFMT" || (echo -e "invalid gofmt: $BADFMT"; exit 1) | ||
silent: true | ||
- go vet ./... | ||
|
||
install: | ||
desc: "Set up an override allowing a local version of the provider to be used" | ||
cmds: | ||
- cmd: |- | ||
cat << EOF > ~/.terraformrc | ||
provider_installation { | ||
dev_overrides { | ||
"omc/bonsai" = "$(pwd)/dist/terraform-provider-vercel_{{ OS }}_{{ ARCH }}" | ||
} | ||
direct {} | ||
} | ||
EOF | ||
uninstall: | ||
desc: "Remove any local overrides for local development" | ||
cmds: | ||
- rm ~/.terraformrc | ||
|
||
sweep: | ||
desc: "Remove any leftover resources from failed test runs" | ||
dir: "sweep" | ||
cmds: | ||
- go run . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "bonsai_space Data Source - terraform-provider-bonsai" | ||
subcategory: "" | ||
description: |- | ||
A Space represents the server groups and geographic regions available to a Bonsai.io https://bonsai.io account, where clusters may be provisioned. | ||
--- | ||
|
||
# bonsai_space (Data Source) | ||
|
||
A Space represents the server groups and geographic regions available to a [Bonsai.io](https://bonsai.io) account, where clusters may be provisioned. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "bonsai_space" "example" { | ||
path = "omc/websolr/us-east-1/common" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `path` (String) A machine-readable name for the server group. | ||
|
||
### Read-Only | ||
|
||
- `cloud` (Attributes) Details about the cloud provider and region attributes. (see [below for nested schema](#nestedatt--cloud)) | ||
- `private_network` (Boolean) Indicates whether the space is isolated and inaccessible from the public Internet. A VPC connection will be needed to communicate with a private cluster. | ||
|
||
<a id="nestedatt--cloud"></a> | ||
### Nested Schema for `cloud` | ||
|
||
Read-Only: | ||
|
||
- `provider` (String) A machine-readable name for the cloud provider in which this space is deployed. | ||
- `region` (String) A machine-readable name for the geographic region of the server group. |
Oops, something went wrong.