Skip to content

Commit

Permalink
delete local TF registry dir when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
elchead committed Dec 27, 2023
1 parent ff17953 commit dcd21ff
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/e2e-test-provider-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions dev-docs/workflows/terraform-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit dcd21ff

Please sign in to comment.