Add username
This commit is contained in:
parent
71654a6fe2
commit
07e582e2be
9 changed files with 358 additions and 192 deletions
|
|
@ -177,6 +177,7 @@ async fn test_ghcr_authentication_e2e() {
|
|||
RegistryConfig {
|
||||
url: "https://registry-1.docker.io".to_string(),
|
||||
auth_token: None,
|
||||
username: None,
|
||||
},
|
||||
);
|
||||
registries.insert(
|
||||
|
|
@ -184,6 +185,7 @@ async fn test_ghcr_authentication_e2e() {
|
|||
RegistryConfig {
|
||||
url: "https://ghcr.io".to_string(),
|
||||
auth_token: Some(github_token),
|
||||
username: None,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
@ -214,6 +216,7 @@ fn create_test_config() -> Config {
|
|||
RegistryConfig {
|
||||
url: "https://registry-1.docker.io".to_string(),
|
||||
auth_token: None,
|
||||
username: None,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -488,6 +488,7 @@ fn create_test_config() -> Config {
|
|||
RegistryConfig {
|
||||
url: "https://registry-1.docker.io".to_string(),
|
||||
auth_token: None,
|
||||
username: None,
|
||||
},
|
||||
);
|
||||
registries.insert(
|
||||
|
|
@ -495,6 +496,7 @@ fn create_test_config() -> Config {
|
|||
RegistryConfig {
|
||||
url: "https://ghcr.io".to_string(),
|
||||
auth_token: None,
|
||||
username: None,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@ fn test_registry_configuration() {
|
|||
RegistryConfig {
|
||||
url: "https://simple.registry.com".to_string(),
|
||||
auth_token: None,
|
||||
username: None,
|
||||
},
|
||||
);
|
||||
registries.insert(
|
||||
|
|
@ -190,6 +191,7 @@ fn test_registry_configuration() {
|
|||
RegistryConfig {
|
||||
url: "https://auth.registry.com".to_string(),
|
||||
auth_token: Some("secret-token".to_string()),
|
||||
username: None,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
@ -224,7 +226,11 @@ registries: {}
|
|||
assert!(config.compose_paths.is_empty());
|
||||
assert!(config.ignore_images.is_empty());
|
||||
assert!(config.schedule.is_empty());
|
||||
assert!(config.registries.is_empty());
|
||||
// The other fields stay as written, but the default registries are restored:
|
||||
// resolving an image now goes through its registry entry, so an empty map
|
||||
// would make every service fail with "Unknown registry" rather than express
|
||||
// any useful intent.
|
||||
assert!(config.registries.contains_key("docker.io"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -283,3 +289,50 @@ registries:
|
|||
.auth_token
|
||||
.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_load_restores_default_registries_omitted_by_the_config_file() {
|
||||
// A `registries` block replaces the defaults instead of merging, so a file
|
||||
// listing only a private registry must still be able to resolve Docker Hub:
|
||||
// every `nginx:1.2.3`-style image in the compose files depends on it.
|
||||
let yaml_config = r#"
|
||||
compose_paths: []
|
||||
schedule: "0 0 2 * * *"
|
||||
registries:
|
||||
private.registry.com:
|
||||
url: "https://private.registry.com"
|
||||
"#;
|
||||
|
||||
let mut temp_file = NamedTempFile::new().unwrap();
|
||||
temp_file.write_all(yaml_config.as_bytes()).unwrap();
|
||||
temp_file.flush().unwrap();
|
||||
|
||||
let config = Config::load(temp_file.path().to_path_buf()).unwrap();
|
||||
assert_eq!(
|
||||
config.registries["docker.io"].url,
|
||||
"https://registry-1.docker.io"
|
||||
);
|
||||
assert!(config.registries.contains_key("private.registry.com"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_load_keeps_explicit_registry_overrides() {
|
||||
let yaml_config = r#"
|
||||
compose_paths: []
|
||||
schedule: "0 0 2 * * *"
|
||||
registries:
|
||||
docker.io:
|
||||
url: "https://mirror.internal"
|
||||
username: "andras"
|
||||
auth_token: "secret"
|
||||
"#;
|
||||
|
||||
let mut temp_file = NamedTempFile::new().unwrap();
|
||||
temp_file.write_all(yaml_config.as_bytes()).unwrap();
|
||||
temp_file.flush().unwrap();
|
||||
|
||||
let config = Config::load(temp_file.path().to_path_buf()).unwrap();
|
||||
let docker_io = &config.registries["docker.io"];
|
||||
assert_eq!(docker_io.url, "https://mirror.internal");
|
||||
assert_eq!(docker_io.username.as_deref(), Some("andras"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -288,6 +288,7 @@ fn create_test_config() -> Config {
|
|||
RegistryConfig {
|
||||
url: "https://registry-1.docker.io".to_string(),
|
||||
auth_token: None,
|
||||
username: None,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue