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 per tags #208

Closed siredmar closed 3 years ago

siredmar commented 3 years ago

In reference to #207 this is a PR that implements the grouped list via tags. Also this PR adds documentation to the AnnotationFields type.

See for yourself below.

dobi.yaml

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"
    tags: 
      - group1

job=group1-2-job:
  use: bash
  command: bash -c "ls"
  annotations:
    description: "test job for group 1.1"
    tags: 
      - 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: "test job for group 2"
    tags: 
      - group2

job=group1and2-job:
  use: bash
  command: bash -c "ls"
  annotations:
    description: "test job for group 1 and 2"
    tags: 
      - group1
      - group2

Usage:

./dobi -f test.yaml list --help  
List resources

Usage:
  dobi list [flags]

Flags:
  -a, --all            List all resources, including those without descriptions
  -g, --groups         List resources sorted by their matching tags. Only resources with configured tags will be listed.
  -t, --tags strings   List tasks matching the tag

Original output

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

Tags:
  group1, group2

Grouped list:

./dobi -f test.yaml list -g     
Resources:
  Tag: group1
  group1-1-job         test job for group 1.1
  group1-2-job         test job for group 1.1
  group1and2-job       test job for group 1 and 2

  Tag: group2
  group1and2-job       test job for group 1 and 2
  group2-job           test job for group 2

Tags:
  group1, group2

Grouped list with all:

./dobi -f test.yaml list -g -a
Resources:
  Tag: none
  bash                 Build image 'bash' from ''
  no-group-job         test job for no group

  Tag: group1
  group1-1-job         test job for group 1.1
  group1-2-job         test job for group 1.1
  group1and2-job       test job for group 1 and 2

  Tag: group2
  group1and2-job       test job for group 1 and 2
  group2-job           test job for group 2

Tags:
  group1, group2