Manage sets of units together
Operate on multiple units in bulk
In general, ConfigHub supports bulk operations, which operate on filtered groups of entities of the same entity type, including units.
Bulk patch, delete, and even create operations are supported for most entity types. Bulk patch can be used to perform unit data operations such as restore and upgrade.
Additionally, functions are invoked in bulk by default, except when operating on a specific revision of a specific unit.
Unit actions, such as Tag, Approve, Apply, Destroy, and Refresh, also support bulk operations. These actions are frequently used as part of a multi-unit change-and-apply workflow. If Apply and Destroy actions need to be performed on the units in a specific order, use links to express the dependencies.
Selecting the units
First identify a set of units you want to operate on. It may be a vertical subset, like the units belonging to a single helm chart or cluster, or a horizontal subset, like all the variants of a unit across clusters.
Use a where expression with Labels to select the units.
To add a label to make them easier to select using a where filter, you can use patch:
cub unit update --patch --label Application=acme --space acme-dev --where "Slug IN ('frontend', 'backend', 'database', 'cache')"
That enables filters to be expressed more concisely:
cub unit list --space acme-dev --where "Labels.Application = 'acme'"
Create a saved Filter
If this is a set of units you'll frequently want to operate on together, create a saved Filter to represent them. Using a saved Filter reduces the chances of making mistakes.
Choose a Space to put the Filter in. We recommend choosing a "home space" to put commonly reused entities in, such as Filters, Views, and ChangeSets. The CLI can store this space as the default space in the context.
cub space create acme-home
cub filter create --space acme-home acme-app Unit --where-field "Labels.Application = 'acme'"
Use a saved Filter
Every command that supports --where also supports --filter. Specify the saved Filter, including its space if it's in not in the default space and not in the space specified on the command line.
cub unit approve --space acme-dev --filter acme-home/acme-app
cub unit apply --space acme-dev --filter acme-home/acme-app
For more on creating and organizing Filters and Views, see the Filters and Views guide.