Repository navigation
Description
tl;dr: deprecate {{these}} in favor of ((these)), and make them understand YAML.
Fixes #118, #299, #360, concourse/s3-resource#41, vmware-archive/fly#53, vmware-archive/fly#83, and sets the stage for #291.
Today's {{params}} are very barebones. They were added with safety and conservatism in mind, as they were originally designed for propagating credentials (e.g. private keys) into a pipeline, and we didn't want to invent another crazy templating language.
The proposal for tomorrow is to invent another crazy templating language. But, like, this time we'll get it right. The only thing this language will support is pulling in values from some other structure. (Though I expect people will continuously ask for new features, e.g. defaults, which is a little worrying...)
The first step is to switch to ((parens)), so that we can parse the YAML first ({{these}} are invalid). This fixes #118 as the YAML parsing would skip any comments.
This interpolation would follow YAML semantics, not just text substitution. This means false would stay false, not become "false" (concourse/s3-resource#41), and you could interpolate structures like arrays and hashes (#299).
We would handle foo((bar))baz by pulling out the bar value as normal, ensuring it's a string, and adding "foo" and "baz" around it, fixing #360. If the value is not a string, we'll fail fast, since we don't want to marshal it (YAML is tricky: yes and on both turn into true, so we can't just marshal).
We would start implementing this as a generic library so that it can be reused with BOSH, which has pretty much the exact same set of goals coming up.
The interpreting of the template handling would be done entirely in the ATC. Fly would just submit the YAML and the params, and ATC would handle it. This way adding things like Vault (#291) is just like adding another source of params for ATC to interpolate in the same pass. So some params would come from fly and some would come from a config server, but they look the same. The goal here is to keep pipeline templates decoupled from the config store that you have their params come from: you could use Vault or just stick with local params.
This would all be backwards-compatible; we'll continue to process {{these}} ahead of time, and likely start issuing warnings, but it's trivial to support both.
Example
pipeline.yml:
resources:
- name: my-repo
source:
uri: [email protected]:concourse/concourse.git
private_key: (( secret.concourse_repo.private_key ))
- name: env-state
source:
bucket: (( env ))-ci
key: state
jobs:
- name: do-some-stuff
plan:
- get: my-repo
- task: build-thing-on-env
tags: (( env-tags ))params.yml:
secret:
concourse_repo:
private_key: |
---BEGIN SUPER SECRET STUFF---
AJHGSHKFSDHJCBSHCJBSGJKDBJSD
...
---END SUPER SECRET STUFF---
env: staging
env-tags: ["speedy"]With fly set-pipeline -c pipeline.yml -l params.yml, this would resolve to:
resources:
- name: my-repo
source:
uri: [email protected]:concourse/concourse.git
private_key: |
---BEGIN SUPER SECRET STUFF---
AJHGSHKFSDHJCBSHCJBSGJKDBJSD
...
---END SUPER SECRET STUFF---
- name: env-state
source:
bucket: staging-ci
key: state
jobs:
- name: do-some-stuff
plan:
- get: my-repo
- task: build-thing-on-env
tags: ["speedy"]And, with Vault support in #291, the secret.concourse_repo.private_key could instead come from a key in Vault. That is, foo.bar.baz would resolve to the baz attribute of the foo/bar key.
Activity
vito commentedon Jul 19, 2016
One concern: with Vault each backend is explicitly mounted at a certain level in the path. This means that keys reaching into Vault would tend to look like
<some backend mount>.foo.bar.baz, which kind of leaks the abstraction and means people reusing the template would have to mimic Vault's hierarchy. In the above example this is shown assecret.concourse_repo.private_key. Maybe that's OK? Maybe the mounts will be named generically enough that it doesn't feel weird? (e.g.aws.)/cc @cppforlife
concourse-bot commentedon Jul 19, 2016
Hi there!
We use Pivotal Tracker to provide visibility into what our team is working on. A story for this issue has been automatically created.
The current status is as follows:
-l-vThis comment, as well as the labels on the issue, will be automatically updated as the status in Tracker changes.
dcarley commentedon Jul 20, 2016
Suits our use cases 👍
robdimsdale commentedon Jul 20, 2016
What happens if
foo:(( some-var ))is not supplied? Will this result infoo: nilor a failure in template rendering?Other than that, this looks fine for me
vito commentedon Jul 20, 2016
@robdimsdale Up for discussion. I'm tempted to have it leave the key
unspecified. Then there'd be no future ask for optional params, and things
would still error if it was required.
Same for
foo-((bar))?Alternatively, as with today's behavior it could error if any are
unspecified.
On Wed, Jul 20, 2016, 7:14 AM Rob Dimsdale-Zucker [email protected]
wrote:
zachgersh commentedon Jul 20, 2016
@vito on the vault abstraction - if the ATC is going to be making the calls to vault to get the values why not have the user specify no backend.
The ATC could just discover what secret backend the user has specified by listing mounts. You end up with a less leaky abstraction and get to specify something like this
Any thoughts on whether fly could automagically convert your {{}} to (()) would probably make the transition even better for people. Still issue a warning so that people change them at some point.
vito commentedon Jul 20, 2016
@zachgersh After the backend is mounted it's just like any other key - that's the Vault abstraction I'd like to preserve.
Fly could probably auto-convert
{{}}to(()).keymon commentedon Jul 21, 2016
@vito when will (( my_mount_thing.a.value )) be evaluated?
When rendering and storing the pipeline in ATC, or every time the resource/task is executed?
I understand it will be every time the resource/task is executed, as this is important in the case of dynamic backends.
vito commentedon Jul 24, 2016
@keymon Until we do #291, that would only mean local config, which could just be rendered and stored in the DB, same as today. (We could keep the params and dynamically evaluate them, but there's not much point since they're static).
Later, we'll want to defer it until resource/task execution.
cjcjameson commentedon Jul 28, 2016
Our use case, prompted from #360: a long-established product for which Concourse is the 3rd generation CI system. So we're adapting existing makefiles etc. and building up concourse around and into its build system, but we've got constraints. The makefiles generate specific, brittle filenames, and our customers expect those same consistent, detailed filenames. So our CI system in the middle is most natural if we maintain those filenames. This defies the Concourse idiom which prefers de-referencing to a generic, abstract filename in the middle and reconstructing the detailed, versioned filename at the end.
We want to interpolate these filenames into our pipeline, as a step on the way to refactoring towards a more ideal structure for the filename. We want to highlight duplication between the Concourse pipeline file and makefiles' hardcoded configuration, so that we can recruit other teams to work with us on building it better. We also want to DRY up the repetition of the brittle filenames within the pipeline.yml.
We will attempt the suggestion from #360 to have the whole filepath as the interpolated variable.
cjcjameson commentedon Aug 5, 2016
Update on our use case: our pain around brittle filenames at the entrypoints to the pipeline is slightly reduced by using the S3 resource's features around arbitrary filenames and glob expansion/matching: https://github.com/concourse/s3-resource#parameters-1
65 remaining items
add template package for evaluating pipeline config
evaluates variables with new templating package
passes []byte of config instead of atc.Config to set pipeline
fix tests to use new create or update pipeline arguments
bump bosh-cli atc fly go-concourse testflight
fix up new templating and backfill tests
avirkar commentedon Aug 14, 2017
Will it be possible to merge two keys for eg.
PCF_APP_NAME: ((cf-api-app1))-((env))
vito commentedon Aug 14, 2017
avirkar commentedon Aug 15, 2017
Do you have an sample of how that can be achieved, my var file has key value pairs like
cf-api-app: api-
cf-dispatcher-app: dispatcher-
cf-space: test
In my pipeline I want to pass param to my task which should look something like
PCF_API_APP_NAME: ((cf-api-app))-((cf-space))
PCF_DISPATCHER_APP_NAME: ((cf-dispatcher-app))-((cf-space))
So my task can get a param based on environment, and it would look something like
PCF_API_APP_NAME: api-test
PCF_DISPATCHER_APP_NAME: dispatcher-test
But I guess somehow, it does not take the combination as expected and is unable to evaluate it.
I even tried using anchor in my config.yml but still it does not work.
aliases: &environ test
cf-api-app: api-*environ (fails)
cf-dispatcher-app: dispatcher-*environ (fails)
cf-space: *environ (works)
endemics commentedon Aug 15, 2017
@avirkar you should consider opening another issue as this issue has been closed when the feature was implemented.
Also when creating a bug report, try to provide the simplest configuration options that allow to reproduce it. In this case, your example is not enough.
For instance, I have configurations using multiple interpolation successfully, so I can tell that the feature works as expected, at least "on my machine".
avirkar commentedon Aug 15, 2017
@endemics Submitted a new issue. #1471