Skip to content

Proposal for new params behavior #545

Closed

Description

@vito

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

  1. vito commented on Jul 19, 2016

    @vito
    ContributorAuthor

    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 as secret.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

  2. concourse-bot commented on Jul 19, 2016

    @concourse-bot

    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:

    • #126547009 Introduce new YAML-semantic templating syntax for -l
    • #126743353 I can populate the new params syntax via -v
    • #126743511 I can interpolate the new params into strings
    • #140235203 Proposal for new params behavior

    This comment, as well as the labels on the issue, will be automatically updated as the status in Tracker changes.

  3. dcarley commented on Jul 20, 2016

    @dcarley
    Contributor

    Suits our use cases 👍

  4. robdimsdale commented on Jul 20, 2016

    @robdimsdale
    Contributor

    What happens if foo:(( some-var )) is not supplied? Will this result in foo: nil or a failure in template rendering?

    Other than that, this looks fine for me

  5. vito commented on Jul 20, 2016

    @vito
    ContributorAuthor

    @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:

    What happens if foo:(( some-var )) is not supplied? Will this result in foo:
    nil or a failure in template rendering?

    Other than that, this looks fine for me

    —
    You are receiving this because you authored the thread.
    Reply to this email directly, view it on GitHub
    #545 (comment),
    or mute the thread
    https://github.com/notifications/unsubscribe-auth/AAAHWLQuJLxUpkOjvdPYOTfOct3Pm-Vbks5qXizdgaJpZM4JQMok
    .

  6. zachgersh commented on Jul 20, 2016

    @zachgersh
    Contributor

    @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.

  7. vito commented on Jul 20, 2016

    @vito
    ContributorAuthor

    @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 (()).

  8. keymon commented on Jul 21, 2016

    @keymon
    Contributor

    @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.

  9. vito commented on Jul 24, 2016

    @vito
    ContributorAuthor

    @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.

  10. cjcjameson commented on Jul 28, 2016

    @cjcjameson
    Contributor

    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.

  11. cjcjameson commented on Aug 5, 2016

    @cjcjameson
    Contributor

    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

  12. 65 remaining items

  13. added a commit that references this issue on Jun 14, 2017
  14. avirkar commented on Aug 14, 2017

    @avirkar

    Will it be possible to merge two keys for eg.
    PCF_APP_NAME: ((cf-api-app1))-((env))

  15. vito commented on Aug 14, 2017

    @vito
    ContributorAuthor
  16. avirkar commented on Aug 15, 2017

    @avirkar

    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)

  17. endemics commented on Aug 15, 2017

    @endemics

    @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".

  18. avirkar commented on Aug 15, 2017

    @avirkar

    @endemics Submitted a new issue. #1471

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions