Manage tags with decK

Uses: deck

Tags are at the core of federated configuration management, which allows each team to manage their own config.

Using the deck file tag commands, you can add tags to identify configuration lineage automatically without depending on your application teams understanding the process and remembering to apply tags consistently.

add-tags

The add-tags command can add tags to any entity. Here’s an example that adds the team-one tag to all entities in the provided file:

deck file add-tags -s ./config.yaml team-one
Copied to clipboard!

This is useful to track entity ownership when using the deck file merge command to build a single configuration to sync.

To add tags to specific entities only, provide the --selector flag. The provided tags will be added only to entities that match the selector

You can add multiple tags at once by providing them as additional arguments, for example: team-one another-tag and-another.

Command usage

Usage:
  deck file add-tags [flags] tag [...tag]

Examples:
# adds tags 'tag1' and 'tag2' to all services in file 'kong.yml'
cat kong.yml | deck file add-tags --selector='services[*]' tag1 tag2

Flags:
      --format string          Output format: json or yaml (default "yaml")
  -h, --help                   help for add-tags
  -o, --output-file string     Output file to write to. Use - to write to stdout. (default "-")
      --selector stringArray   JSON path expression to select objects to add tags to.
                               Defaults to all Kong entities. Repeat for multiple selectors.
  -s, --state string           decK file to process. Use - to read from stdin. (default "-")

Copied to clipboard!

remove-tags

The opposite of add-tags, remove-tags allows you delete tags from your configuration file. It will remove the provided tag only by default:

deck file remove-tags -s ./config.yaml tag_to_remove
Copied to clipboard!

To keep specific tags and remove all others, pass the --keep-only flag:

deck file remove-tags -s ./config.yaml --keep-only env-prod team-one
Copied to clipboard!

Finally, to remove tags from specific entities you can pass a --selector. This can be combined with --keep-only as needed:

deck file remove-tags -s ./config.yaml \
  --selector "$..services[*]" \
  --keep-only env-prod team-one
Copied to clipboard!

Command usage

Usage:
  deck file remove-tags [flags] tag [...tag]

Examples:
# clear tags 'tag1' and 'tag2' from all services in file 'kong.yml'
cat kong.yml | deck file remove-tags --selector='services[*]' tag1 tag2

# clear all tags except 'tag1' and 'tag2' from the file 'kong.yml'
cat kong.yml | deck file remove-tags --keep-only tag1 tag2

Flags:
      --format string          Output format: json or yaml (default "yaml")
  -h, --help                   help for remove-tags
      --keep-empty-array       Keep empty tag arrays in output.
      --keep-only              Setting this flag will remove all tags except the ones listed.
                               If none are listed, all tags will be removed.
  -o, --output-file string     Output file to write. Use - to write to stdout. (default "-")
      --selector stringArray   JSON path expression to select objects to remove tags from.
                               Defaults to all Kong entities. Repeat for multiple selectors.
  -s, --state string           decK file to process. Use - to read from stdin. (default "-")

Copied to clipboard!

list-tags

The list-tags command outputs all tags found in the file. Any tag that is applied to at least one entity is returned.

deck file list-tags -s ./config.yaml
Copied to clipboard!

Command usage

Usage:
  deck file list-tags [flags]

Examples:
# list all tags used on services
cat kong.yml | deck file list-tags --selector='services[*]'

Flags:
      --format string          Output format: json, yaml, or PLAIN (default "PLAIN")
  -h, --help                   help for list-tags
  -o, --output-file string     Output file to write to. Use - to write to stdout. (default "-")
      --selector stringArray   JSON path expression to select objects to scan for tags.
                               Defaults to all Kong entities. Repeat for multiple selectors.
  -s, --state string           decK file to process. Use - to read from stdin. (default "-")

Copied to clipboard!

Did this doc help?

Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!