Feature - Pipeline template `((variables))` interpolation
dbednall opened this issue · 1 comments
dbednall commented
Thank you for developing and publishing this provider.
requested feature context
Pipeline template variable syntax: https://concourse-ci.org/vars.html#var-syntax
Processes of performing interpolation of variables is handled within fly
https://github.com/concourse/concourse/blob/4189a7ed0b920f1de9d7c468caf40047126383b9/fly/commands/set_pipeline.go#L104
and therefore is missing from this provider, meaning to many/most users the provider cannot act as a drop-in replacement for fly in the trivial usecase and is only suitable where either
- the pipeline config contains no "Static Vars" (https://concourse-ci.org/vars.html#static-vars)
- some other 3rd party performs pipeline template generation
❯ fly sp -h
Usage:
✂️
[set-pipeline command options]
✂️
-v, --var=[NAME=STRING] Specify a string value to set for a variable in the pipeline
-l, --load-vars-from= Variable flag that can be used for filling in template values in configuration from a YAML file
✂️
high-level suggested implementation
Resources affected
concourse_pipeline
- addition of attributevars
toconcourse_pipeline
resource.- could be
map(string)
using TF config directly (ex 1) or accept YAML/JSON encoded input similar topipeline_config
attr (ex 2)
- could be
resource "concourse_pipeline" "my_pipeline" {
team_name = "main"
pipeline_name = "my-pipeline"
is_exposed = true
is_paused = true
pipeline_config = file("pipeline-config.yml")
pipeline_config_format = "yaml"
vars = { # 👋
"what_day_is_it" = "tuesday",
}
}
or 2.
resource "concourse_pipeline" "my_pipeline" {
team_name = "main"
pipeline_name = "my-pipeline"
is_exposed = true
is_paused = true
pipeline_config = file("pipeline-config.yml")
pipeline_config_format = "yaml"
vars = file("pipeline-vars.yml") # 👋
}
- could consider importing
templatehelpers
mod or related fromfly
project to get templating logic for free
MartinSchmidt123 commented
Especially, support for instance vars would be great. However, they are only experimental for now.
Currently, I am doing something like
locals {
docker_images = {
debian-11 = {
image = "debian"
version = "11"
}
alpine-3-14 = {
image = "alpine"
version = "3.14"
}
}
}
resource "concourse_pipeline" "template_docker" {
for_each = local.docker_images
team_name = data.vault_generic_secret.concourse.data["team"]
pipeline_name = "docker-${each.key}"
is_exposed = false
is_paused = false
pipeline_config = templatefile(format("%s/%s",path.module,"docker-build.yml"),{
image = each.value.image
version = each.value.version
})
pipeline_config_format = "yaml"
}
It works quite well but you have to use
((variable))
for concourse variables, and${variable}
or"${variable}"
for terrraform variables