TOML
kind: toml
On this page
source | condition | target |
---|---|---|
✔ | ✔ | ✔ |
Description
source
The TOML "source" retrieves an information from a TOML file.
condition
The TOML "condition" tests that an information exist in a TOML file.
target
The TOML "target" ensures that a TOML file content a specific value at specific location.
Parameters
Name | Type | Description | Required |
---|---|---|---|
createmissingkey | boolean | [t] CreateMissingKey allows non-existing keys. If the key does not exist, the key is created if AllowsMissingKey is true, otherwise an error is raised (the default). Only supported if Key is used | |
file | string | [s][c][t] File specifies the toml file to manipulate | |
files | array | [c][t] Files specifies a list of Json file to manipulate | |
key | string | [s][c][t] Key specifies the query to retrieve an information from a toml file | |
query | string | [s][c][t] Query allows to used advanced query. Override the parameter key | |
value | string | [s][c][t] Value specifies the value for a specific key. Default to source output | |
versionfilter | object | [s] VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest. | |
kind | string | specifies the version kind such as semver, regex, or latest | |
pattern | string | specifies the version pattern according the version kind | |
strict | boolean | strict enforce strict versioning rule. Only used for semantic versioning at this time |
Query
The TOML resource relies on Dasel to query toml files.
Example
# updatecli.yaml
name: Basic TOML Example
sources:
local:
name: Get value from toml
kind: toml
spec:
file: pkg/plugins/resources/toml/testdata/data.toml
key: .owner.firstName
conditions:
local:
name: Test value from toml
kind: toml
spec:
file: pkg/plugins/resources/toml/testdata/data.toml
key: .owner.firstName
targets:
local:
name: Ensure owner.firstName is set to John
kind: toml
spec:
file: pkg/plugins/resources/toml/testdata/data.toml
key: .owner.firstName
value: John
Important
The library used to manipulate TOML files, drops comments. More information is available on
tomwright/dasel#178. Until we find a solution, a potential workaround is to use the resource file
like in the following example:
# updatecli.yaml
name: Fallback example with TOML
sources:
hugo:
name: Get latest HUGO version
kind: githubrelease
transformers:
- trimprefix: v
spec:
owner: gohugoio
repository: hugo
token: '{{ requiredEnv "UPDATECLI_GITHUB_TOKEN" }}'
username: '{{ requiredEnv "UPDATECLI_GITHUB_ACTOR" }}'
targets:
netlify:
name: Update Hugo version used on Netlify
kind: file
spec:
file: netlify.toml
matchpattern: HUGO_VERSION = "(.*)"
replacepattern: HUGO_VERSION = "{{ source "hugo" }}"
scmid: default
sourceid: hugo