ARTIFACTORY: How to Set up a Smart Remote Repository for Cargo Package type in JFrog Artifactory with Sparse Indexing
A smart remote repository is a remote repository that proxies a local, remote and federated repository from another instance of Artifactory.
Sparse indexing is a Cargo registry protocol, introduced in Rust 1.68, that fetches crate index metadata over HTTPS instead of using a Git-based index
Please follow this article to set up a remote repository for Cargo in Artifactory. Once the remote repository is set up, we can start setting up the smart remote repository by following the below.
1. Point the URL and Registry URL and validate the connection by entering the source Artifactory’s user username and password as mentioned below:
Example:
URL: http://<$SourceArtifactoryurl>/artifactory/api/cargo/$ArtifactorySourceRemoteKey Registry URL : http://<$SourceArtifactoryurl>/artifactory/api/cargo/$ArtifactorySourceRemoteKey/index
Once the URL is mapped, please enable sparse index support in the Remote repository settings.
2. Once the configuration at the Artifactory level is completed, find the below steps which need to be performed at the Cargo client level.
Sample “config.toml” file:
# Makes artifactory the default registry and saves passing --registry parameter [registry] default = "artifactory" [registries.artifactory] index = "sparse+http://$ArtifactoryBURL/artifactory/api/cargo/$Bremotekey/index/" # For sending credentials in git requests. # Not required if anonymous access is enabled [net] git-fetch-with-cli = true # Add these 2 sections for resolving dependencies from Artifactory [source.artifactory] registry = "sparse+http://$ArtifactoryBURL/artifactory/api/cargo/$Bremotekey/index/" [source.crates-io] replace-with = "artifactory"
3. Now try to download a Cargo packages, we will be able to download the packages:
#cargo login --registry artifactory -Z sparse-registry
#cargo -Z sparse-registry install ripgrep
4. Artifacts downloaded successfully: