Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cargo): support private crate #24704

Merged
merged 9 commits into from
Oct 3, 2023
26 changes: 20 additions & 6 deletions docs/usage/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,23 @@ Read the [Rust environment variables docs](https://doc.rust-lang.org/cargo/refer

## Private crate registries and private Git dependencies

If any dependencies are hosted in private Git repositories, [Git Authentication for cargo](https://doc.rust-lang.org/cargo/appendix/git-authentication.html) must be set up.

If any dependencies are hosted on private crate registries (i.e., not on `crates.io`), then credentials should be set up in such a way that the Git command-line is able to clone the registry index.
Third-party crate registries usually provide instructions to achieve this.

Both of these are currently only possible when running Renovate self-hosted.
This example shows how you can use a `hostRules` configuration to configure Renovate for use with a custom private Crate using Git to pull the modules when updating `Cargo.lock`.
vmaerten marked this conversation as resolved.
Show resolved Hide resolved
All token `hostRules` with a `hostType` (e.g. `github`, `gitlab`, `bitbucket`, ... ) and host rules without a `hostType` are setup for authentication.
vmaerten marked this conversation as resolved.
Show resolved Hide resolved
It's also possible to setup a hostRules which will be used only for Cargo authentication (e.g. `hostType: 'cargo'`).
vmaerten marked this conversation as resolved.
Show resolved Hide resolved

```js
module.exports = {
hostRules: [
{
matchHost: 'github.enterprise.com',
token: process.env.GITHUB_TOKEN,
hostType: 'github',
},
{
matchHost: 'someGitHost.enterprise.com',
token: process.env.CARGO_GIT_TOKEN,
hostType: 'cargo',
},
],
};
```
10 changes: 5 additions & 5 deletions lib/modules/manager/cargo/__snapshots__/artifacts.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`modules/manager/cargo/artifacts returns null if unchanged 1`] = `
[
{
"cmd": "cargo update --manifest-path Cargo.toml --workspace",
"cmd": "cargo update --config net.git-fetch-with-cli=true --manifest-path Cargo.toml --workspace",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
Expand All @@ -26,7 +26,7 @@ exports[`modules/manager/cargo/artifacts returns null if unchanged 1`] = `
exports[`modules/manager/cargo/artifacts returns updated Cargo.lock 1`] = `
[
{
"cmd": "cargo update --manifest-path Cargo.toml --workspace",
"cmd": "cargo update --config net.git-fetch-with-cli=true --manifest-path Cargo.toml --workspace",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
Expand All @@ -49,7 +49,7 @@ exports[`modules/manager/cargo/artifacts returns updated Cargo.lock 1`] = `
exports[`modules/manager/cargo/artifacts returns updated Cargo.lock for lockfile maintenance 1`] = `
[
{
"cmd": "cargo update --manifest-path Cargo.toml",
"cmd": "cargo update --config net.git-fetch-with-cli=true --manifest-path Cargo.toml",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
Expand All @@ -72,7 +72,7 @@ exports[`modules/manager/cargo/artifacts returns updated Cargo.lock for lockfile
exports[`modules/manager/cargo/artifacts returns updated workspace Cargo.lock 1`] = `
[
{
"cmd": "cargo update --manifest-path crates/one/Cargo.toml --workspace",
"cmd": "cargo update --config net.git-fetch-with-cli=true --manifest-path crates/one/Cargo.toml --workspace",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
Expand All @@ -95,7 +95,7 @@ exports[`modules/manager/cargo/artifacts returns updated workspace Cargo.lock 1`
exports[`modules/manager/cargo/artifacts updates Cargo.lock based on the packageName, when given 1`] = `
[
{
"cmd": "cargo update --manifest-path Cargo.toml --workspace",
"cmd": "cargo update --config net.git-fetch-with-cli=true --manifest-path Cargo.toml --workspace",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
Expand Down