CI/CD catalog template conditionals
Proposal
Now that &11674 (closed) has been released as beta, I think this is the next step to improve templates.
One basic feature of templates is having support for if
, or conditionals.
For example, if the template is for creating environment deployment jobs, a template could want to ask for the tier, and skip adding a stop job if the tier is production
. Pseudo-code example:
spec:
inputs:
name:
tier:
options:
- development
- staging
- production
---
deploy $[[ inputs.name ]]:
script: ./deploy
environment:
name: $[[ inputs.tier ]]/$[[ if inputs.tier == 'development' ]]mr-$CI_MERGE_REQUEST_IID$[[
elif inputs.tier == 'staging' ]]/$CI_COMMIT_REF_SLUG$[[
else ]]main$[[ endif ]]
url: http://$CI_ENVIRONMENT_SLUG.example.com
$[[ if inputs.tier != 'production' ]]
on_stop: destroy $[[ inputs.name ]]
auto_stop_in: 1 week
destroy $[[ inputs.name ]]:
script: ./destroy
environment:
action: stop
name: $[[ inputs.tier ]]$[[ if inputs.tier == 'development' ]]/mr-$CI_MERGE_REQUEST_IID$[[ endif ]]
$[[ endif ]]