Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OpenTofu
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
components
OpenTofu
Commits
a0c46918
Unverified
Commit
a0c46918
authored
8 months ago
by
Timo Furrer
Browse files
Options
Downloads
Patches
Plain Diff
Support `<job>_rules` inputs in `validate-plan-destroy` pipeline template
Changelog: added
parent
44cb7c5e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
templates/validate-plan-destroy.yml
+45
-22
45 additions, 22 deletions
templates/validate-plan-destroy.yml
with
45 additions
and
22 deletions
templates/validate-plan-destroy.yml
+
45
−
22
View file @
a0c46918
...
...
@@ -93,6 +93,42 @@ spec:
default
:
'
'
type
:
string
description
:
'
Path
to
a
variables
files
relative
to
root_dir.'
fmt_rules
:
default
:
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_OPEN_MERGE_REQUESTS
# Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
when
:
never
-
if
:
$CI_COMMIT_BRANCH
# If there's no open merge request, add it to a *branch* pipeline instead.
type
:
array
description
:
'
Defines
the
`rules`
of
the
`fmt`
job.'
validate_rules
:
default
:
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_OPEN_MERGE_REQUESTS
# Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
when
:
never
-
if
:
$CI_COMMIT_BRANCH
# If there's no open merge request, add it to a *branch* pipeline instead.
type
:
array
description
:
'
Defines
the
`rules`
of
the
`validate`
job.'
plan_rules
:
default
:
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_OPEN_MERGE_REQUESTS
# Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
when
:
never
-
if
:
$CI_COMMIT_BRANCH
# If there's no open merge request, add it to a *branch* pipeline instead.
type
:
array
description
:
'
Defines
the
`rules`
of
the
`plan`
job.'
destroy_rules
:
default
:
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
&&
"$[[
inputs.auto_destroy
]]"
==
"true"'
-
when
:
manual
type
:
array
description
:
'
Defines
the
`rules`
of
the
`destroy`
job.'
delete_state_rules
:
default
:
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH'
-
when
:
manual
type
:
array
description
:
'
Defines
the
`rules`
of
the
`delete-state`
job.'
---
...
...
@@ -109,11 +145,7 @@ include:
image_digest
:
$[[ inputs.image_digest ]]
root_dir
:
$[[ inputs.root_dir ]]
needs
:
[]
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_OPEN_MERGE_REQUESTS
# Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
when
:
never
-
if
:
$CI_COMMIT_BRANCH
# If there's no open merge request, add it to a *branch* pipeline instead.
rules
:
$[[ inputs.fmt_rules ]]
-
local
:
'
/templates/validate.yml'
inputs
:
as
:
'
$[[
inputs.job_name_prefix
]]validate'
...
...
@@ -127,11 +159,7 @@ include:
root_dir
:
$[[ inputs.root_dir ]]
state_name
:
$[[ inputs.state_name ]]
var_file
:
$[[ inputs.var_file ]]
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_OPEN_MERGE_REQUESTS
# Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
when
:
never
-
if
:
$CI_COMMIT_BRANCH
# If there's no open merge request, add it to a *branch* pipeline instead.
rules
:
$[[ inputs.validate_rules ]]
-
local
:
'
/templates/plan.yml'
inputs
:
as
:
'
$[[
inputs.job_name_prefix
]]plan'
...
...
@@ -148,11 +176,7 @@ include:
artifacts_access
:
$[[ inputs.plan_artifacts_access ]]
destroy
:
true
var_file
:
$[[ inputs.var_file ]]
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_OPEN_MERGE_REQUESTS
# Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
when
:
never
-
if
:
$CI_COMMIT_BRANCH
# If there's no open merge request, add it to a *branch* pipeline instead.
rules
:
$[[ inputs.plan_rules ]]
-
local
:
'
/templates/destroy.yml'
inputs
:
as
:
'
$[[
inputs.job_name_prefix
]]destroy'
...
...
@@ -169,18 +193,17 @@ include:
plan_name
:
$[[ inputs.plan_name ]]
auto_destroy
:
$[[ inputs.auto_destroy ]]
var_file
:
$[[ inputs.var_file ]]
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
&&
"$[[
inputs.auto_destroy
]]"
==
"true"'
-
when
:
manual
rules
:
$[[ inputs.destroy_rules ]]
-
local
:
'
/templates/delete-state.yml'
inputs
:
as
:
'
$[[
inputs.job_name_prefix
]]delete-state'
stage
:
$[[ inputs.stage_cleanup ]]
state_name
:
$[[ inputs.state_name ]]
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH'
-
when
:
manual
rules
:
$[[ inputs.delete_state_rules ]]
# NOTE: we have to define this `needs` here, because inputs don't support arrays, yet.
# FIXME: eventually, we'll have a `needs` input on the `delete-state`
# job template, but the issue is that we cannot default it to something
# meaningful other than `null` - but `null` is also not yet supported, see
# https://gitlab.com/gitlab-org/gitlab/-/issues/440468
$[[ inputs.job_name_prefix ]]delete-state
:
needs
:
[
'
$[[
inputs.job_name_prefix
]]destroy'
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment