Skip to content

Allow globs in groups - #6060

Merged
aoldershaw merged 1 commit into
concourse:masterfrom
EngineerBetter:allow-globs-in-groups
Nov 19, 2020
Merged

aoldershaw merged 1 commit into
concourse:masterfrom
EngineerBetter:allow-globs-in-groups

Conversation

@andy-paine

@andy-paine andy-paine commented Sep 11, 2020 •

Copy link
Copy Markdown

What does this PR accomplish?

Allow groups to list jobs via globs rather than just strict matches. It isn't uncommon to have an all group which you need to remember to add any new jobs to and it is easy to forget to fly validate-pipeline first. With this feature, the groups could just be (quoting to prevent being seen as YAML anchor):

- name: all
  jobs:
  - "*"
- name: deploy
  jobs:
  - deploy-*

Bug Fix | Feature | Documentation

Changes proposed by this PR:

When validating/saving groups that a job is in, use glob.Glob rather than Lookup/map keys which strictly check equality. Add/modify some tests to ensure behaviour is covered.

Notes to reviewer:

There are 2 commits here - the first uses a regular expression and the second converts it to using globs. I think globs seem nicer so I would prefer to use globs and just squash these 2 commits but I left it there for reference. I don't think users need/necessarily want the full power of regular expressions just for selecting groups.

On my travels I also noticed that a group can contain resources - I'm pretty sure this field only exists on the object and in validation and isn't actually persisted to the DB anywhere. Doing some manual testing specifying resources in the pipeline config doesn't do anything so I'm pretty sure this is dead code. I say all this to qualify why I didn't bother extending the glob based matching to resources as well 😂

Release Note

  • groups in a pipeline can now match jobs based on globs e.g.:
    groups:
    - name: deploy
      jobs:
      - deploy-*
    

Contributor Checklist

Reviewer Checklist

  • Code reviewed
  • Tests reviewed
  • Documentation reviewed
  • Release notes reviewed
  • PR acceptance performed
  • New config flags added? Ensure that they are added to the
    BOSH and
    Helm packaging; otherwise, ignored for
    the integration
    tests

    (for example, if they are Garden configs that are not displayed in the
    --help text).

@agurney

agurney commented Sep 25, 2020

Copy link
Copy Markdown

This looks useful for many of our teams who have fairly elaborate pipeline setups that include deployment and testing in multiple environments. I was just looking at some of the group configs our users currently have, and it should be nice if they can say stuff like ["terraform-*-staging"] instead of ["terraform-plan-pod-staging", "terraform-apply-pod-staging", "terraform-plan-basic-staging", "terraform-apply-basic-staging"], and many other similar instances.

@chenbh

chenbh commented Sep 30, 2020

Copy link
Copy Markdown
Contributor

I wonder if we should use https://github.com/gobwas/glob and support the full wildcards suite instead of just *. I can see a scenario where I want to group deploy-to-{dev,qa,staging} and deploy-to-{uat,prod} separately

@andy-paine

Copy link
Copy Markdown
Author

I could get behind that - I actually used that library to begin with but then didn't want to add a new dependency since the one I used is already included via the Vault dep

@andy-paine
andy-paine force-pushed the allow-globs-in-groups branch 2 times, most recently from ee8ea0f to 2d9e7f6 Compare October 16, 2020 13:25
@andy-paine

Copy link
Copy Markdown
Author

I've squashed everything down to a single commit and it uses gobwas now

@andy-paine
andy-paine force-pushed the allow-globs-in-groups branch from 2d9e7f6 to a3c8361 Compare October 21, 2020 22:31
It is quite common to have an "all" group or a "test" group in a
pipeline and it can be annoying when you forget to add new jobs to those
groups. By allowing globs, groups can be kept smaller and catch new jobs
(provided they match the expression)

Signed-off-by: Andy Paine <[email protected]>
@andy-paine
andy-paine force-pushed the allow-globs-in-groups branch from a3c8361 to 5903b6f Compare November 6, 2020 14:24
@andy-paine

Copy link
Copy Markdown
Author

I've fixed all the tests now. Can you let me know if there is anything more I need to do on this?

@aoldershaw aoldershaw self-assigned this Nov 19, 2020

@aoldershaw aoldershaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay getting this reviewed! Appreciate your patience 🙏

Looks good to me! Seems like a useful feature - I have also felt the pain of forgetting to add new jobs to groups. While it's not so hard to add the job to the group after fly complains, it's certainly a QoL improvement. I also like how this encourages consistent naming of jobs!

Thanks!

@aoldershaw
aoldershaw merged commit 27e1d83 into concourse:master Nov 19, 2020
aoldershaw added a commit to concourse/docs that referenced this pull request Jan 26, 2021
@aoldershaw aoldershaw added the release/documented Documentation and release notes have been updated. label Jan 26, 2021
kcbimonte pushed a commit to Aviator-Labs/docs-ci that referenced this pull request Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement release/documented Documentation and release notes have been updated.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants