From ac0c36ec28077876cea1ee81a002dc699d173382 Mon Sep 17 00:00:00 2001 From: Timo Furrer <tfurrer@gitlab.com> Date: Fri, 19 Jan 2024 07:27:56 +0100 Subject: [PATCH] Rename image registry base variable --- Makefile | 7 ++++++- backports/.Base.gitlab-ci.yml | 2 +- backports/OpenTofu/Base.gitlab-ci.yml | 2 +- templates/full-pipeline.yml | 4 ++-- tests/integration-tests/Defaults.gitlab-ci.yml | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index cd347bb..44619cd 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +all: docs backports + +.PHONY: docs docs: csplit -sf readme -n 1 .gitlab/README.md '/<INPUTS>/' echo '<!-- This document is generated by `make docs` from `.gitlab/README.md` -->' > README.md @@ -23,6 +26,7 @@ BACKPORTS_BASE_FILE := $(BACKPORTS_BASE_DIR)/Base.gitlab-ci.yml # Install it with `brew install gnu-sed` and follow the instructions in `brew info gnu-sed` to # make it the standard `sed` binary (if you wish) or temporarily alias sed=gsed backports: + @echo "Generating $(BACKPORTS_BASE_FILE) ..." @mkdir -p $(BACKPORTS_BASE_DIR) @cp $(BACKPORTS_DIR)/.Base.gitlab-ci.yml $(BACKPORTS_BASE_FILE) @sed '1,/^---$$/d' templates/full-pipeline.yml >> $(BACKPORTS_BASE_FILE) @@ -30,7 +34,7 @@ backports: @sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.stage_build \]\]/build/' @sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.stage_deploy \]\]/deploy/' @sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.stage_cleanup \]\]/cleanup/' - @sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs._image_registry_base \]\]/$$GITLAB_OPENTOFU_IMAGE_REGISTRY_BASE/' + @sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.image_registry_base \]\]/$$GITLAB_OPENTOFU_IMAGE_REGISTRY_BASE/' @sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.version \]\]/$$GITLAB_OPENTOFU_VERSION/' @sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.opentofu_version \]\]/$$OPENTOFU_VERSION/' @sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.root_dir \]\]/$$TF_ROOT/' @@ -47,3 +51,4 @@ backports: @sed -i $(BACKPORTS_BASE_FILE) -e 's/destroy:/.opentofu:destroy:/' @sed -i $(BACKPORTS_BASE_FILE) -e '/needs: \[destroy\]/d' @sed -i $(BACKPORTS_BASE_FILE) -e 's/^delete-state:$$/.opentofu:delete-state:/' + @echo "Generated $(BACKPORTS_BASE_FILE)" diff --git a/backports/.Base.gitlab-ci.yml b/backports/.Base.gitlab-ci.yml index 9f3c6ec..738097d 100644 --- a/backports/.Base.gitlab-ci.yml +++ b/backports/.Base.gitlab-ci.yml @@ -18,7 +18,7 @@ variables: # Compatible OpenTofu version, see https://gitlab.com/components/opentofu/-/releases OPENTOFU_VERSION: "1.6.0" # Job Image with `gitlab-tofu` - GITLAB_OPENTOFU_IMAGE: registry.gitlab.com/components/opentofu/gitlab-opentofu:$VERSION-opentofu$OPENTOFU_VERSION + GITLAB_OPENTOFU_IMAGE_REGISTRY_BASE: $CI_REGISTRY/components/opentofu # The relative path to the root directory of the OpenTofu project TF_ROOT: ${CI_PROJECT_DIR} # The name of the state file used by the GitLab Managed Terraform state backend diff --git a/backports/OpenTofu/Base.gitlab-ci.yml b/backports/OpenTofu/Base.gitlab-ci.yml index fecf6ef..cf52a46 100644 --- a/backports/OpenTofu/Base.gitlab-ci.yml +++ b/backports/OpenTofu/Base.gitlab-ci.yml @@ -18,7 +18,7 @@ variables: # Compatible OpenTofu version, see https://gitlab.com/components/opentofu/-/releases OPENTOFU_VERSION: "1.6.0" # Job Image with `gitlab-tofu` - GITLAB_OPENTOFU_IMAGE: registry.gitlab.com/components/opentofu/gitlab-opentofu:$VERSION-opentofu$OPENTOFU_VERSION + GITLAB_OPENTOFU_IMAGE_REGISTRY_BASE: $CI_REGISTRY/components/opentofu # The relative path to the root directory of the OpenTofu project TF_ROOT: ${CI_PROJECT_DIR} # The name of the state file used by the GitLab Managed Terraform state backend diff --git a/templates/full-pipeline.yml b/templates/full-pipeline.yml index 8d616ad..ba00d1e 100644 --- a/templates/full-pipeline.yml +++ b/templates/full-pipeline.yml @@ -30,7 +30,7 @@ spec: description: 'OpenTofu version that should be used.' # Images - _image_registry_base: + image_registry_base: default: '$CI_REGISTRY/components/opentofu' # FIXME: not yet possible because of https://gitlab.com/gitlab-org/gitlab/-/issues/438722 # gitlab_opentofu_image: @@ -64,7 +64,7 @@ spec: .default: image: - name: '$[[ inputs._image_registry_base ]]/gitlab-opentofu:$[[ inputs.version ]]-opentofu$[[ inputs.opentofu_version ]]' + name: '$[[ inputs.image_registry_base ]]/gitlab-opentofu:$[[ inputs.version ]]-opentofu$[[ inputs.opentofu_version ]]' variables: TF_ROOT: $[[ inputs.root_dir ]] diff --git a/tests/integration-tests/Defaults.gitlab-ci.yml b/tests/integration-tests/Defaults.gitlab-ci.yml index f622545..4e856f3 100644 --- a/tests/integration-tests/Defaults.gitlab-ci.yml +++ b/tests/integration-tests/Defaults.gitlab-ci.yml @@ -1,7 +1,7 @@ include: - component: gitlab.com/$CI_PROJECT_PATH/full-pipeline@$CI_COMMIT_SHA inputs: - _image_registry_base: $GITLAB_OPENTOFU_IMAGE_BASE + image_registry_base: $GITLAB_OPENTOFU_IMAGE_BASE version: $CI_COMMIT_SHA opentofu_version: $OPENTOFU_VERSION root_dir: $TEST_TF_ROOT -- GitLab