On this page
Tool Versions
| source | condition | target |
|---|---|---|
✔ | ✔ | ✔ |
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 whenvalueis unset.- target
Updates that entry. Files already holding the value are reported as up to date and left untouched.
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| createmissingkey | boolean | “createmissingkey” creates the key when the .tool-versions file does not hold it yet. compatible:
default: false remark:
| |
| file | string | “file” defines the path of the .tool-versions file to use. compatible:
remark:
example:
| |
| files | array | “files” defines the list of .tool-versions file paths to use. compatible:
remark:
| |
| key | string | “key” defines the name of the tool to use. compatible:
remark:
example:
| |
| value | string | “value” defines the version associated with the tool. compatible:
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.
keyThe tool name as it appears at the start of the line (
golang, not a path expression).valueDefaults to the source output.
createmissingkeyTarget 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"