From f6c03109ceb05364d8d15808b9bf2d8facc4035a Mon Sep 17 00:00:00 2001 From: Manuel Ganter Date: Tue, 18 Nov 2025 14:00:09 +0100 Subject: [PATCH 1/6] updated goreleaser to match tf expectation --- .goreleaser.yaml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 1bf1eca..bb35f3e 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -17,19 +17,15 @@ builds: - arm64 archives: - - formats: [tar.gz] - # this name template makes the OS and Arch compatible with the results of `uname`. - name_template: >- - {{ .ProjectName }}_ - {{- title .Os }}_ - {{- if eq .Arch "amd64" }}x86_64 - {{- else if eq .Arch "386" }}i386 - {{- else }}{{ .Arch }}{{ end }} - {{- if .Arm }}v{{ .Arm }}{{ end }} - # use zip for windows archives - format_overrides: - - goos: windows - formats: [zip] + - format: zip + name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' + +checksum: + extra_files: + - glob: 'terraform-registry-manifest.json' + name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' + name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' + algorithm: sha256 signs: - artifacts: checksum From 692e563ca99d7bdd0878e01265a9edcdae656252 Mon Sep 17 00:00:00 2001 From: Manuel Ganter Date: Tue, 18 Nov 2025 14:04:36 +0100 Subject: [PATCH 2/6] added terraform-registry-manifest.json --- terraform-registry-manifest.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 terraform-registry-manifest.json diff --git a/terraform-registry-manifest.json b/terraform-registry-manifest.json new file mode 100644 index 0000000..fec2a56 --- /dev/null +++ b/terraform-registry-manifest.json @@ -0,0 +1,6 @@ +{ + "version": 1, + "metadata": { + "protocol_versions": ["6.0"] + } +} From 593841bf1f7d4424797bc6ce1f5dd1a537a24e01 Mon Sep 17 00:00:00 2001 From: Manuel Ganter Date: Tue, 18 Nov 2025 15:46:54 +0100 Subject: [PATCH 3/6] improved .goreleaser.yaml --- .goreleaser.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index bb35f3e..0d9b264 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -17,14 +17,14 @@ builds: - arm64 archives: - - format: zip - name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' + - formats: ["zip"] + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" checksum: extra_files: - - glob: 'terraform-registry-manifest.json' - name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' - name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' + - glob: "terraform-registry-manifest.json" + name_template: "{{ .ProjectName }}_{{ .Version }}_manifest.json" + name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS" algorithm: sha256 signs: @@ -64,6 +64,9 @@ release: gitea: owner: DevFW-CICD name: terraform-provider-edge-connect + extra_files: + - glob: 'terraform-registry-manifest.json' + name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' force_token: gitea gitea_urls: From 7cb14a872a531717a0128105d2467044b086398f Mon Sep 17 00:00:00 2001 From: Martin McCaffery Date: Wed, 19 Nov 2025 09:53:11 +0100 Subject: [PATCH 4/6] test: output json from goreleaser --- .github/workflows/release.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3040258..da0ef5f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -26,9 +26,15 @@ jobs: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.GPG_PASSPHRASE }} - name: Run GoReleaser + id: goreleaser uses: https://github.com/goreleaser/goreleaser-action@v6 env: GITEA_TOKEN: ${{ secrets.PACKAGES_TOKEN }} GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} with: args: release --clean + + - name: TEST output json (artifacts) + run: echo "${{steps.goreleaser.outputs.artifacts}}" + - name: TEST output json (metadata) + run: echo "${{steps.goreleaser.outputs.metadata}}" From c8104c0f1d500d9853c9a793adf1bc5c3a55ff92 Mon Sep 17 00:00:00 2001 From: Martin McCaffery Date: Wed, 19 Nov 2025 10:50:39 +0100 Subject: [PATCH 5/6] workflow: generate provider.json, upload to terralist --- .github/workflows/release.yaml | 12 +++++--- generate-provider-json.sh | 51 ++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 4 deletions(-) create mode 100755 generate-provider-json.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index da0ef5f..11ec0f8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -34,7 +34,11 @@ jobs: with: args: release --clean - - name: TEST output json (artifacts) - run: echo "${{steps.goreleaser.outputs.artifacts}}" - - name: TEST output json (metadata) - run: echo "${{steps.goreleaser.outputs.metadata}}" + - name: Generate and upload provider.json + run: | + echo '${{steps.goreleaser.outputs.artifacts}}' >artifacts.json + echo '${{steps.goreleaser.outputs.metadata}}' >metadata.json + ./generate-provider-json.sh artifacts.json metadata.json + env: + TERRALIST_API: https://terralist.garm-provider-test.t09.de/v1/api + TERRALIST_API_KEY: ${{ secrets.TERRALIST_API_KEY }} diff --git a/generate-provider-json.sh b/generate-provider-json.sh new file mode 100755 index 0000000..1cd1124 --- /dev/null +++ b/generate-provider-json.sh @@ -0,0 +1,51 @@ +#!/bin/bash +set -o errexit + +# This script generates and uploads a terraform provider.json file and uploads it to Terralist + +ARTIFACTS_FILE=$1 +METADATA_FILE=$2 + +TERRALIST_API=${TERRALIST_API:-https://terralist.garm-provider-test.t09.de/v1/api} +TERRALIST_API_KEY=${TERRALIST_API_KEY:-invalid-key} + +VERSION=$(cat $METADATA_FILE | jq -r '.version') + +BASE_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download" + +if ! [[ "$BASE_URL" =~ "terraform" ]]; then + echo "Error: GITHUB_ environment variables not set correctly" >&2 + exit 1 +fi + +jq --arg base_url "$BASE_URL" --arg version "$VERSION" ' +{ + protocols: ["6"], + + shasums: ( + { + url: ($base_url + "/v" + $version + "/" + (.[] + | select(.type=="Checksum").name)), + signature_url: ($base_url + "/v" + $version + "/" + (.[] + | select(.type=="Signature").name)) + } + ), + + platforms: [ + .[] + | select(.type=="Archive") + | { + os: .goos, + arch: .goarch, + download_url: ($base_url + "/v" + $version + "/" + .name), + shasum: (.extra.Checksum | sub("^sha256:";"")) + } + ] +} +' $ARTIFACTS_FILE >./provider.json + +cat provider.json | jq . + +curl -X POST $TERRALIST_API/providers/edge-connect/${VERSION}/upload \ + -H "Authorization: Bearer x-api-key:$TERRALIST_API_KEY" \ + -d "$(cat ./provider.json)" \ No newline at end of file From da1f4eecdb6b23a6cc180d80a9b8002c80dace2f Mon Sep 17 00:00:00 2001 From: "martin.mccaffery" Date: Wed, 3 Dec 2025 10:26:45 +0000 Subject: [PATCH 6/6] Update README.md to separate provider conf and local dev --- README.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d2f1b50..e94483b 100644 --- a/README.md +++ b/README.md @@ -50,17 +50,11 @@ mkdir -p ~/.terraform.d/plugins/registry.terraform.io/DevFW-CICD/edge-connect/1. cp terraform-provider-edge-connect ~/.terraform.d/plugins/registry.terraform.io/DevFW-CICD/edge-connect/1.0.0/darwin_arm64/ ``` -Note: Adjust the path based on your OS and architecture (e.g., `linux_amd64`, `darwin_amd64`, etc.) +> Note: Adjust the path based on your OS and architecture (e.g., `linux_amd64`, `darwin_amd64`, etc.) -## Usage +4. Generate the binary by running `go install .` from the repository root. This installs the provider binary to `$HOME/go/bin` and means that `terraform init` is not necessary. -### Provider Configuration - -As the provider is currently not officially registered for public download, terraform must be configured to use a locally built version. - -To generate the binary run `go install .` from the repository root. This installs the provider binary to `$HOME/go/bin` and means that `terraform init` is not necessary. - -You will also need a `~/.terraformrc` file with the following contents. `` should refer to your `$HOME` directory. +5. You will also need a `~/.terraformrc` file with the following contents. `` should refer to your `$HOME` directory. ```hcl provider_installation { @@ -76,7 +70,11 @@ provider_installation { } ``` -You can then reference the local provider in your `.tf` files as follows: +## Usage + +### Provider Configuration + +The provider must be configured with credentials and a URL. This can be done with a token in your code: ```hcl provider "edge-connect" { @@ -85,7 +83,7 @@ provider "edge-connect" { } ``` -Or using basic authentication: +Or with basic authentication: ```hcl provider "edge-connect" { @@ -95,7 +93,7 @@ provider "edge-connect" { } ``` -Configuration can also be provided via environment variables: +Or without code changes, via environment variables: - `EDGE_CONNECT_BASE_URL` - `EDGE_CONNECT_TOKEN` - `EDGE_CONNECT_USERNAME`