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

Add opinionated template for validate, plan and apply

parent ee7d007d
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ include: ...@@ -35,7 +35,7 @@ include:
version: <VERSION> version: <VERSION>
opentofu_version: <OPENTOFU_VERSION> opentofu_version: <OPENTOFU_VERSION>
stages: [validate, test, build, deploy, cleanup] stages: [validate, build, deploy, cleanup]
``` ```
A concrete example may look like this: A concrete example may look like this:
...@@ -51,7 +51,7 @@ include: ...@@ -51,7 +51,7 @@ include:
version: latest version: latest
opentofu_version: 1.6.0 opentofu_version: 1.6.0
stages: [validate, test, build, deploy, cleanup] stages: [validate, build, deploy, cleanup]
--- ---
...@@ -65,10 +65,21 @@ include: ...@@ -65,10 +65,21 @@ include:
version: 0.0.0-alpha1 version: 0.0.0-alpha1
opentofu_version: 1.6.0 opentofu_version: 1.6.0
stages: [validate, test, build, deploy, cleanup] stages: [validate, build, deploy, cleanup]
``` ```
Instead of including the `full-pipeline`, it's also possible to include individual jobs ### Opinionated Templates
This component repository also provides some templates that may often be used,
for example one that only runs validation (`fmt` and `validate`), plan and an apply,
but no destructive actions.
- [`validate-plan-apply`](templates/validate-plan-apply.yml)
### Job Templates
Instead of including the `full-pipeline` or another opinionated tempalte,
it's also possible to include individual jobs
and compose your own pipeline, for example, to just run the `fmt` job you can do: and compose your own pipeline, for example, to just run the `fmt` job you can do:
```yaml ```yaml
......
...@@ -37,7 +37,7 @@ include: ...@@ -37,7 +37,7 @@ include:
version: <VERSION> version: <VERSION>
opentofu_version: <OPENTOFU_VERSION> opentofu_version: <OPENTOFU_VERSION>
stages: [validate, test, build, deploy, cleanup] stages: [validate, build, deploy, cleanup]
``` ```
A concrete example may look like this: A concrete example may look like this:
...@@ -53,7 +53,7 @@ include: ...@@ -53,7 +53,7 @@ include:
version: latest version: latest
opentofu_version: 1.6.0 opentofu_version: 1.6.0
stages: [validate, test, build, deploy, cleanup] stages: [validate, build, deploy, cleanup]
--- ---
...@@ -67,10 +67,21 @@ include: ...@@ -67,10 +67,21 @@ include:
version: 0.0.0-alpha1 version: 0.0.0-alpha1
opentofu_version: 1.6.0 opentofu_version: 1.6.0
stages: [validate, test, build, deploy, cleanup] stages: [validate, build, deploy, cleanup]
``` ```
Instead of including the `full-pipeline`, it's also possible to include individual jobs ### Opinionated Templates
This component repository also provides some templates that may often be used,
for example one that only runs validation (`fmt` and `validate`), plan and an apply,
but no destructive actions.
- [`validate-plan-apply`](templates/validate-plan-apply.yml)
### Job Templates
Instead of including the `full-pipeline` or another opinionated tempalte,
it's also possible to include individual jobs
and compose your own pipeline, for example, to just run the `fmt` job you can do: and compose your own pipeline, for example, to just run the `fmt` job you can do:
```yaml ```yaml
......
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_deploy:
default: 'deploy'
description: 'Defines the deploy stage. This stage includes the `apply` job.'
# 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.6.0'
options:
- '$OPENTOFU_VERSION'
- '1.6.0'
- '1.6.0-rc1'
description: 'OpenTofu version that should be used.'
# Images
image_registry_base:
default: '$CI_REGISTRY/components/opentofu'
# 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.'
# Configuration
root_dir:
default: ${CI_PROJECT_DIR}
description: 'Root directory for the OpenTofu project.'
state_name:
default: default
description: 'Remote OpenTofu state name.'
auto_apply:
default: 'false'
description: 'Whether the apply 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 ]]
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 ]]
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 ]]
root_dir: $[[ inputs.root_dir ]]
state_name: $[[ inputs.state_name ]]
- local: '/templates/apply.yml'
inputs:
as: 'apply'
stage: $[[ inputs.stage_deploy ]]
version: $[[ inputs.version ]]
opentofu_version: $[[ inputs.opentofu_version ]]
image_registry_base: $[[ inputs.image_registry_base ]]
root_dir: $[[ inputs.root_dir ]]
state_name: $[[ inputs.state_name ]]
auto_apply: $[[ inputs.auto_apply ]]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment