From 8ddafb2cdc2baee8a84bd6ffa0f115b08fb0a820 Mon Sep 17 00:00:00 2001 From: Philipp Hahn <hahn@univention.de> Date: Tue, 23 Apr 2024 13:22:19 +0200 Subject: [PATCH] fix: get project values from CI variables $CI_REGISTRY <- registry.gitlab.com $CI_SERVER_FQDN <- gitlab.com $CI_PROJECT_PATH <- components/opentofu Closes: https://gitlab.com/components/opentofu/-/issues/36 --- .gitlab-ci.yml | 2 +- .gitlab/README.md.template | 24 +++++++++---------- .gitlab/release-notes.md.template | 2 +- README.md | 24 +++++++++---------- backports/.Base.latest.gitlab-ci.yml | 4 ++-- backports/OpenTofu/Base.latest.gitlab-ci.yml | 4 ++-- .../integration-tests/Defaults.gitlab-ci.yml | 2 +- .../JobTemplates.gitlab-ci.yml | 2 +- tests/integration-tests/TestJob.gitlab-ci.yml | 2 +- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 68134fb..a2b92a4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,7 @@ include: # Additionally, when this project is mirrored into another instance the component reference fails. # This may be solved with https://gitlab.com/gitlab-org/gitlab/-/issues/434260#note_1776822074 - # - component: gitlab.com/components/container-scanning/container-scanning@3.0 + # - component: $CI_SERVER_FQDN/components/container-scanning/container-scanning@3.0 # inputs: # stage: quality # cs_image: $GITLAB_OPENTOFU_IMAGE_NAME diff --git a/.gitlab/README.md.template b/.gitlab/README.md.template index 284eaf7..7ad5f58 100644 --- a/.gitlab/README.md.template +++ b/.gitlab/README.md.template @@ -29,7 +29,7 @@ You find all releases on the [Releases Overview Page](https://gitlab.com/compone ```yaml include: - - component: gitlab.com/components/opentofu/full-pipeline@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/full-pipeline@<VERSION> inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -43,7 +43,7 @@ stages: [validate, test, build, deploy, cleanup] # ... or without the destroy jobs: include: - - component: gitlab.com/components/opentofu/validate-plan-apply@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/validate-plan-apply@<VERSION> inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -59,7 +59,7 @@ A concrete example may look like this: ```yaml # Using version `0.10.0`: include: - - component: gitlab.com/components/opentofu/full-pipeline@0.10.0 + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/full-pipeline@0.10.0 inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -74,7 +74,7 @@ stages: [validate, test, build, deploy, cleanup] # ... in case you absolutely know what you are doing and are # aware that this may introduce breaking changes, you may use the latest release: include: - - component: gitlab.com/components/opentofu/full-pipeline@~latest + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/full-pipeline@~latest inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -89,7 +89,7 @@ Or import all jobs as hidden templates ready to be extended: ```yaml include: - - component: gitlab.com/components/opentofu/job-templates@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/job-templates@<VERSION> inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -122,7 +122,7 @@ and compose your own pipeline, for example, to just run the `fmt` job you can do ```yaml include: - - component: gitlab.com/components/opentofu/fmt@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/fmt@<VERSION> inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -139,7 +139,7 @@ you want to extend the jobs: ```yaml include: - - component: gitlab.com/components/opentofu/job-templates@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/job-templates@<VERSION> inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -195,7 +195,7 @@ the tools. For example to install `jq`: ```yaml include: - - component: gitlab.com/components/opentofu/validate-plan@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/validate-plan@<VERSION> inputs: version: <VERSION> opentofu_version: 1.6.1 @@ -227,10 +227,10 @@ and as the `version` input. Check out the [Usage](#Usage) section for examples. Each component release deploys the following images: -- `registry.gitlab.com/components/opentofu/gitlab-opentofu:<VERSION>-opentofu<OPENTOFU_VERSION>` -- `registry.gitlab.com/components/opentofu/gitlab-opentofu:<VERSION>-opentofu` +- `$CI_REGISTRY/$CI_PROJECT_PATH/gitlab-opentofu:<VERSION>-opentofu<OPENTOFU_VERSION>` +- `$CI_REGISTRY/$CI_PROJECT_PATH/gitlab-opentofu:<VERSION>-opentofu` - Includes the latest stable OpenTofu version at the time of releasing the component -- `registry.gitlab.com/components/opentofu/gitlab-opentofu:<VERSION>` +- `$CI_REGISTRY/$CI_PROJECT_PATH/gitlab-opentofu:<VERSION>` - Includes the latest stable OpenTofu version at the time of releasing the component In the above examples `<VERSION>` references the component version and `<OPENTOFU_VERSION>` @@ -255,7 +255,7 @@ and then use the component as you would from GitLab.com, but change the domain, ```yaml include: - - component: gitlab.example.com/components/opentofu/full-pipeline@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/full-pipeline@<VERSION> inputs: ... ``` diff --git a/.gitlab/release-notes.md.template b/.gitlab/release-notes.md.template index a24d368..eeac4ad 100644 --- a/.gitlab/release-notes.md.template +++ b/.gitlab/release-notes.md.template @@ -8,7 +8,7 @@ You can use the OpenTofu CI/CD component from the CI/CD catalog using: ```yaml include: - - component: gitlab.com/components/opentofu/full-pipeline@$CI_COMMIT_TAG + - component: $CI_COMMIT_TAG/$CI_PROJECT_PATH/full-pipeline@$CI_COMMIT_TAG inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed diff --git a/README.md b/README.md index b14016a..4dff8c7 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ You find all releases on the [Releases Overview Page](https://gitlab.com/compone ```yaml include: - - component: gitlab.com/components/opentofu/full-pipeline@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/full-pipeline@<VERSION> inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -45,7 +45,7 @@ stages: [validate, test, build, deploy, cleanup] # ... or without the destroy jobs: include: - - component: gitlab.com/components/opentofu/validate-plan-apply@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/validate-plan-apply@<VERSION> inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -61,7 +61,7 @@ A concrete example may look like this: ```yaml # Using version `0.10.0`: include: - - component: gitlab.com/components/opentofu/full-pipeline@0.10.0 + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/full-pipeline@0.10.0 inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -76,7 +76,7 @@ stages: [validate, test, build, deploy, cleanup] # ... in case you absolutely know what you are doing and are # aware that this may introduce breaking changes, you may use the latest release: include: - - component: gitlab.com/components/opentofu/full-pipeline@~latest + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/full-pipeline@~latest inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -91,7 +91,7 @@ Or import all jobs as hidden templates ready to be extended: ```yaml include: - - component: gitlab.com/components/opentofu/job-templates@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/job-templates@<VERSION> inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -124,7 +124,7 @@ and compose your own pipeline, for example, to just run the `fmt` job you can do ```yaml include: - - component: gitlab.com/components/opentofu/fmt@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/fmt@<VERSION> inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -141,7 +141,7 @@ you want to extend the jobs: ```yaml include: - - component: gitlab.com/components/opentofu/job-templates@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/job-templates@<VERSION> inputs: # The version must currently be specified explicitly as an input, # to find the correctly associated images. # This can be removed @@ -218,7 +218,7 @@ the tools. For example to install `jq`: ```yaml include: - - component: gitlab.com/components/opentofu/validate-plan@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/validate-plan@<VERSION> inputs: version: <VERSION> opentofu_version: 1.6.1 @@ -250,10 +250,10 @@ and as the `version` input. Check out the [Usage](#Usage) section for examples. Each component release deploys the following images: -- `registry.gitlab.com/components/opentofu/gitlab-opentofu:<VERSION>-opentofu<OPENTOFU_VERSION>` -- `registry.gitlab.com/components/opentofu/gitlab-opentofu:<VERSION>-opentofu` +- `$CI_REGISTRY/$CI_PROJECT_PATH/gitlab-opentofu:<VERSION>-opentofu<OPENTOFU_VERSION>` +- `$CI_REGISTRY/$CI_PROJECT_PATH/gitlab-opentofu:<VERSION>-opentofu` - Includes the latest stable OpenTofu version at the time of releasing the component -- `registry.gitlab.com/components/opentofu/gitlab-opentofu:<VERSION>` +- `$CI_REGISTRY/$CI_PROJECT_PATH/gitlab-opentofu:<VERSION>` - Includes the latest stable OpenTofu version at the time of releasing the component In the above examples `<VERSION>` references the component version and `<OPENTOFU_VERSION>` @@ -278,7 +278,7 @@ and then use the component as you would from GitLab.com, but change the domain, ```yaml include: - - component: gitlab.example.com/components/opentofu/full-pipeline@<VERSION> + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/full-pipeline@<VERSION> inputs: ... ``` diff --git a/backports/.Base.latest.gitlab-ci.yml b/backports/.Base.latest.gitlab-ci.yml index 2232cce..162f2f3 100644 --- a/backports/.Base.latest.gitlab-ci.yml +++ b/backports/.Base.latest.gitlab-ci.yml @@ -19,7 +19,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_BASE: $CI_REGISTRY/components/opentofu + GITLAB_OPENTOFU_IMAGE_REGISTRY_BASE: $CI_REGISTRY/$CI_PROJECT_PATH # 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 @@ -42,7 +42,7 @@ opentofu:use-component-instead-of-template: echo "To include the CI/CD component with a default configuration:" echo " " echo "include:" - echo " - component: gitlab.com/components/opentofu/full-pipeline@<VERSION>" + echo " - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/full-pipeline@<VERSION>" echo " inputs:" echo " version: <VERSION>" echo " opentofu_version: 1.6.0" diff --git a/backports/OpenTofu/Base.latest.gitlab-ci.yml b/backports/OpenTofu/Base.latest.gitlab-ci.yml index 16437e6..7c77480 100644 --- a/backports/OpenTofu/Base.latest.gitlab-ci.yml +++ b/backports/OpenTofu/Base.latest.gitlab-ci.yml @@ -19,7 +19,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_BASE: $CI_REGISTRY/components/opentofu + GITLAB_OPENTOFU_IMAGE_REGISTRY_BASE: $CI_REGISTRY/$CI_PROJECT_PATH # 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 @@ -42,7 +42,7 @@ opentofu:use-component-instead-of-template: echo "To include the CI/CD component with a default configuration:" echo " " echo "include:" - echo " - component: gitlab.com/components/opentofu/full-pipeline@<VERSION>" + echo " - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/full-pipeline@<VERSION>" echo " inputs:" echo " version: <VERSION>" echo " opentofu_version: 1.6.0" diff --git a/tests/integration-tests/Defaults.gitlab-ci.yml b/tests/integration-tests/Defaults.gitlab-ci.yml index ad65d6a..572ee7d 100644 --- a/tests/integration-tests/Defaults.gitlab-ci.yml +++ b/tests/integration-tests/Defaults.gitlab-ci.yml @@ -1,5 +1,5 @@ include: - - component: gitlab.com/$CI_PROJECT_PATH/full-pipeline@$CI_COMMIT_SHA + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/full-pipeline@$CI_COMMIT_SHA inputs: image_registry_base: $GITLAB_OPENTOFU_IMAGE_BASE version: $CI_COMMIT_SHA diff --git a/tests/integration-tests/JobTemplates.gitlab-ci.yml b/tests/integration-tests/JobTemplates.gitlab-ci.yml index 7d2b47b..b85fccd 100644 --- a/tests/integration-tests/JobTemplates.gitlab-ci.yml +++ b/tests/integration-tests/JobTemplates.gitlab-ci.yml @@ -1,5 +1,5 @@ include: - - component: gitlab.com/$CI_PROJECT_PATH/job-templates@$CI_COMMIT_SHA + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/job-templates@$CI_COMMIT_SHA inputs: image_registry_base: $GITLAB_OPENTOFU_IMAGE_BASE version: $CI_COMMIT_SHA diff --git a/tests/integration-tests/TestJob.gitlab-ci.yml b/tests/integration-tests/TestJob.gitlab-ci.yml index 05b8144..adf8da8 100644 --- a/tests/integration-tests/TestJob.gitlab-ci.yml +++ b/tests/integration-tests/TestJob.gitlab-ci.yml @@ -1,5 +1,5 @@ include: - - component: gitlab.com/$CI_PROJECT_PATH/test@$CI_COMMIT_SHA + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/test@$CI_COMMIT_SHA inputs: image_registry_base: $GITLAB_OPENTOFU_IMAGE_BASE version: $CI_COMMIT_SHA -- GitLab