Skip to content

Allow defaults to be set for resource get/put build steps in resource configuration #1941

Closed

Description

@timrchavez

Feature Request

What challenge are you facing?

There can be a fair bit of mental overhead when creating Concourse pipelines, some of which is a result of having to duplicate a lot of boilerplate.

A Modest Proposal

Add a new defaults section to resource configuration blocks, that allow the pipeline developer to specify some defaults for get and put build steps. For example, if the resource supports defaults,

This:

resources:
- name: foo
  type: pull-request
  source:
    ....

jobs:
- name: tests
  plan:
  - get: foo
     trigger: true
     version: every
  - put: foo
    params:
      context: tests
      path: foo
      status: pending
  - task: validate_and_run_tests
    file: path/to/foo/tasks/unit_tests.yml
    on_failure:
      put: foo
      params:
        context: tests
        path: foo
        status: failure
    on_success:
      put: foo
      params:
        context: tests
        path: foo
        status: success
- name: deploy
  plan:
  - get: foo
    trigger: true
    version: every
  ....

Becomes this:

resources:
- name: foo
  type: pull-request
  source:
    ....
  defaults:
    get:
      trigger: true
      version: every
    put:
      params:
        context: tests
        path: foo

jobs:
- name: tests
  plan:
  - get: foo
  - put: foo
    params:
      status: pending
  - task: validate_and_run_tests
    file: path/to/foo/tasks/unit_tests.yml
    on_failure:
      put: foo
      params:
        status: failure
    on_success:
      put: foo
      params:
        status: success
- name: deploy
  plan:
  - get: foo
  ....

Activity

  1. vito commented on Jan 12, 2018

    @vito
    Contributor

    To me, this adds more mental overhead. Now a get: foo can mean simply get: foo but I have to cross-reference foo to really be sure. Changing defaults is also risky, as the full impact of the change isn't immediately clear (have to check for all gets or puts of it, and what happens when many of them don't want the default?).

    I do feel some of the same pain (though probably markedly less; our pipeline has been largely "done" for a while, only requiring incremental changes as we add jobs occasionally), but I suspect this problem runs a bit deeper than DRY-ing up config.

    Your particular example seems to be an example of notifications, which is indeed very verbose and annoying to maintain as it involves annotating every job with verbose config. I think that's the thing to solve, and it's something we've had on the backburner for a while. There are a few creative approaches to this: one being to formalize a notion of 'notifications' specifically, and another more general feature in annotations. This is captured in #1052

  2. ghostsquad commented on Sep 8, 2018

    @ghostsquad

    @timrchavez check out https://jsonnet.org/. It makes writing long and complex pipelines really pleasant!

    I agree with @vito that supporting features to keep you DRY is an antipattern. There's plenty of tools external to concourse that can help you solve this problem.

    jsonnet -y ./pipeline.jsonnet > /tmp/pipeline.yaml
    fly -t my-team set-pipeline -p my-pipeline -c /tmp/pipeline.yaml
    rm /tmp/pipeline.yaml
    {
      local getTriggerEvery(name) = {
    	get: name,
        trigger: true,
        version: "every",
      },
    
      local putTestCtx(name) = {
    	put: name,
        params: {
    		context "tests",
    		path: "foo",
    	},
      },
    
      resources: [
        { 
    		name: "foo",
    		type: "pull-request",
    		source: { ... }
        }
      ],
      jobs: [
    	{
    		name: "tests",
    		plan: [
    			getTriggerEvery("foo"),
    			putTestCtx("foo") { params+: { status: "pending", } },
    			{
    				task: "validate_and_run_tests",
    				file: "path/to/foo/tasks/unit_tests.yml",
    				on_failure: putTestCtx("foo") { params+: { status: "failure" }, },
    				on_success: putTestCtx("foo") { params+: { status: "success" }, },
    			}
    		],
    	},
    	{
    		name: "deploy",
    		plan: [
    			getTriggerEvery("foo"),
    		]
    	}
      ],
    }
  3. stale commented on Jul 16, 2019

    @stale

    Beep boop! This issue has been idle for long enough that it's time to check
    in and see if it's still important.

    If it is, what is blocking it? Would anyone be interested in submitting a
    PR
    or
    continuing the discussion to help move things forward?

    If no activity is observed within the next week, this issue will be
    exterminated closed, in accordance with our stale issue
    process
    .

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions