Compare commits

..

1 commit
main ... v0.0.8

Author SHA1 Message Date
6cc9905612
test: output json from goreleaser
All checks were successful
test / test (push) Successful in 19s
ci / goreleaser (push) Successful in 28s
2025-11-19 09:53:11 +01:00
10 changed files with 61 additions and 119 deletions

View file

@ -25,15 +25,7 @@ jobs:
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Print GPG information
run: |
echo "To set up Terralist properly, you need to input the following Signing Key as per the README:"
echo "More info: https://edp.buildth.ing/DevFW-CICD/terraform-provider-edge-connect#terralist"
echo "Key ID: ${{ steps.import_gpg.outputs.keyid }}"
echo "ASCII armor:"
gpg --armor --export ${{ steps.import_gpg.outputs.keyid }}
- name: Run GoReleaser
id: goreleaser
uses: https://github.com/goreleaser/goreleaser-action@v6
env:
GITEA_TOKEN: ${{ secrets.PACKAGES_TOKEN }}
@ -41,11 +33,7 @@ jobs:
with:
args: release --clean
- 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 }}
- name: TEST output json (artifacts)
run: echo "{{steps.goreleaser.outputs.artifacts}}"
- name: TEST output json (metadata)
run: echo "{{steps.goreleaser.outputs.metadata}}"

View file

@ -24,59 +24,59 @@ This Terraform provider allows you to manage Edge Connect applications and appli
terraform {
required_providers {
edge-connect = {
source = "terralist.garm-provider-test.t09.de/edge-connect/edge-connect"
version = ">= 0.0.15"
source = "DevFW-CICD/edge-connect"
version = "~> 1.0"
}
}
}
```
### Terralist
To allow the above downloads, the provider artifact must be published to a private Terraform registry. We use [Terralist](https://www.terralist.io/).
Terralist is deployed on EDP [clusters](https://terralist.garm-provider-test.t09.de/) via [ArgoCD](https://argocd.garm-provider-test.t09.de) using the [terralist stack](https://edp.buildth.ing/DevFW-CICD/stacks/src/branch/main/template/stacks/terralist). Administration can be performed by logging in via the relevant [Forgejo instance](https://garm-provider-test.t09.de/) ([set up](https://edp.buildth.ing/DevFW-CICD/stacks/src/commit/ce8865007cefe3aaec3184fcbf7df955b95a8ef3/template/stacks/terralist/terralist/values.yaml#L7-L38) during [cluster deployment](https://edp.buildth.ing/DevFW/infra-deploy/src/commit/95904c87f0c7248d418d7ed1dc6754d81fc4cccc/scripts/edp-install.sh#L216-L224)), but no authentication is needed to download published Providers.
Publishing a new instance requires a GPG key, which is stored within the Forgejo [Organisation secrets](https://edp.buildth.ing/org/DevFW-CICD/settings/actions/secrets) to be [available](https://edp.buildth.ing/DevFW-CICD/terraform-provider-edge-connect/src/commit/da1f4eecdb6b23a6cc180d80a9b8002c80dace2f/.github/workflows/release.yaml#L26-L27) to the [release pipeline](https://edp.buildth.ing/DevFW-CICD/terraform-provider-edge-connect/src/branch/main/.github/workflows/release.yaml). It also requires a `TERRALIST_API_KEY` (stored at the [repository level](https://edp.buildth.ing/DevFW-CICD/terraform-provider-edge-connect/settings/actions/secrets)) to be able to push; this can be created within [terralist settings](https://terralist.garm-provider-test.t09.de/#/settings): first create a new Authority with Name `edge-connect` and empty Policy, create a new API Key, then hit the ▽ button and 𓁹 to view the Key.
Next, you must ensure Terraform can download the Provider. To the Authority, add a Signing Key, with Key ID and ASCII Armor copied from the output of the [release workflow](https://edp.buildth.ing/DevFW-CICD/terraform-provider-edge-connect/actions/?workflow=release.yaml&actor=0&status=0). Trust Signature can be left empty.
### Local Development
1. Clone the repository:
```bash
git clone ssh://git@edp.buildth.ing/DevFW-CICD/terraform-provider-edge-connect.git
cd terraform-provider-edge-connect
```
```bash
git clone ssh://git@edp.buildth.ing/DevFW-CICD/terraform-provider-edge-connect.git
cd terraform-provider-edge-connect
```
1. 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. Note that you will need `$HOME/go/bin` to be in your `$PATH` variable for this to work smoothly.
2. Build the provider:
```bash
go build -o terraform-provider-edge-connect
```
1. You will also need a `~/.terraformrc` file with the following contents. `<home>` should refer to your `$HOME` directory. It should contain the following:
3. Install locally:
```bash
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/DevFW-CICD/edge-connect/1.0.0/darwin_arm64
cp terraform-provider-edge-connect ~/.terraform.d/plugins/registry.terraform.io/DevFW-CICD/edge-connect/1.0.0/darwin_arm64/
```
```hcl
provider_installation {
dev_overrides {
"local/edge-connect" = "<home>/go/bin"
}
# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}
```
1. You can then test changes by running the following from the /examples/edgeconnect-config/ repo whenever you update the source code:
```bash
go install ../../ && terraform plan
```
- You will of course need credentials in order to execute `terraform plan`, as described below.
Note: Adjust the path based on your OS and architecture (e.g., `linux_amd64`, `darwin_amd64`, etc.)
## Usage
### Provider Configuration
The provider must be configured with credentials and a URL. This can be done with a token in your code:
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. `<home>` should refer to your `$HOME` directory.
```hcl
provider_installation {
dev_overrides {
"local/edge-connect" = "<home>/go/bin"
}
# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}
```
You can then reference the local provider in your `.tf` files as follows:
```hcl
provider "edge-connect" {
@ -85,7 +85,7 @@ provider "edge-connect" {
}
```
Or with basic authentication:
Or using basic authentication:
```hcl
provider "edge-connect" {
@ -95,7 +95,7 @@ provider "edge-connect" {
}
```
Or without code changes, via environment variables:
Configuration can also be provided via environment variables:
- `EDGE_CONNECT_BASE_URL`
- `EDGE_CONNECT_TOKEN`
- `EDGE_CONNECT_USERNAME`

View file

@ -1,51 +0,0 @@
#!/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)"

1
go.mod
View file

@ -3,7 +3,6 @@ module edp.buildth.ing/DevFW-CICD/terraform-provider-edge-connect
go 1.25.3
require (
edp.buildth.ing/DevFW-CICD/edge-connect-client v1.0.0
edp.buildth.ing/DevFW-CICD/edge-connect-client/v2 v2.1.2
github.com/hashicorp/terraform-plugin-framework v1.16.1
github.com/hashicorp/terraform-plugin-log v0.9.0

2
go.sum
View file

@ -1,5 +1,3 @@
edp.buildth.ing/DevFW-CICD/edge-connect-client v1.0.0 h1:WcQmJNHS/4dlGx3lpw3x0hZdPj+GKSdGsQrWRxpdhyI=
edp.buildth.ing/DevFW-CICD/edge-connect-client v1.0.0/go.mod h1:qZUPl2hFLNuhtkIojGfSq/MF7DQJGwvq6KbmtqPwZws=
edp.buildth.ing/DevFW-CICD/edge-connect-client/v2 v2.1.2 h1:g1iY/8Au4T6UV6cFm8/SQXAAF+DvFcjR6Hb0TqTF064=
edp.buildth.ing/DevFW-CICD/edge-connect-client/v2 v2.1.2/go.mod h1:nPZ4K4BB7eXyeSrcHXvSPkNZbs+XgmxbDJOM4KhbI1A=
github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw=

View file

@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect/v2"
)
var _ datasource.DataSource = &AppDataSource{}

View file

@ -15,7 +15,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect/v2"
)
var _ resource.Resource = &AppResource{}

View file

@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect/v2"
)
var _ datasource.DataSource = &AppInstanceDataSource{}
@ -144,10 +144,12 @@ func (d *AppInstanceDataSource) Read(ctx context.Context, req datasource.ReadReq
Name: data.CloudletName.ValueString(),
},
}
appKey := edgeclient.AppKey{
Name: data.AppId.ValueString(),
}
region := data.Region.ValueString()
appInstances, err := d.client.ShowAppInstances(ctx, appInstKey, region)
appInstances, err := d.client.ShowAppInstances(ctx, appInstKey, appKey, region)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read app instance %s/%s in region %s, got error: %s",
data.Organization.ValueString(), data.Name.ValueString(), region, err))

View file

@ -13,7 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect/v2"
)
var _ resource.Resource = &AppInstanceResource{}
@ -190,7 +190,7 @@ func (r *AppInstanceResource) Create(ctx context.Context, req resource.CreateReq
data.Id = types.StringValue(appInstInput.AppInst.Key.Name)
data.State = types.StringValue("created")
appInstance, err := r.client.ShowAppInstance(ctx, appInstInput.AppInst.Key, data.Region.ValueString())
appInstance, err := r.client.ShowAppInstance(ctx, appInstInput.AppInst.Key, appInstInput.AppInst.AppKey, data.Region.ValueString())
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read app instance %s, got error: %s", data.Id.ValueString(), err))
return
@ -221,8 +221,11 @@ func (r *AppInstanceResource) Read(ctx context.Context, req resource.ReadRequest
Name: data.CloudletName.ValueString(),
},
}
appKey := edgeclient.AppKey{
Name: data.AppName.ValueString(),
}
appInstance, err := r.client.ShowAppInstance(ctx, appInstKey, data.Region.ValueString())
appInstance, err := r.client.ShowAppInstance(ctx, appInstKey, appKey, data.Region.ValueString())
if err != nil {
if errors.Is(err, edgeclient.ErrResourceNotFound) {
@ -267,6 +270,9 @@ func (r *AppInstanceResource) Update(ctx context.Context, req resource.UpdateReq
Flavor: edgeclient.Flavor{Name: data.FlavorName.ValueString()},
},
}
appInput := edgeclient.AppKey{
Name: data.AppName.ValueString(),
}
err := r.client.UpdateAppInstance(ctx, updateInput)
if err != nil {
@ -274,7 +280,7 @@ func (r *AppInstanceResource) Update(ctx context.Context, req resource.UpdateReq
return
}
appInstance, err := r.client.ShowAppInstance(ctx, updateInput.AppInst.Key, data.Region.ValueString())
appInstance, err := r.client.ShowAppInstance(ctx, updateInput.AppInst.Key, appInput, data.Region.ValueString())
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read app instance %s, got error: %s", data.Id.ValueString(), err))
return

View file

@ -15,7 +15,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect/v2"
)
var _ provider.Provider = &EdgeConnectProvider{}