dnephin / dobi

A build automation tool for Docker applications
https://dnephin.github.io/dobi/
Apache License 2.0
309 stars 36 forks source link

List by groups #205

Closed siredmar closed 3 years ago

siredmar commented 3 years ago

This feature adds the option -g / --groups to the list command. Allowing a group setting in the annotations field lets group certain things together.

example dobi file:

meta:
  project: test

image=bash:
  image: bash
  pull: once
  tags:
    - latest

job=group1-1-job:
  use: bash
  command: bash -c "ls"
  annotations:
    description: "test job for group 1.1"
    group: group1

job=group1-2-job:
  use: bash
  command: bash -c "ls"
  annotations:
    description: "test job for group 1.1"
    group: group1

job=no-group-job:
  use: bash
  command: bash -c "ls"
  annotations:
    description: "test job for no group"

job=group2-job:
  use: bash
  command: bash -c "ls"
  annotations:
    description: "teset job for group 2"
    group: group2

Resulting behavior with -g flag

./dobi -f test.yaml list -g                     
Resources:
  no-group-job         test job for no group
Group: group1
  group1-1-job         test job for group 1.1
  group1-2-job         test job for group 1.1
Group: group2
  group2-job           teset job for group 2

The old behavior is still present without -g flag.

./dobi -f test.yaml list   
Resources:
  group1-1-job         test job for group 1.1
  group1-2-job         test job for group 1.1
  group2-job           teset job for group 2
  no-group-job         test job for no group

If there are no groups defined but list is called with -g, it looks like if it were run without -g.

siredmar commented 3 years ago

I guess this PR can be closed. Most of the Features are already present with Tags. However, i will open a new PR that makes it possible to list all resources by its tags.