From d2451eb650d8f8f352b89f638f78220ca7208df2 Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Mon, 12 Oct 2026 00:40:26 +1100 Subject: [PATCH] Add estate CI, release and Makefile; use git.unkin.net/unkin/binarylane source --- .gitignore | 1 + .pre-commit-config.yaml | 17 ++++++++++ .woodpecker/build.yml | 30 ++++++++++++++++ .woodpecker/pre-commit.yaml | 30 ++++++++++++++++ .woodpecker/release.yml | 52 ++++++++++++++++++++++++++++ .woodpecker/test.yml | 57 +++++++++++++++++++++++++++++++ CONTRIBUTING.md | 2 +- Makefile | 64 +++++++++++++++++++++++++++++++++++ docs/index.md | 2 +- examples/basic/main.tf | 2 +- examples/cloud-init/README.md | 2 +- examples/cloud-init/main.tf | 2 +- examples/k3s/providers.tf | 2 +- examples/nix/main.tf | 2 +- examples/offerings/main.tf | 2 +- examples/provider/provider.tf | 2 +- examples/ssh/main.tf | 2 +- examples/vpc/main.tf | 2 +- main.go | 2 +- 19 files changed, 263 insertions(+), 12 deletions(-) create mode 100644 .pre-commit-config.yaml create mode 100644 .woodpecker/build.yml create mode 100644 .woodpecker/pre-commit.yaml create mode 100644 .woodpecker/release.yml create mode 100644 .woodpecker/test.yml create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 066bada..68e6270 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ tmp # Normally, you wouldn't want to exclude lock files, but our examples are tested # with a locally built provider and won't be useful to others. .terraform.lock.hcl +*.zip diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..35028bf --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + exclude: ^docs/ + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + - repo: https://github.com/dnephin/pre-commit-golang + rev: v0.5.1 + hooks: + - id: go-fmt + - id: go-vet + exclude: ^tools/ + - id: go-mod-tidy diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml new file mode 100644 index 0000000..65710a6 --- /dev/null +++ b/.woodpecker/build.yml @@ -0,0 +1,30 @@ +when: + - event: pull_request + +steps: + - name: build + image: artifactapi.k8s.syd1.au.unkin.net/docker-internal/gobuilder:0.1.2-alma9 + environment: + GOCACHE_S3_BUCKET: gocache + GOCACHE_S3_REGION: us-east-1 + GOCACHE_S3_ENDPOINT_URL: https://s3.ceph.unkin.net + GOCACHE_S3_PATH_STYLE: "true" + GOCACHE_KEY_PREFIX: ci-terraform-provider-binarylane + GOCACHE_METRICS: "true" + GOCACHEPROG: go-cache-plugin --cache-dir=/tmp/gocache + AWS_ACCESS_KEY_ID: + from_secret: GOCACHE_AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: GOCACHE_AWS_SECRET_ACCESS_KEY + commands: + - make build + backend_options: + kubernetes: + serviceAccountName: default + resources: + requests: + memory: 512Mi + cpu: 1 + limits: + memory: 2Gi + cpu: 2 diff --git a/.woodpecker/pre-commit.yaml b/.woodpecker/pre-commit.yaml new file mode 100644 index 0000000..5d7b741 --- /dev/null +++ b/.woodpecker/pre-commit.yaml @@ -0,0 +1,30 @@ +when: + - event: pull_request + +steps: + - name: pre-commit + image: artifactapi.k8s.syd1.au.unkin.net/docker-internal/gobuilder:0.1.2-alma9 + environment: + GOCACHE_S3_BUCKET: gocache + GOCACHE_S3_REGION: us-east-1 + GOCACHE_S3_ENDPOINT_URL: https://s3.ceph.unkin.net + GOCACHE_S3_PATH_STYLE: "true" + GOCACHE_KEY_PREFIX: ci-terraform-provider-binarylane + GOCACHE_METRICS: "true" + GOCACHEPROG: go-cache-plugin --cache-dir=/tmp/gocache + AWS_ACCESS_KEY_ID: + from_secret: GOCACHE_AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: GOCACHE_AWS_SECRET_ACCESS_KEY + commands: + - uvx pre-commit run --all-files + backend_options: + kubernetes: + serviceAccountName: default + resources: + requests: + memory: 512Mi + cpu: 1 + limits: + memory: 2Gi + cpu: 2 diff --git a/.woodpecker/release.yml b/.woodpecker/release.yml new file mode 100644 index 0000000..2e039d8 --- /dev/null +++ b/.woodpecker/release.yml @@ -0,0 +1,52 @@ +when: + - event: tag + +steps: + - name: package + image: artifactapi.k8s.syd1.au.unkin.net/docker-internal/gobuilder:0.1.2-alma9 + environment: + GOCACHE_S3_BUCKET: gocache + GOCACHE_S3_REGION: us-east-1 + GOCACHE_S3_ENDPOINT_URL: https://s3.ceph.unkin.net + GOCACHE_S3_PATH_STYLE: "true" + GOCACHE_KEY_PREFIX: ci-terraform-provider-binarylane + GOCACHE_METRICS: "true" + GOCACHEPROG: go-cache-plugin --cache-dir=/tmp/gocache + AWS_ACCESS_KEY_ID: + from_secret: GOCACHE_AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: GOCACHE_AWS_SECRET_ACCESS_KEY + commands: + - make package VERSION=${CI_COMMIT_TAG} + backend_options: + kubernetes: + serviceAccountName: default + resources: + requests: + memory: 512Mi + cpu: 1 + limits: + memory: 2Gi + cpu: 2 + + - name: upload + image: git.unkin.net/unkin/almalinux9-base:20260606 + commands: + - | + VERSION=$$(echo ${CI_COMMIT_TAG} | sed 's/^v//') + FILE="terraform-provider-binarylane_$${VERSION}_linux_amd64.zip" + curl -f -X PUT \ + "https://artifactapi.k8s.syd1.au.unkin.net/api/v2/remotes/terraform-unkin/files/unkin/binarylane/$${FILE}" \ + -H "Content-Type: application/zip" \ + --data-binary @"$${FILE}" + depends_on: [package] + backend_options: + kubernetes: + serviceAccountName: default + resources: + requests: + memory: 128Mi + cpu: 100m + limits: + memory: 512Mi + cpu: 500m diff --git a/.woodpecker/test.yml b/.woodpecker/test.yml new file mode 100644 index 0000000..aad6a88 --- /dev/null +++ b/.woodpecker/test.yml @@ -0,0 +1,57 @@ +when: + - event: pull_request + +steps: + - name: lint + image: artifactapi.k8s.syd1.au.unkin.net/docker-internal/gobuilder:0.1.2-alma9 + environment: + GOCACHE_S3_BUCKET: gocache + GOCACHE_S3_REGION: us-east-1 + GOCACHE_S3_ENDPOINT_URL: https://s3.ceph.unkin.net + GOCACHE_S3_PATH_STYLE: "true" + GOCACHE_KEY_PREFIX: ci-terraform-provider-binarylane + GOCACHE_METRICS: "true" + GOCACHEPROG: go-cache-plugin --cache-dir=/tmp/gocache + AWS_ACCESS_KEY_ID: + from_secret: GOCACHE_AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: GOCACHE_AWS_SECRET_ACCESS_KEY + commands: + - make lint + backend_options: + kubernetes: + serviceAccountName: default + resources: + requests: + memory: 512Mi + cpu: 1 + limits: + memory: 2Gi + cpu: 2 + + - name: test + image: artifactapi.k8s.syd1.au.unkin.net/docker-internal/gobuilder:0.1.2-alma9 + environment: + GOCACHE_S3_BUCKET: gocache + GOCACHE_S3_REGION: us-east-1 + GOCACHE_S3_ENDPOINT_URL: https://s3.ceph.unkin.net + GOCACHE_S3_PATH_STYLE: "true" + GOCACHE_KEY_PREFIX: ci-terraform-provider-binarylane + GOCACHE_METRICS: "true" + GOCACHEPROG: go-cache-plugin --cache-dir=/tmp/gocache + AWS_ACCESS_KEY_ID: + from_secret: GOCACHE_AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: GOCACHE_AWS_SECRET_ACCESS_KEY + commands: + - make test + backend_options: + kubernetes: + serviceAccountName: default + resources: + requests: + memory: 512Mi + cpu: 1 + limits: + memory: 2Gi + cpu: 2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e87c6a7..5977d4c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ Based on [this example from the terraform docs](https://developer.hashicorp.com/ provider_installation { dev_overrides { # Example GOBIN path, will need to be replaced with your own GOBIN path. Default is $GOPATH/bin - "oscarhermoso/binarylane" = "/home/oscarhermoso/Git/terraform-provider-binarylane/bin" + "git.unkin.net/unkin/binarylane" = "/path/to/terraform-provider-binarylane/bin" } direct {} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3d98897 --- /dev/null +++ b/Makefile @@ -0,0 +1,64 @@ +.PHONY: build install test lint fmt clean tidy package pre-commit patch minor major check-go + +BINARY := terraform-provider-binarylane +VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "0.0.0-dev") +OS_ARCH := linux_amd64 +INSTALL_VERSION := $(shell echo $(VERSION) | sed 's/^v//') +INSTALL_DIR := ~/.terraform.d/plugins/git.unkin.net/unkin/binarylane/$(INSTALL_VERSION)/$(OS_ARCH) +ZIP := $(BINARY)_$(INSTALL_VERSION)_$(OS_ARCH).zip + +GO_VERSION_REQUIRED := 1.25 +GO_VERSION_ACTUAL := $(shell go version | sed 's/go version go\([0-9]*\.[0-9]*\).*/\1/') + +check-go: + @if [ "$$(printf '%s\n%s' "$(GO_VERSION_REQUIRED)" "$(GO_VERSION_ACTUAL)" | sort -V | head -1)" != "$(GO_VERSION_REQUIRED)" ]; then \ + echo "ERROR: Go >= $(GO_VERSION_REQUIRED) required, found $(GO_VERSION_ACTUAL)"; exit 1; \ + fi + +build: check-go tidy + go build -ldflags="-s -w -X main.version=$(VERSION)" -o $(BINARY) + +install: build + mkdir -p $(INSTALL_DIR) + cp $(BINARY) $(INSTALL_DIR)/ + +test: check-go + go test -race -count=1 ./... + +lint: check-go + go vet ./... + +fmt: check-go + gofmt -w . + +package: build + cp $(BINARY) $(BINARY)_v$(INSTALL_VERSION) + python3 -c "import zipfile,sys; z=zipfile.ZipFile(sys.argv[1],'w',zipfile.ZIP_DEFLATED); z.write(sys.argv[2]); z.close()" $(ZIP) $(BINARY)_v$(INSTALL_VERSION) + rm $(BINARY)_v$(INSTALL_VERSION) + +pre-commit: + uvx pre-commit run --all-files + +clean: + rm -f $(BINARY) *.zip + +tidy: + go mod tidy + +_LATEST := $(shell git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$$' | head -1) +_BASE := $(if $(_LATEST),$(_LATEST),v0.0.0) +_MAJ := $(shell echo $(_BASE) | sed 's/^v//' | cut -d. -f1) +_MIN := $(shell echo $(_BASE) | sed 's/^v//' | cut -d. -f2) +_PAT := $(shell echo $(_BASE) | sed 's/^v//' | cut -d. -f3) + +patch: + @NEW=v$(_MAJ).$(_MIN).$(shell expr $(_PAT) + 1); \ + git tag $$NEW && echo "Tagged $$NEW" && git push origin $$NEW + +minor: + @NEW=v$(_MAJ).$(shell expr $(_MIN) + 1).0; \ + git tag $$NEW && echo "Tagged $$NEW" && git push origin $$NEW + +major: + @NEW=v$(shell expr $(_MAJ) + 1).0.0; \ + git tag $$NEW && echo "Tagged $$NEW" && git push origin $$NEW diff --git a/docs/index.md b/docs/index.md index 0522591..08a7054 100644 --- a/docs/index.md +++ b/docs/index.md @@ -15,7 +15,7 @@ description: |- terraform { required_providers { binarylane = { - source = "oscarhermoso/binarylane" + source = "git.unkin.net/unkin/binarylane" } } } diff --git a/examples/basic/main.tf b/examples/basic/main.tf index f88a3f6..78ec28a 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { binarylane = { - source = "oscarhermoso/binarylane" + source = "git.unkin.net/unkin/binarylane" } } } diff --git a/examples/cloud-init/README.md b/examples/cloud-init/README.md index 10f07e6..dff8c60 100644 --- a/examples/cloud-init/README.md +++ b/examples/cloud-init/README.md @@ -8,7 +8,7 @@ If you want to deploy multiple parts of a cloud-init configuration, you can use terraform { required_providers { binarylane = { - source = "oscarhermoso/binarylane" + source = "git.unkin.net/unkin/binarylane" } } } diff --git a/examples/cloud-init/main.tf b/examples/cloud-init/main.tf index 9077b3a..67be2c8 100644 --- a/examples/cloud-init/main.tf +++ b/examples/cloud-init/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { binarylane = { - source = "oscarhermoso/binarylane" + source = "git.unkin.net/unkin/binarylane" } } } diff --git a/examples/k3s/providers.tf b/examples/k3s/providers.tf index 7b02867..f75bb61 100644 --- a/examples/k3s/providers.tf +++ b/examples/k3s/providers.tf @@ -1,7 +1,7 @@ terraform { required_providers { binarylane = { - source = "oscarhermoso/binarylane" + source = "git.unkin.net/unkin/binarylane" } } } diff --git a/examples/nix/main.tf b/examples/nix/main.tf index 27aeea3..f116c3b 100644 --- a/examples/nix/main.tf +++ b/examples/nix/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { binarylane = { - source = "oscarhermoso/binarylane" + source = "git.unkin.net/unkin/binarylane" } } } diff --git a/examples/offerings/main.tf b/examples/offerings/main.tf index 202a652..434a511 100644 --- a/examples/offerings/main.tf +++ b/examples/offerings/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { binarylane = { - source = "oscarhermoso/binarylane" + source = "git.unkin.net/unkin/binarylane" } } } diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 8748dad..3e256ae 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -1,7 +1,7 @@ terraform { required_providers { binarylane = { - source = "oscarhermoso/binarylane" + source = "git.unkin.net/unkin/binarylane" } } } diff --git a/examples/ssh/main.tf b/examples/ssh/main.tf index 0c765f3..7ecd363 100644 --- a/examples/ssh/main.tf +++ b/examples/ssh/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { binarylane = { - source = "oscarhermoso/binarylane" + source = "git.unkin.net/unkin/binarylane" } } } diff --git a/examples/vpc/main.tf b/examples/vpc/main.tf index 4ec7390..9aac7ba 100644 --- a/examples/vpc/main.tf +++ b/examples/vpc/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { binarylane = { - source = "oscarhermoso/binarylane" + source = "git.unkin.net/unkin/binarylane" } } } diff --git a/main.go b/main.go index 8af75ca..8b3cd17 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,7 @@ func main() { flag.Parse() opts := providerserver.ServeOpts{ - Address: "hashicorp.com/oscarhermoso/binarylane", + Address: "git.unkin.net/unkin/binarylane", Debug: debug, } -- 2.47.3