Skip to content

Commit 411b11c

Browse files
authored
Complete IndexConfig according to current Cargo reference (#90)
1 parent a8b1d08 commit 411b11c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/index.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@ pub use crate::utils::flock::FileLock;
3333

3434
/// Global configuration of an index, reflecting the [contents of config.json](https://doc.rust-lang.org/cargo/reference/registries.html#index-format).
3535
#[derive(Eq, PartialEq, PartialOrd, Ord, Clone, Debug, serde::Deserialize, serde::Serialize)]
36+
#[serde(rename_all = "kebab-case")]
3637
pub struct IndexConfig {
3738
/// Pattern for creating download URLs. See [`Self::download_url`].
3839
pub dl: String,
40+
#[serde(default)]
3941
/// Base URL for publishing, etc.
4042
pub api: Option<String>,
43+
#[serde(default)]
44+
auth_required: bool,
4145
}
4246

4347
impl IndexConfig {
@@ -189,6 +193,7 @@ mod test {
189193
let crates_io = IndexConfig {
190194
dl: "https://crates.io/api/v1/crates".into(),
191195
api: Some("https://crates.io".into()),
196+
auth_required: false,
192197
};
193198

194199
assert_eq!(
@@ -215,6 +220,7 @@ mod test {
215220
let ic = IndexConfig {
216221
dl: "https://dl.cloudsmith.io/public/embark/deny/cargo/{crate}-{version}.crate".into(),
217222
api: Some("https://cargo.cloudsmith.io/embark/deny".into()),
223+
auth_required: false,
218224
};
219225

220226
assert_eq!(
@@ -242,6 +248,7 @@ mod test {
242248
let ic = IndexConfig {
243249
dl: "https://complex.io/ohhi/embark/rust/cargo/{lowerprefix}/{crate}/{crate}/{prefix}-{version}".into(),
244250
api: None,
251+
auth_required: false,
245252
};
246253

247254
assert_eq!(

0 commit comments

Comments
 (0)