cargo-quickstart
Last updated on
Prerequisites
- Ensure you have the Cargo CLI (
cargo) installed on your local machine. - Access to a Harness account with appropriate permissions to create registries and connectors.
Create a Cargo artifact registry
- Interactive Guide
- Step-by-Step
- Navigate to the Artifact Registry module in your Harness project.
- Click on New Artifact Registry.
- In the Registry Type dropdown, select Cargo Registry.
- Provide a Registry Name.
registry name criteria
Your registry name must start with a letter and can include lowercase alphanumerics, _, . and -.
- Optionally, add a Description and Labels for better organization.
- Choose visibility between Public and Private.
- Click Create Registry to finalize.
private registry
This registry will serve as your private Cargo registry within Harness.
Configure an Upstream Proxy (Optional)
An upstream proxy allows your registry to fetch Cargo packages from external sources if they are not available locally.
- Interactive Guides
- Step-by-Step
Create an upstream proxy
Configure the upstream proxy in your registry
Create an upstream proxy
- In the Artifact Registry module, click the dropdown next to New Artifact Registry and select Upstream Proxy.
- Choose Cargo Registry as the proxy type.
- Click Create Proxy to establish the connection.
Configure the upstream proxy in your registry
- In the Artifact Registry module, select an existing Artifact Registry.
- Select the Configuration tab.
- Under Advanced (Optional), select Configure Upstream.
- Select from the list of compatible proxies to add them to your registry.
- Click Save to save the configuration.
upstream proxy caching
If a Cargo package isn’t found in your Harness registry, the upstream proxy can fetch it from an external source like Cargo.io, helping to reduce duplication and ensure reliable access to public packages.
Publish & Install Cargo Packages
Configure authentication
- In your Harness Cargo Artifact Registry, click Setup Client.
- Create or update your
~/.cargo/config.tomlfile and add the following configuration:
[registry]
global-credential-providers = ["cargo:token", "cargo:libsecret", "cargo:macos-keychain", "cargo:wincred"]
[registries.harness-cargo-registry]
index = "sparse+https://pkg.app.harness.io/pkg/<harness-account-id>/<cargo-registry-name>/cargo/index/"
After creating your new Cargo registry, you will need to set up a client to authenticate with the registry.
- Click Generate token to generate a new identity token for CLI access.
- Create or update your
~/.cargo/credentialsfile and add the following configuration:
[registries.harness-cargo-registry]
token = "Bearer <token from step 2>"
Publish a package
Publish your package with the following command:
cargo publish --registry harness-cargo-registry
Install a package
Install your package with the following command:
cargo add <ARTIFACT_NAME>@<VERSION> --registry harness-cargo-registry