terraform-provider: only build as enterprise user (#2770)

Co-authored-by: Malte Poll <1780588+malt3@users.noreply.github.com>
This commit is contained in:
Adrian Stobbe 2023-12-22 08:38:28 +01:00 committed by GitHub
parent 837b24bf54
commit ac1f322044
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 11 deletions

View File

@ -10,12 +10,18 @@ sh_template(
"//bootstrapper/cmd/bootstrapper:bootstrapper_patched",
"//cli:cli_edition_host",
"//debugd/cmd/cdbg:cdbg_host",
"//terraform-provider-constellation:terraform_rc",
"//terraform-provider-constellation:tf_provider",
"//upgrade-agent/cmd:upgrade_agent_linux_amd64",
"@gnused//:bin/sed",
"@yq_toolchains//:resolved_toolchain",
],
] + select(
{
"//bazel/settings:cli_edition_enterprise": [
"//terraform-provider-constellation:terraform_rc",
"//terraform-provider-constellation:tf_provider",
],
"//conditions:default": [],
},
),
substitutions = {
"@@BOOTSTRAPPER@@": "$(rootpath //bootstrapper/cmd/bootstrapper:bootstrapper_patched)",
"@@CDBG@@": "$(rootpath //debugd/cmd/cdbg:cdbg_host)",
@ -23,8 +29,6 @@ sh_template(
"@@CONTAINER_SUMS@@": "$(rootpath //bazel/release:container_sums)",
"@@EDITION@@": "$(rootpath :devbuild_cli_edition)",
"@@SED@@": "$(rootpath @gnused//:bin/sed)",
"@@TERRAFORM_PROVIDER@@": "$(rootpath //terraform-provider-constellation:tf_provider)",
"@@TERRAFORM_RC@@": "$(rootpath //terraform-provider-constellation:terraform_rc)",
"@@UPGRADE_AGENT@@": "$(rootpath //upgrade-agent/cmd:upgrade_agent_linux_amd64)",
"@@VERSION_FILE@@": "$(rootpath //bazel/settings:tag)",
"@@YQ@@": "$(rootpath @yq_toolchains//:resolved_toolchain)",
@ -42,7 +46,18 @@ sh_template(
"@platforms//cpu:x86_64": {
"@@GOARCH@@": "amd64",
},
}),
}) | select(
{
"//bazel/settings:cli_edition_enterprise": {
"@@TERRAFORM_PROVIDER@@": "$(rootpath //terraform-provider-constellation:tf_provider)",
"@@TERRAFORM_RC@@": "$(rootpath //terraform-provider-constellation:terraform_rc)",
},
"//conditions:default": {
"@@TERRAFORM_PROVIDER@@": "",
"@@TERRAFORM_RC@@": "",
},
},
),
template = "prepare_developer_workspace.sh.in",
visibility = ["//visibility:public"],
)

View File

@ -38,8 +38,13 @@ stat "${cdbg}" >> /dev/null
container_sums=$(realpath @@CONTAINER_SUMS@@)
stat "${container_sums}" >> /dev/null
edition=$(cat @@EDITION@@)
terraform_provider=$(realpath @@TERRAFORM_PROVIDER@@)
stat "${terraform_provider}" >> /dev/null
raw_provider="@@TERRAFORM_PROVIDER@@"
if [[ -n ${raw_provider} ]]; then
terraform_provider=$(realpath "${raw_provider}")
stat "${terraform_provider}" >> /dev/null
else
terraform_provider=""
fi
build_version=$(cat @@VERSION_FILE@@)
if [[ -z ${build_version} ]]; then
echo "Error: version file is empty"
@ -80,9 +85,11 @@ ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${cdbg}")" "${workd
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${container_sums}")" "${workdir}/container_sums.sha256"
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${cli}")" "${workdir}/constellation"
terraform_provider_dir=${HOME}/.terraform.d/plugins/registry.terraform.io/edgelesssys/constellation/${build_version#v}/${goos}_${goarch}/
mkdir -p "${terraform_provider_dir}"
ln -sf "${terraform_provider}" "${terraform_provider_dir}/terraform-provider-constellation_${build_version}"
if [[ -n ${terraform_provider} ]]; then
terraform_provider_dir=${HOME}/.terraform.d/plugins/registry.terraform.io/edgelesssys/constellation/${build_version#v}/${goos}_${goarch}/
mkdir -p "${terraform_provider_dir}"
ln -sf "${terraform_provider}" "${terraform_provider_dir}/terraform-provider-constellation_${build_version}"
fi
if [[ ! -f "${workdir}/constellation-conf.yaml" ]]; then
echo "constellation-conf.yaml not present in workspace"