mirror of
https://github.com/imjasonh/krust
synced 2026-07-13 17:07:26 +00:00
feat: Fork oci-distribution and add enhanced features
- Fork oci-distribution v0.11.0 into vendor/oci-distribution - Add get_image_platforms() method for proper platform detection - Support fetching config blobs for single-platform images - Add OAuth2/Bearer token authentication support - Add push_manifest_and_get_digest() for reliable digest extraction - Update krust to use the forked version with enhanced features
This commit is contained in:
parent
e2c4b6b14c
commit
7827c25d9b
4 changed files with 84 additions and 83 deletions
|
|
@ -83,6 +83,16 @@ impl AuthConfig {
|
|||
return RegistryAuth::Anonymous;
|
||||
}
|
||||
|
||||
// Check for bearer tokens first
|
||||
if let Some(token) = &self.registry_token {
|
||||
return RegistryAuth::Bearer(token.clone());
|
||||
}
|
||||
|
||||
if let Some(token) = &self.identity_token {
|
||||
return RegistryAuth::Bearer(token.clone());
|
||||
}
|
||||
|
||||
// Then check for basic auth
|
||||
if let (Some(username), Some(password)) = (&self.username, &self.password) {
|
||||
return RegistryAuth::Basic(username.clone(), password.clone());
|
||||
}
|
||||
|
|
@ -234,4 +244,30 @@ mod unit_tests {
|
|||
let header = auth.to_authorization_header().unwrap().unwrap();
|
||||
assert_eq!(header, "Bearer token123");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_auth_config_to_registry_auth() {
|
||||
use oci_distribution::secrets::RegistryAuth;
|
||||
|
||||
// Test anonymous
|
||||
let auth = AuthConfig::anonymous();
|
||||
assert_eq!(auth.to_registry_auth(), RegistryAuth::Anonymous);
|
||||
|
||||
// Test basic auth
|
||||
let auth = AuthConfig::new("user".to_string(), "pass".to_string());
|
||||
assert_eq!(
|
||||
auth.to_registry_auth(),
|
||||
RegistryAuth::Basic("user".to_string(), "pass".to_string())
|
||||
);
|
||||
|
||||
// Test bearer token
|
||||
let auth = AuthConfig {
|
||||
registry_token: Some("token123".to_string()),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(
|
||||
auth.to_registry_auth(),
|
||||
RegistryAuth::Bearer("token123".to_string())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue