Skip to content
Snippets Groups Projects
Commit 7cffa28c authored by Timo Furrer's avatar Timo Furrer
Browse files

Merge branch 'refactor-warning-empty-plan' into 'main'

Rename `warning_on_none_empty_plan` to `warning_on_non_empty_plan`

See merge request components/opentofu!173
parents 65192abc 6ac698fd
No related branches found
No related tags found
No related merge requests found
...@@ -149,7 +149,7 @@ spec: ...@@ -149,7 +149,7 @@ spec:
- when: manual - when: manual
type: array type: array
description: 'Defines the `rules` of the `delete-state` job.' description: 'Defines the `rules` of the `delete-state` job.'
warning_on_none_empty_plan: warning_on_non_empty_plan:
default: false default: false
type: boolean type: boolean
description: 'Whether to mark the job with a warning if the plan contains a diff.' description: 'Whether to mark the job with a warning if the plan contains a diff.'
...@@ -218,7 +218,7 @@ include: ...@@ -218,7 +218,7 @@ include:
artifacts_access: $[[ inputs.plan_artifacts_access ]] artifacts_access: $[[ inputs.plan_artifacts_access ]]
var_file: $[[ inputs.var_file ]] var_file: $[[ inputs.var_file ]]
rules: $[[ inputs.plan_rules ]] rules: $[[ inputs.plan_rules ]]
warning_on_none_empty_plan: $[[ inputs.warning_on_none_empty_plan ]] warning_on_non_empty_plan: $[[ inputs.warning_on_non_empty_plan ]]
- local: '/templates/apply.yml' - local: '/templates/apply.yml'
inputs: inputs:
as: '$[[ inputs.job_name_prefix ]]apply' as: '$[[ inputs.job_name_prefix ]]apply'
......
...@@ -95,7 +95,7 @@ spec: ...@@ -95,7 +95,7 @@ spec:
default: '' default: ''
type: string type: string
description: 'Path to a variables files relative to root_dir.' description: 'Path to a variables files relative to root_dir.'
warning_on_none_empty_plan: warning_on_non_empty_plan:
default: false default: false
type: boolean type: boolean
description: 'Whether to mark the job with a warning if the plan contains a diff.' description: 'Whether to mark the job with a warning if the plan contains a diff.'
...@@ -165,7 +165,7 @@ include: ...@@ -165,7 +165,7 @@ include:
state_name: $[[ inputs.state_name ]] state_name: $[[ inputs.state_name ]]
plan_name: $[[ inputs.plan_name ]] plan_name: $[[ inputs.plan_name ]]
var_file: $[[ inputs.var_file ]] var_file: $[[ inputs.var_file ]]
warning_on_none_empty_plan: $[[ inputs.warning_on_none_empty_plan ]] warning_on_non_empty_plan: $[[ inputs.warning_on_non_empty_plan ]]
- local: '/templates/apply.yml' - local: '/templates/apply.yml'
inputs: inputs:
as: '$[[ inputs.job_name_prefix ]]apply' as: '$[[ inputs.job_name_prefix ]]apply'
......
...@@ -93,7 +93,7 @@ spec: ...@@ -93,7 +93,7 @@ spec:
default: pull-push default: pull-push
type: string type: string
description: 'Defines the cache policy of the job.' description: 'Defines the cache policy of the job.'
warning_on_none_empty_plan: warning_on_non_empty_plan:
default: false default: false
type: boolean type: boolean
description: 'Whether to mark the job with a warning if the plan contains a diff.' description: 'Whether to mark the job with a warning if the plan contains a diff.'
...@@ -101,7 +101,7 @@ spec: ...@@ -101,7 +101,7 @@ spec:
--- ---
# NOTE: the two following jobs are necessary to implement the abstraction logic # NOTE: the two following jobs are necessary to implement the abstraction logic
# required for the `warning_on_none_empty_plan` input. # required for the `warning_on_non_empty_plan` input.
# Without any kind of flow control support for the GitLab CI YAML we cannot infer # Without any kind of flow control support for the GitLab CI YAML we cannot infer
# another value from the input. However, we can clearly apply "inheritance" to # another value from the input. However, we can clearly apply "inheritance" to
# customize behavior related to the CI keywords that have otherwise nothing # customize behavior related to the CI keywords that have otherwise nothing
...@@ -110,14 +110,22 @@ spec: ...@@ -110,14 +110,22 @@ spec:
extends: null extends: null
'.$[[ inputs.as ]]:detailed_exitcode:warning:true': '.$[[ inputs.as ]]:detailed_exitcode:warning:true':
variables:
OPENTOFU_COMPONENT_USE_DETAILED_EXITCODE: '$[[ inputs.warning_on_non_empty_plan ]]'
# NOTE: we rely on correct exitcode reporting behavior for the `warning_on_non_empty_plan` input
# behavior. However, when using bash the runner does not work properly without setting
# the feature flag below to `true`.
FF_USE_NEW_BASH_EVAL_STRATEGY: 'true'
allow_failure: allow_failure:
# NOTE: tofu plan -detailed-exitcode return 2 as exit code
# when the plan is non-empty.
exit_codes: [2] exit_codes: [2]
'$[[ inputs.as ]]': '$[[ inputs.as ]]':
stage: $[[ inputs.stage ]] stage: $[[ inputs.stage ]]
extends: extends:
# NOTE: see the comment above. This is to support the `warning_on_none_empty_plan` input. # NOTE: see the comment above. This is to support the `warning_on_non_empty_plan` input.
- '.$[[ inputs.as ]]:detailed_exitcode:warning:$[[ inputs.warning_on_none_empty_plan ]]' - '.$[[ inputs.as ]]:detailed_exitcode:warning:$[[ inputs.warning_on_non_empty_plan ]]'
environment: environment:
name: $[[ inputs.state_name ]] name: $[[ inputs.state_name ]]
action: prepare action: prepare
...@@ -145,11 +153,6 @@ spec: ...@@ -145,11 +153,6 @@ spec:
TF_STATE_NAME: $[[ inputs.state_name ]] TF_STATE_NAME: $[[ inputs.state_name ]]
TF_PLAN_NAME: $[[ inputs.plan_name ]] TF_PLAN_NAME: $[[ inputs.plan_name ]]
OPENTOFU_COMPONENT_VAR_FILE: '$[[ inputs.var_file ]]' OPENTOFU_COMPONENT_VAR_FILE: '$[[ inputs.var_file ]]'
OPENTOFU_COMPONENT_USE_DETAILED_EXITCODE: '$[[ inputs.warning_on_none_empty_plan ]]'
# NOTE: we rely on correct exitcode reporting behavior for the `warning_on_none_empty_plan` input
# behavior. However, when using bash the runner does not work properly without setting
# the feature flag below to `true`.
FF_USE_NEW_BASH_EVAL_STRATEGY: 'true'
image: image:
name: '$[[ inputs.image_registry_base ]]/$[[ inputs.image_name ]]:$[[ inputs.version ]]-opentofu$[[ inputs.opentofu_version ]]-$[[ inputs.base_os ]]$[[ inputs.image_digest ]]' name: '$[[ inputs.image_registry_base ]]/$[[ inputs.image_name ]]:$[[ inputs.version ]]-opentofu$[[ inputs.opentofu_version ]]-$[[ inputs.base_os ]]$[[ inputs.image_digest ]]'
script: script:
......
...@@ -119,7 +119,7 @@ spec: ...@@ -119,7 +119,7 @@ spec:
when: manual when: manual
type: array type: array
description: 'Defines the `rules` of the `apply` job.' description: 'Defines the `rules` of the `apply` job.'
warning_on_none_empty_plan: warning_on_non_empty_plan:
default: false default: false
type: boolean type: boolean
description: 'Whether to mark the job with a warning if the plan contains a diff.' description: 'Whether to mark the job with a warning if the plan contains a diff.'
...@@ -172,7 +172,7 @@ include: ...@@ -172,7 +172,7 @@ include:
var_file: $[[ inputs.var_file ]] var_file: $[[ inputs.var_file ]]
rules: $[[ inputs.plan_rules ]] rules: $[[ inputs.plan_rules ]]
cache_policy: pull cache_policy: pull
warning_on_none_empty_plan: $[[ inputs.warning_on_none_empty_plan ]] warning_on_non_empty_plan: $[[ inputs.warning_on_non_empty_plan ]]
- local: '/templates/apply.yml' - local: '/templates/apply.yml'
inputs: inputs:
as: '$[[ inputs.job_name_prefix ]]apply' as: '$[[ inputs.job_name_prefix ]]apply'
......
...@@ -124,7 +124,7 @@ spec: ...@@ -124,7 +124,7 @@ spec:
- when: manual - when: manual
type: array type: array
description: 'Defines the `rules` of the `delete-state` job.' description: 'Defines the `rules` of the `delete-state` job.'
warning_on_none_empty_plan: warning_on_non_empty_plan:
default: false default: false
type: boolean type: boolean
description: 'Whether to mark the job with a warning if the plan contains a diff.' description: 'Whether to mark the job with a warning if the plan contains a diff.'
...@@ -178,7 +178,7 @@ include: ...@@ -178,7 +178,7 @@ include:
var_file: $[[ inputs.var_file ]] var_file: $[[ inputs.var_file ]]
rules: $[[ inputs.plan_rules ]] rules: $[[ inputs.plan_rules ]]
cache_policy: pull cache_policy: pull
warning_on_none_empty_plan: $[[ inputs.warning_on_none_empty_plan ]] warning_on_non_empty_plan: $[[ inputs.warning_on_non_empty_plan ]]
- local: '/templates/destroy.yml' - local: '/templates/destroy.yml'
inputs: inputs:
as: '$[[ inputs.job_name_prefix ]]destroy' as: '$[[ inputs.job_name_prefix ]]destroy'
......
...@@ -105,7 +105,7 @@ spec: ...@@ -105,7 +105,7 @@ spec:
- if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead. - if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead.
type: array type: array
description: 'Defines the `rules` of the `plan` job.' description: 'Defines the `rules` of the `plan` job.'
warning_on_none_empty_plan: warning_on_non_empty_plan:
default: false default: false
type: boolean type: boolean
description: 'Whether to mark the job with a warning if the plan contains a diff.' description: 'Whether to mark the job with a warning if the plan contains a diff.'
...@@ -158,4 +158,4 @@ include: ...@@ -158,4 +158,4 @@ include:
var_file: $[[ inputs.var_file ]] var_file: $[[ inputs.var_file ]]
rules: $[[ inputs.plan_rules ]] rules: $[[ inputs.plan_rules ]]
cache_policy: pull cache_policy: pull
warning_on_none_empty_plan: $[[ inputs.warning_on_none_empty_plan ]] warning_on_non_empty_plan: $[[ inputs.warning_on_non_empty_plan ]]
...@@ -7,7 +7,7 @@ include: ...@@ -7,7 +7,7 @@ include:
opentofu_version: $OPENTOFU_VERSION opentofu_version: $OPENTOFU_VERSION
root_dir: $TEST_TF_ROOT root_dir: $TEST_TF_ROOT
state_name: $TEST_TF_STATE_NAME state_name: $TEST_TF_STATE_NAME
warning_on_none_empty_plan: true warning_on_non_empty_plan: true
# For CI Terraform state cleanup # For CI Terraform state cleanup
- component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/delete-state@$CI_COMMIT_SHA - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/delete-state@$CI_COMMIT_SHA
......
...@@ -16,7 +16,7 @@ component: ...@@ -16,7 +16,7 @@ component:
- ModuleRelease - ModuleRelease
- Destroy - Destroy
- VarFile - VarFile
- WarningOnNoneEmptyPlan - WarningOnNonEmptyPlan
GITLAB_OPENTOFU_BASE_IMAGE_OS: GITLAB_OPENTOFU_BASE_IMAGE_OS:
- alpine - alpine
- debian - debian
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment