diff --git a/.github/workflows/e2e-test-provider-example.yml b/.github/workflows/e2e-test-provider-example.yml index ca9cc13b7b..3d02e17d0e 100644 --- a/.github/workflows/e2e-test-provider-example.yml +++ b/.github/workflows/e2e-test-provider-example.yml @@ -143,8 +143,8 @@ jobs: targetArch: 'amd64' outputPath: "build/terraform-provider-constellation" - - name: Move Terraform provider binary - if: inputs.providerVersion == '' || inputs.toProviderVersion == '' + - name: Add to local Terraform registry + if: inputs.providerVersion == '' # only move if needed, because otherwise the public TF registry will not be used shell: bash id: install_tf_provider run: | @@ -330,6 +330,28 @@ jobs: cat _override.tf # TODO rename version to image_version + - name: Remove or add to local Terraform registry + shell: bash + id: upgrade_tf_provider + run: | + bazel build //bazel/settings:tag + repository_root=$(git rev-parse --show-toplevel) + out_rel=$(bazel cquery --output=files //bazel/settings:tag) + build_version=$(cat "$(realpath "${repository_root}/${out_rel}")") + + terraform_provider_dir="${HOME}/.terraform.d/plugins/registry.terraform.io/edgelesssys/constellation/${build_version#v}/linux_amd64/" + + # remove local registry if it was used and public registry should be used now + if [[ "${{ inputs.providerVersion }}" == "" && "${{ inputs.toProviderVersion }}" != "" ]]; then + rm -rf "${terraform_provider_dir}" + fi + + # add to local registry if it was not used and local registry should be used now + if [[ "${{ inputs.providerVersion }}" != "" && "${{ inputs.toProviderVersion }}" == "" ]]; then + mkdir -p "${terraform_provider_dir}" + mv build/terraform-provider-constellation "${terraform_provider_dir}/terraform-provider-constellation_${build_version}" + fi + - name: Upgrade Terraform Cluster working-directory: ${{ github.workspace }}/cluster shell: bash diff --git a/dev-docs/workflows/terraform-provider.md b/dev-docs/workflows/terraform-provider.md index 7f255710f1..cec4b6c136 100644 --- a/dev-docs/workflows/terraform-provider.md +++ b/dev-docs/workflows/terraform-provider.md @@ -21,6 +21,14 @@ bazel run //:devbuild' > rm .terraform.lock.hcl > terraform init > ``` +> + + +> [!IMPORTANT] when wanting to use the public Terraform registry afterwards, you will need to remove the local registry: +> +> ```bash +> rm -rf ~/.terraform.d/plugins/registry.terraform.io/edgelesssys/constellation +> ``` Only build: