diff --git a/backports/OpenTofu/Base.latest.gitlab-ci.yml b/backports/OpenTofu/Base.latest.gitlab-ci.yml index 5600b234b1ded896f7d2ddd25adf8888e635043b..81f4d7a695767af8bb3e61446a92294053837481 100644 --- a/backports/OpenTofu/Base.latest.gitlab-ci.yml +++ b/backports/OpenTofu/Base.latest.gitlab-ci.yml @@ -64,9 +64,12 @@ opentofu:use-component-instead-of-template: #allow_failure: true allow_failure: true cache: - key: "$TF_ROOT" + key: "$__CACHE_KEY_HACK" paths: - $TF_ROOT/.terraform/ + variables: + # FIXME: work around to make slashes work in `cache:key`. see https://gitlab.com/gitlab-org/gitlab/-/issues/439898 + __CACHE_KEY_HACK: "$TF_ROOT" image: name: '$GITLAB_OPENTOFU_IMAGE_REGISTRY_BASE/gitlab-opentofu:$GITLAB_OPENTOFU_VERSION-opentofu$OPENTOFU_VERSION' script: @@ -80,9 +83,12 @@ opentofu:use-component-instead-of-template: when: never - if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead. cache: - key: "$TF_ROOT" + key: "$__CACHE_KEY_HACK" paths: - $TF_ROOT/.terraform/ + variables: + # FIXME: work around to make slashes work in `cache:key`. see https://gitlab.com/gitlab-org/gitlab/-/issues/439898 + __CACHE_KEY_HACK: "$TF_ROOT" image: name: '$GITLAB_OPENTOFU_IMAGE_REGISTRY_BASE/gitlab-opentofu:$GITLAB_OPENTOFU_VERSION-opentofu$OPENTOFU_VERSION' script: @@ -112,9 +118,12 @@ opentofu:use-component-instead-of-template: when: never - if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead. cache: - key: "$TF_ROOT" + key: "$__CACHE_KEY_HACK" paths: - $TF_ROOT/.terraform/ + variables: + # FIXME: work around to make slashes work in `cache:key`. see https://gitlab.com/gitlab-org/gitlab/-/issues/439898 + __CACHE_KEY_HACK: "$TF_ROOT" image: name: '$GITLAB_OPENTOFU_IMAGE_REGISTRY_BASE/gitlab-opentofu:$GITLAB_OPENTOFU_VERSION-opentofu$OPENTOFU_VERSION' script: @@ -132,9 +141,12 @@ opentofu:use-component-instead-of-template: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH when: manual cache: - key: "$TF_ROOT" + key: "$__CACHE_KEY_HACK" paths: - $TF_ROOT/.terraform/ + variables: + # FIXME: work around to make slashes work in `cache:key`. see https://gitlab.com/gitlab-org/gitlab/-/issues/439898 + __CACHE_KEY_HACK: "$TF_ROOT" image: name: '$GITLAB_OPENTOFU_IMAGE_REGISTRY_BASE/gitlab-opentofu:$GITLAB_OPENTOFU_VERSION-opentofu$OPENTOFU_VERSION' script: @@ -150,9 +162,12 @@ opentofu:use-component-instead-of-template: - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && "$_TF_AUTO_DESTROY" == "true"' - when: manual cache: - key: "$TF_ROOT" + key: "$__CACHE_KEY_HACK" paths: - $TF_ROOT/.terraform/ + variables: + # FIXME: work around to make slashes work in `cache:key`. see https://gitlab.com/gitlab-org/gitlab/-/issues/439898 + __CACHE_KEY_HACK: "$TF_ROOT" image: name: '$GITLAB_OPENTOFU_IMAGE_REGISTRY_BASE/gitlab-opentofu:$GITLAB_OPENTOFU_VERSION-opentofu$OPENTOFU_VERSION' script: diff --git a/templates/apply.yml b/templates/apply.yml index cc1a6d56942ef590d6a96b80ef5cb34290353475..8083b36eec49404d4929b31abedaec88c99b1db8 100644 --- a/templates/apply.yml +++ b/templates/apply.yml @@ -59,10 +59,12 @@ spec: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH when: manual cache: - key: "$[[ inputs.root_dir ]]" + key: "$__CACHE_KEY_HACK" paths: - $[[ inputs.root_dir ]]/.terraform/ variables: + # FIXME: work around to make slashes work in `cache:key`. see https://gitlab.com/gitlab-org/gitlab/-/issues/439898 + __CACHE_KEY_HACK: "$[[ inputs.root_dir ]]" TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] image: diff --git a/templates/destroy.yml b/templates/destroy.yml index 267a0d801f36c6395cfbd25b8f5c847619679d03..a15e8f97627275abaab4ec7ef864dd27b1efb863 100644 --- a/templates/destroy.yml +++ b/templates/destroy.yml @@ -58,10 +58,12 @@ spec: - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && "$[[ inputs.auto_destroy ]]" == "true"' - when: manual cache: - key: "$[[ inputs.root_dir ]]" + key: "$__CACHE_KEY_HACK" paths: - $[[ inputs.root_dir ]]/.terraform/ variables: + # FIXME: work around to make slashes work in `cache:key`. see https://gitlab.com/gitlab-org/gitlab/-/issues/439898 + __CACHE_KEY_HACK: "$[[ inputs.root_dir ]]" TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] image: diff --git a/templates/fmt.yml b/templates/fmt.yml index 730f1a836328fdbad19784facc68e21f856a6ea6..857fd3be84cbc1b813bfc551d45756d3252fb75a 100644 --- a/templates/fmt.yml +++ b/templates/fmt.yml @@ -59,10 +59,12 @@ spec: #allow_failure: $[[ inputs.allow_failure ]] allow_failure: true cache: - key: "$[[ inputs.root_dir ]]" + key: "$__CACHE_KEY_HACK" paths: - $[[ inputs.root_dir ]]/.terraform/ variables: + # FIXME: work around to make slashes work in `cache:key`. see https://gitlab.com/gitlab-org/gitlab/-/issues/439898 + __CACHE_KEY_HACK: "$[[ inputs.root_dir ]]" TF_ROOT: $[[ inputs.root_dir ]] image: name: '$[[ inputs.image_registry_base ]]/gitlab-opentofu:$[[ inputs.version ]]-opentofu$[[ inputs.opentofu_version ]]' diff --git a/templates/plan.yml b/templates/plan.yml index 6cc5b6c10ea75cd8b789c09dff154bc42e3ddd7e..58575777c35eb7be38cad2d39afb3b203ce59634 100644 --- a/templates/plan.yml +++ b/templates/plan.yml @@ -69,10 +69,12 @@ spec: when: never - if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead. cache: - key: "$[[ inputs.root_dir ]]" + key: "$__CACHE_KEY_HACK" paths: - $[[ inputs.root_dir ]]/.terraform/ variables: + # FIXME: work around to make slashes work in `cache:key`. see https://gitlab.com/gitlab-org/gitlab/-/issues/439898 + __CACHE_KEY_HACK: "$[[ inputs.root_dir ]]" TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] image: diff --git a/templates/validate.yml b/templates/validate.yml index 241ffecb07cf1f19a953d7c263f46cf0d4d96a83..e2b9d22fe44a3fd0667f8e31ab2c51a2be9e5f7a 100644 --- a/templates/validate.yml +++ b/templates/validate.yml @@ -53,10 +53,12 @@ spec: when: never - if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead. cache: - key: "$[[ inputs.root_dir ]]" + key: "$__CACHE_KEY_HACK" paths: - $[[ inputs.root_dir ]]/.terraform/ variables: + # FIXME: work around to make slashes work in `cache:key`. see https://gitlab.com/gitlab-org/gitlab/-/issues/439898 + __CACHE_KEY_HACK: "$[[ inputs.root_dir ]]" TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] image: