From ac1f3220445999d750d389e05255658bfc2dafb5 Mon Sep 17 00:00:00 2001 From: Adrian Stobbe Date: Fri, 22 Dec 2023 08:38:28 +0100 Subject: [PATCH] terraform-provider: only build as enterprise user (#2770) Co-authored-by: Malte Poll <1780588+malt3@users.noreply.github.com> --- bazel/devbuild/BUILD.bazel | 27 ++++++++++++++----- .../prepare_developer_workspace.sh.in | 17 ++++++++---- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/bazel/devbuild/BUILD.bazel b/bazel/devbuild/BUILD.bazel index 27afb1347..12ac22edf 100644 --- a/bazel/devbuild/BUILD.bazel +++ b/bazel/devbuild/BUILD.bazel @@ -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"], ) diff --git a/bazel/devbuild/prepare_developer_workspace.sh.in b/bazel/devbuild/prepare_developer_workspace.sh.in index 152a52230..0f9fe5d15 100755 --- a/bazel/devbuild/prepare_developer_workspace.sh.in +++ b/bazel/devbuild/prepare_developer_workspace.sh.in @@ -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"