TOML

kind: toml

sourceconditiontarget

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

NameTypeDescriptionRequired
createmissingkeyboolean[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
filestring[s][c][t] File specifies the toml file to manipulate
filesarray[c][t] Files specifies a list of Json file to manipulate
keystring[s][c][t] Key specifies the query to retrieve an information from a toml file
querystring[s][c][t] Query allows to used advanced query. Override the parameter key
valuestring[s][c][t] Value specifies the value for a specific key. Default to source output
versionfilterobject[s] VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest.
    kindstringspecifies the version kind such as semver, regex, or latest
    patternstringspecifies the version pattern according the version kind
    strictbooleanstrict 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
Top