# Cargo Package<no value>
// <!-- Required for asciidoctor -->
:toc:
// Set toclevels to be at least your hugo [markup.tableOfContents.endLevel] config key
:toclevels: 4

[cols="1^,1^,1^",options=header]
|===
| source | condition | target
| &#10004; | &#10004; | &#10007;
|===

== Description

The `cargopackage` resource queries a cargo registry (link:https://crates.io[crates.io] by default) for the versions of a crate.

**source**::
Returns the version matching `versionfilter`.

**condition**::
Checks that `version` is 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 link:/docs/plugins/resource/toml/["TOML" resource] against `Cargo.toml`, or the link:/docs/plugins/autodiscovery/cargo/[cargo autodiscovery crawler].

== Parameters

{{< resourceparameters "sources" "cargopackage" >}}

`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:

[cols="1,3",options=header]
|===
| Field | Meaning
| `url` | A registry HTTP index. Unset means crates.io.
| `rootdir` | A local directory holding a filesystem index, instead of an HTTP one.
| `scmid` | The id of an `scm` whose clone holds the index. Overrides `rootdir` and `url`.
|===

`registry.auth` carries the credentials for a private registry:

[source,yaml]
----
spec:
  package: serde
  registry:
    url: https://cargo.acme.example.com
    auth:
      token: '{{ requiredEnv "CARGO_TOKEN" }}'
----

== Example

[source,yaml]
----
# updatecli.yaml
{{<include "assets/code_example/docs/plugins/resources/cargopackage/updatecli.d/default.yaml">}}
----

== Links

* link:https://doc.rust-lang.org/cargo/reference/registries.html[Cargo registries]
* link:/docs/core/versionfilter/["Version Filtering" page]
