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
010eb4ec
Unverified
Commit
010eb4ec
authored
1 year ago
by
Timo Furrer
Browse files
Options
Downloads
Patches
Plain Diff
Implement validate-plan-destroy pipeline template
parent
f4c53550
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
templates/validate-plan-destroy.yml
+113
-0
113 additions, 0 deletions
templates/validate-plan-destroy.yml
tests/integration-tests/Destroy.gitlab-ci.yml
+15
-3
15 additions, 3 deletions
tests/integration-tests/Destroy.gitlab-ci.yml
with
128 additions
and
3 deletions
templates/validate-plan-destroy.yml
0 → 100644
+
113
−
0
View file @
010eb4ec
spec
:
inputs
:
# Stages
stage_validate
:
default
:
'
validate'
description
:
'
Defines
the
validate
stage.
This
stage
includes
the
`fmt`
and
`validate`
jobs.'
stage_build
:
default
:
'
build'
description
:
'
Defines
the
build
stage.
This
stage
includes
the
`plan`
job.'
stage_cleanup
:
default
:
'
cleanup'
description
:
'
Defines
the
cleanup
stage.
This
stage
includes
the
`destroy`
and
`delete-state`
jobs.'
# Versions
# This version is only required, because we cannot access the context of the component,
# see https://gitlab.com/gitlab-org/gitlab/-/issues/438275
version
:
default
:
'
latest'
description
:
'
Version
of
this
component.
Has
to
be
the
same
as
the
one
in
the
component
include
entry.'
opentofu_version
:
default
:
'
1.7.1'
options
:
-
'
$OPENTOFU_VERSION'
-
'
1.7.1'
-
'
1.7.0'
-
'
1.7.0-alpha1'
-
'
1.6.2'
-
'
1.6.1'
-
'
1.6.0'
description
:
'
OpenTofu
version
that
should
be
used.'
# Images
image_registry_base
:
default
:
'
$CI_REGISTRY/components/opentofu'
description
:
'
Host
URI
to
the
job
images.
Will
be
combined
with
`image_name`
to
construct
the
actual
image
URI.'
# FIXME: not yet possible because of https://gitlab.com/gitlab-org/gitlab/-/issues/438722
# gitlab_opentofu_image:
# # FIXME: This should reference the component tag that is used.
# # Currently, blocked by https://gitlab.com/gitlab-org/gitlab/-/issues/438275
# # default: '$CI_REGISTRY/components/opentofu/gitlab-opentofu:$[[ inputs.opentofu_version ]]'
# default: '$CI_REGISTRY/components/opentofu/gitlab-opentofu:$[[ inputs.version ]]-opentofu$[[ inputs.opentofu_version ]]'
# description: 'Tag of the gitlab-opentofu image.'
image_name
:
default
:
'
gitlab-opentofu'
description
:
'
Image
name
for
the
job
images.
Hosted
under
`image_registry_base`.'
# Configuration
root_dir
:
default
:
${CI_PROJECT_DIR}
description
:
'
Root
directory
for
the
OpenTofu
project.'
state_name
:
default
:
default
description
:
'
Remote
OpenTofu
state
name.'
auto_destroy
:
default
:
false
type
:
boolean
description
:
'
Whether
the
destroy
job
is
manual
or
automatically
run.'
---
include
:
-
local
:
'
/templates/fmt.yml'
inputs
:
as
:
'
fmt'
stage
:
$[[ inputs.stage_validate ]]
version
:
$[[ inputs.version ]]
opentofu_version
:
$[[ inputs.opentofu_version ]]
image_registry_base
:
$[[ inputs.image_registry_base ]]
image_name
:
$[[ inputs.image_name ]]
root_dir
:
$[[ inputs.root_dir ]]
-
local
:
'
/templates/validate.yml'
inputs
:
as
:
'
validate'
stage
:
$[[ inputs.stage_validate ]]
version
:
$[[ inputs.version ]]
opentofu_version
:
$[[ inputs.opentofu_version ]]
image_registry_base
:
$[[ inputs.image_registry_base ]]
image_name
:
$[[ inputs.image_name ]]
root_dir
:
$[[ inputs.root_dir ]]
state_name
:
$[[ inputs.state_name ]]
-
local
:
'
/templates/plan.yml'
inputs
:
as
:
'
plan'
stage
:
$[[ inputs.stage_build ]]
version
:
$[[ inputs.version ]]
opentofu_version
:
$[[ inputs.opentofu_version ]]
image_registry_base
:
$[[ inputs.image_registry_base ]]
image_name
:
$[[ inputs.image_name ]]
root_dir
:
$[[ inputs.root_dir ]]
state_name
:
$[[ inputs.state_name ]]
destroy
:
true
-
local
:
'
/templates/destroy.yml'
inputs
:
as
:
'
destroy'
stage
:
$[[ inputs.stage_cleanup ]]
version
:
$[[ inputs.version ]]
opentofu_version
:
$[[ inputs.opentofu_version ]]
image_registry_base
:
$[[ inputs.image_registry_base ]]
image_name
:
$[[ inputs.image_name ]]
root_dir
:
$[[ inputs.root_dir ]]
state_name
:
$[[ inputs.state_name ]]
auto_destroy
:
$[[ inputs.auto_destroy ]]
-
local
:
'
/templates/delete-state.yml'
inputs
:
as
:
'
delete-state'
stage
:
$[[ inputs.stage_cleanup ]]
state_name
:
$[[ inputs.state_name ]]
# NOTE: we have to define this `needs` here, because inputs don't support arrays, yet.
delete-state
:
needs
:
[
destroy
]
This diff is collapsed.
Click to expand it.
tests/integration-tests/Destroy.gitlab-ci.yml
+
15
−
3
View file @
010eb4ec
include
:
-
component
:
$CI_SERVER_FQDN/$CI_PROJECT_PATH/
plan
@$CI_COMMIT_SHA
-
component
:
$CI_SERVER_FQDN/$CI_PROJECT_PATH/
validate-plan-destroy
@$CI_COMMIT_SHA
inputs
:
image_registry_base
:
$GITLAB_OPENTOFU_IMAGE_BASE
version
:
$CI_COMMIT_SHA
opentofu_version
:
$OPENTOFU_VERSION
root_dir
:
$TEST_TF_ROOT
state_name
:
$TEST_TF_STATE_NAME
destroy
:
true
stages
:
[
build
]
stages
:
[
validate
,
build
,
cleanup
]
# Required to run everything immediately, instead of manually.
fmt
:
rules
:
[{
when
:
always
}]
validate
:
rules
:
[{
when
:
always
}]
plan
:
rules
:
[{
when
:
always
}]
destroy
:
rules
:
[{
when
:
always
}]
delete-state
:
rules
:
[{
when
:
always
}]
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