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
filestring[s][c][t] File specifies the toml file to manipulate
filesarray[c][t] Files specifies a list of Json file to manipuate
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

Xpath

Under construction, some help would be need to document common jsonpath query that work with Updatecli https://www.w3.org/TR/1999/REC-xpath-19991116/

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