Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
api/admin/admin.gen.go linguist-generated=true
api/admin/openapi.json linguist-generated=true
api/admin/openapi.upstream.json linguist-vendored=true
docs/** linguist-generated=true
* text=auto eol=lf
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
groups:
go-dependencies:
patterns:
- "*"
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
github-actions:
patterns:
- "*"
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release

on:
push:
tags:
- "v*"

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
id: import_gpg
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
97 changes: 97 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Tests

on:
pull_request:
paths-ignore:
- "README.md"
push:
branches:
- main
paths-ignore:
- "README.md"
workflow_dispatch:

permissions:
contents: read

jobs:
build:
name: Build and lint
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- run: go mod download
- run: go build -v ./...
# golangci-lint runs through the Makefile so it is compiled with this
# repo's Go toolchain. The prebuilt action binary lags the Go version in
# go.mod and refuses to run against a newer one.
- run: make lint

generate:
name: Docs up to date
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
# tfplugindocs needs Terraform to read the provider schema. Installing it
# here keeps tfplugindocs from downloading its own copy.
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.13.*"
terraform_wrapper: false
- run: make docs
- name: Check for uncommitted changes
run: |
git diff --compact-summary --exit-code || \
(echo; echo "docs/ is out of date. Run 'make docs' and commit the result."; exit 1)

test:
name: Unit tests
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- run: go mod download
- run: go test -v -cover ./...

# Acceptance tests create real, billable Quicknode resources, so they run only
# when triggered by hand. They need QUICKNODE_API_KEY for a paid account that
# is dedicated to testing.
acceptance:
name: Acceptance tests
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.event_name == 'workflow_dispatch'
strategy:
fail-fast: false
matrix:
terraform:
- "1.13.*"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- env:
TF_ACC: "1"
QUICKNODE_API_KEY: ${{ secrets.QUICKNODE_API_KEY }}
run: go test -v -timeout 30m ./...
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
terraform-provider-quicknode
dist/
*.tfstate
*.tfstate.*
.terraform/
.terraform.lock.hcl
.env
27 changes: 27 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "2"

run:
timeout: 5m

linters:
default: standard
enable:
- bodyclose
- copyloopvar
- errorlint
- misspell
- nilerr
- predeclared
- unconvert
- usestdlibvars
exclusions:
generated: lax
paths:
- api/admin/admin.gen.go

formatters:
enable:
- gofmt
exclusions:
paths:
- api/admin/admin.gen.go
61 changes: 61 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
version: 2

before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
flags:
- -trimpath
ldflags:
- "-s -w -X main.version={{.Version}}"
goos:
- darwin
- freebsd
- linux
- windows
goarch:
- amd64
- arm64
- "386"
- arm
goarm:
- "6"
ignore:
- goos: darwin
goarch: "386"
- goos: darwin
goarch: arm
- goos: windows
goarch: arm
binary: "{{ .ProjectName }}_v{{ .Version }}"

archives:
- formats: [zip]
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS"
algorithm: sha256

signs:
- artifacts: checksum
args:
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}"
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"

release:
draft: false
extra_files:
- glob: terraform-registry-manifest.json
name_template: "{{ .ProjectName }}_{{ .Version }}_manifest.json"

changelog:
disable: true
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

## Unreleased

FEATURES:

* **New Resource:** `quicknode_endpoint`
* **New Data Source:** `quicknode_chains`
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @quicknode/devex
83 changes: 83 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Contributing

Thanks for helping improve the Quicknode Terraform provider.

## Getting set up

You need Go (the version in `go.mod`) and Terraform 1.13 or later.

```sh
make build # compile
make test # unit tests
make lint # gofmt, go vet, golangci-lint
```

## Trying a local build

Terraform normally downloads providers from the registry. To point it at a local
build instead, add a development override to `~/.terraformrc`:

```hcl
provider_installation {
dev_overrides {
"quicknode/quicknode" = "/path/to/your/GOPATH/bin"
}
direct {}
}
```

Then `go install .` and run Terraform as usual. Skip `terraform init` — with an
override in place it is neither needed nor supported.

## Making changes

**Schema changes require regenerated docs.** `docs/` is generated from the
provider schema and the files under `examples/`, and CI fails if it is stale:

```sh
make docs
```

Commit the result alongside your change.

**API client changes.** `api/admin/admin.gen.go` is generated and should never
be edited by hand. It comes from `api/admin/openapi.upstream.json`, which is
vendored verbatim, plus the local schema corrections in
`api/admin/patches.json`. To pick up an upstream spec change:

```sh
make vendor # refresh the vendored spec
make generate # apply patches, regenerate the client
```

Review the `make vendor` diff before generating — an upstream change can
silently invalidate a patch.

Domain types live in `internal/client`, not in the generated package. The
provider layer imports `internal/client` and never `api/admin`.

## Tests

Unit tests run against `httptest` servers and need no credentials.

Acceptance tests create real, billable Quicknode resources. They need an Admin
API key for a paid account dedicated to testing:

```sh
QUICKNODE_API_KEY=... make testacc
```

Do not run them against an account with production endpoints.

## Pull requests

- One logical change per pull request.
- Include tests for behavior changes.
- Run `make lint`, `make test` and `make docs` before pushing.
- Describe what the change does and why, not just what files moved.

## Reporting bugs

Open an issue with the provider version, the Terraform version, a minimal
configuration that reproduces the problem, and the output of the failing
command. Redact API keys and endpoint URLs containing tokens.
42 changes: 42 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
OAPI_CODEGEN_VERSION ?= v2.8.0
TFPLUGINDOCS_VERSION ?= v0.23.0
GOLANGCI_LINT_VERSION ?= v2.13.2
ADMIN_SPEC_URL ?= https://www.quicknode.com/docs/openapi/admin-api.openapi.json

default: build

build:
go build ./...

# vendor refreshes the upstream Admin API spec. Review the diff before
# generating: an upstream change can silently invalidate a patch in
# api/admin/patches.json.
vendor:
curl -sSf -o api/admin/openapi.upstream.json $(ADMIN_SPEC_URL)

generate:
go run ./api/admin/gen
cd api/admin && go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@$(OAPI_CODEGEN_VERSION) -config config.yaml openapi.json
gofmt -w api/admin/admin.gen.go

docs:
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@$(TFPLUGINDOCS_VERSION) generate --provider-name quicknode

fmt:
gofmt -w .
terraform fmt -recursive ./examples/

lint:
gofmt -l . | tee /dev/stderr | (! read)
go vet ./...
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run ./...

test:
go test ./...

# testacc creates real, billable Quicknode resources. It needs QUICKNODE_API_KEY
# for a paid account that is dedicated to testing.
testacc:
TF_ACC=1 go test ./... -v -timeout 30m

.PHONY: default build vendor generate docs fmt lint test testacc
Loading
Loading