On this page
Cargo Package
| source | condition | target |
|---|---|---|
✔ | ✔ | ✗ |
Description
The cargopackage resource queries a cargo registry (crates.io by default) for the versions of a crate.
- source
Returns the version matching
versionfilter.- condition
Checks that
versionis published for the crate.- target
Not supported - a target fails with
Target not supported for the plugin Cargo Package. To bump a dependency in a file, use the "TOML" resource againstCargo.toml, or the cargo autodiscovery crawler.
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| package | string | “package” defines the name of the Cargo package. compatible:
remark:
example:
| |
| registry | object | “registry” defines the Cargo registry to query. compatible:
default: the crates.io API, https://crates.io/api/v1/crates remark:
| |
| auth | object | “auth” defines the credentials used to authenticate with the cargo registry. | |
| rootdir | string | “rootdir” defines the local directory of a cargo registry index, used instead of the registry API. remark:
| |
| scmid | string | “scmid” defines the scm holding the cargo registry index, used instead of the registry API. remark:
| |
| url | string | “url” defines the URL of the cargo registry API. default: https://crates.io/api/v1/crates, when neither “rootdir” nor a scm is set. remark:
| |
| version | string | “version” defines the package version to check. compatible:
default: the output of the associated source. example:
| |
| versionfilter | object | “versionfilter” defines the version pattern and its kind, such as regex, semver or latest. compatible:
default: kind: latest remark:
| |
| kind | string | “kind” defines the versioning scheme used to select a version. default: latest remark:
example:
| |
| pattern | string | “pattern” defines the version pattern, according to “kind”. default:
remark:
example:
| |
| regex | string | “regex” defines the regular expression extracting the version from each entry. remark:
example:
| |
| replaceall | object | “replaceall” applies a regular expression replacement to each version before filtering. remark:
example: turns “curl-8_15_0” into “curl-8.15.0”. | |
| strict | boolean | “strict” enforces strict semantic versioning rules when parsing versions. default: false remark:
|
package is mandatory. version is condition-only (the version whose existence is being checked).
Note | indexurl is deprecated and hidden from the table above. Use registry.url. |
Registry
registry describes where to look, and its three location fields are mutually exclusive, setting more than one is rejected before the run, naming the field that would be overridden:
| Field | Meaning |
|---|---|
| A registry HTTP index. Unset means crates.io. |
| A local directory holding a filesystem index, instead of an HTTP one. |
| The id of an |
registry.auth carries the credentials for a private registry:
spec:
package: serde
registry:
url: https://cargo.acme.example.com
auth:
token: '{{ requiredEnv "CARGO_TOKEN" }}'Example
# updatecli.yaml
name: Retrieve the latest Cargo Package Version
scms:
private-registry:
kind: git
spec:
url: "https://github.com/updatecli-test/fake-cargo-registry.git"
branch: "main"
sources:
rand:
name: Get latest rand version from public cargo registry
kind: cargopackage
spec:
package: rand
test-crate-2:
name: Get latest test-crate-2 version from private cargo registry
kind: cargopackage
scmid: private-registry
spec:
package: test-crate-2
versionfilter:
kind: semver
pattern: ~0
conditions:
existing-package-private-reg:
name: Test if test-crate-2 0.1.0 exists on private registry
kind: cargopackage
disablesourceinput: true
scmid: private-registry
spec:
package: test-crate-2
version: 0.1.0
existing-package-not-existing-version-private-reg:
name: Test if test-crate-2 0.6.0 does not exists on private registry
kind: cargopackage
disablesourceinput: true
scmid: private-registry
failwhen: true
spec:
package: test-crate-2
version: 0.6.0
non-existing-package-private-reg:
name: Test if non-existing-test-crate 0.1.0 does not exists on private registry
kind: cargopackage
disablesourceinput: true
scmid: private-registry
failwhen: true
spec:
package: non-existing-test-crate
version: 0.1.0
existing-package-public-reg:
name: Test if rand version exists on public reg
kind: cargopackage
disablesourceinput: true
spec:
package: rand
version: 0.7.2
existing-package-p-not-existing-version-public-reg:
name: Test if rand version 99.99.99 does not exists on public reg
kind: cargopackage
disablesourceinput: true
failwhen: true
spec:
package: rand
version: 99.99.99
non-existing-package-public-reg:
name: Test if non-existing-package-to-be-sure-123456 does exists on public reg
kind: cargopackage
disablesourceinput: true
failwhen: true
spec:
package: non-existing-package-to-be-sure-123456
version: 0.7.2
targets:
# Targets are not supported