diff --git a/Makefile b/Makefile index cd347bb0be4afdf3cab98374f8ab97c8ca2beadd..44619cdaf25ad9abb3edcf3d03800050cd4d369b 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 9f3c6ec75a6db5e3bfe964d30b9498c513be6590..738097d3186c03a034e574d844e9d72f9270c446 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 fecf6ef80dfdfa4bf4ce12f0f4d86d332265020a..cf52a46aa778b727ec1311d1dd1716bfb9e45cfe 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 8d616ad75c7347b375921c4585fb96a44a91cf1d..ba00d1e82c28806285e6a6e29c1c750d6f956dbe 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 f6225458605365f2d1d83d217f2bbf4d6a297028..4e856f3a4093ed6ce4f91a7aa24b8f32b882cd0c 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