Compose
Description
The updatecli compose feature allows specifying a list of updatecli policies to enforce. This is useful when applying the same policies on multiple repositories.
By default, it relies on a file named updatecli-compose.yaml in the current directory,
overridable with the --file (-f) flag, such as in the follow example:
policies:
- name: Local Updatecli Website Policies
config:
- updatecli/updatecli.d/
- name: Handle Nodejs version in githubaction
policy: ghcr.io/updatecli/policies/policies/nodejs/githubaction:latest
values:
- updatecli/values.d/scm.yaml
- updatecli/values.d/nodejs.yamlRunning
updatecli compose applywould enforce the state defined in each of the policiesRunning
updatecli compose diffwould show the targeted state defined in each of the policiesRunning
updatecli compose showwould show the manifest generated by each of the policies
Note | update-compose.yaml is the deprecated former default filename. Updatecli still picks it up, with a warning, when no updatecli-compose.yaml exists. |
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| env_files | array | Env_files contains a list of environment files Example:
| |
| environments | object | Environment contains a list of environment variables Example: ENV_VAR1: value1 ENV_VAR2: value2 | |
| include | array | Include contains a list of compose files to include | |
| name | string | Name contains the compose name | |
| policies | array | Policies contains a list of policies | |
| config | array | Config contains a list of Updatecli config file path | |
| id | string | ID contains the policy ID, it can be used to filter policies to execute | |
| name | string | Name contains the policy name | |
| policy | string | Policy contains the policy OCI name | |
| secrets | array | Secrets contains a list of Updatecli secret file path | |
| values | array | Values contains a list of Updatecli config file path | |
| valuesinline | object | ValuesInline contains a list of inline values for Updatecli config A deep merge will be performed between global inline values and policy inline values if both are defined. Example: key1: value1 key2: value2 | |
| secrets | array | Secrets contains a list of Updatecli secret file path This is the default secret file that will be applied to all policies if not overridden by the policy secret file. | |
| values | array | Values contains a list of Updatecli config file path This is the default values file that will be applied to all policies if not overridden by the policy values file. | |
| valuesinline | object | ValuesInline contains a list of inline values for Updatecli config This is the default inline values that will be applied to all policies if not overridden by the policy inline values. A deep merge will be performed between global inline values and policy inline values if both are defined. Example: key1: value1 key2: value2 |
Values precedence
A policy pulled from a registry ships its own values and secrets files.
The compose file can add more, at two levels: the root keys values, valuesinline, and secrets
apply to every policy, while the same keys under an individual policy apply to that policy only.
They are combined rather than replaced, in this order, later winning over earlier:
values and secrets shipped by the policy itself
root level
values, then the policy’s ownvaluesroot level
secrets, then the policy’s ownsecretsroot level
valuesinline, then the policy’s ownvaluesinline
The merge is recursive, so two files can contribute different keys to the same nested object, and only conflicting leaves are overridden.
Note | Paths in values and secrets are resolved relative to the compose file, not to the current working directory. |
Environment variables
The root keys environments and env_files set environment variables before the policies are
evaluated, which is how you feed {{ requiredEnv "…" }} in a policy without exporting anything in
your shell.
environments:
UPDATECLI_GITHUB_OWNER: updatecli
env_files:
- .env
policies:
- name: Local policies
config:
- updatecli/updatecli.d/The two keys do not behave the same way:
environmentssets each variable unconditionally, overriding whatever the shell already exported.env_filesreads dotenv files and never overrides an existing variable, which makes it suitable for defaults rather than for forcing a value.
Important |
|
Splitting a compose file
The root key include loads other compose files, whose policies are appended to the run.
Circular includes are detected and skipped, so a file is never loaded twice.
include:
- compose/golang.yaml
- compose/container.yamlIncluded paths are resolved relative to the file declaring them.
Selecting policies
Give a policy an id to be able to run a subset of the compose file:
policies:
- name: Handle Nodejs version in githubaction
id: nodejs
policy: ghcr.io/updatecli/policies/policies/nodejs/githubaction:latest# Only run the policies with these ids
updatecli compose diff --only-policy-ids=nodejs
# Run everything but these ones
updatecli compose diff --ignored-policy-ids=nodejsImportant | With --only-policy-ids, policies without an id are skipped, since they cannot be selected. |
Examples
Updatecli
The repository updatecli/policies contains a list of common updatecli policies published on GitHub Registry.
Go Further
To know more about how a policy is built and published, see Updatecli policy
To know more about filtering the pipelines inside those policies, see labels