sourceconditiontarget

✔

✔

✔

Description

The toolversions resource reads and writes one entry in a .tool-versions file, the version manifest used by asdf and mise, where each line pairs a tool name with one or more versions:

nodejs 20.11.0
golang 1.22.0
terraform 1.7.4
source

Returns the version recorded for key.

condition

Checks that the entry holds value, or the source output when value is unset.

target

Updates that entry. Files already holding the value are reported as up to date and left untouched.

Parameters

NameTypeDescriptionRequired
createmissingkeyboolean

“createmissingkey” creates the key when the .tool-versions file does not hold it yet.

compatible:

  • target

default: false

remark:

  • when false, a missing key raises an error.
filestring

“file” defines the path of the .tool-versions file to use.

compatible:

  • source
  • condition
  • target

remark:

  • “file” and “files” are mutually exclusive.
  • the schemes “https://” and “http://” are not supported in a target.

example:

  • file: .tool-versions
filesarray

“files” defines the list of .tool-versions file paths to use.

compatible:

  • condition
  • target

remark:

  • “file” and “files” are mutually exclusive.
keystring

“key” defines the name of the tool to use.

compatible:

  • source
  • condition
  • target

remark:

  • “key” is required.

example:

  • key: golang
valuestring

“value” defines the version associated with the tool.

compatible:

  • condition
  • target

default: the output of the associated source.

file or files is mandatory, as is key; missing either aborts the run with wrong spec content, preceded by .tool-versions file undefined or tool-versions key undefined. file and files are mutually exclusive.

key

The tool name as it appears at the start of the line (golang, not a path expression).

value

Defaults to the source output.

createmissingkey

Target only. Appends the tool when the file does not mention it yet, instead of failing. Unlike the "TOML" resource, there is no engine restriction on it.

Remote files

For a source and a condition, file accepts https://, http:// and file://. A target must write locally and refuses a URL.

Example

# updatecli.yaml
name: Basic .tool-versions Example

scms:
  default:
    kind: git
    spec:
      url: https://github.com/asdf-vm/asdf.git

sources:
  local:
    name: Get value from .tool-versions
    kind: toolversions
    scmid: default
    spec:
      file: .tool-versions
      key: bats
  http:
    name: Get value from .tool-versions
    kind: toolversions
      file: https://raw.githubusercontent.com/updatecli/updatecli/master/pkg/plugins/resources/toolversions/testdata/.tool-versions
      key: bats

conditions:
  local:
    name: Test value from .tool-versions
    kind: toolversions
    sourceid: local
    scmid: default
    spec:
      file: .tool-versions
      path: bats
  http:
    name: Test value from .tool-versions
    kind: toolversions
    disablesourceinput: true
    spec:
      file: https://raw.githubusercontent.com/updatecli/updatecli/master/pkg/plugins/resources/toolversions/testdata/.tool-versions
      path: bats
      value: "1.0.0"

targets:
  local:
    name: Ensure bats is set to "1.8.2" in the .tool-versions file
    kind: toolversions
    sourceid: local
    scmid: default
    spec:
      file: .tool-versions
      key: bats
      value: "1.8.2"