agent: image: Set image-rs auth config

If the agent-config has a value for `image_registry_auth`,
Then pass this to the image-rs client and enable auth mode too

Fixes: #8122

Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
This commit is contained in:
stevenhorsman
2024-06-25 10:40:14 +01:00
committed by Wainer dos Santos Moschetta
parent 265322990a
commit 7cc81ce867

View File

@@ -54,9 +54,16 @@ pub struct ImageService {
impl ImageService { impl ImageService {
pub fn new() -> Self { pub fn new() -> Self {
Self { let mut image_client = ImageClient::new(PathBuf::from(KATA_IMAGE_WORK_DIR));
image_client: ImageClient::new(PathBuf::from(KATA_IMAGE_WORK_DIR)), #[cfg(feature = "guest-pull")]
if !AGENT_CONFIG.image_registry_auth.is_empty() {
let registry_auth = &AGENT_CONFIG.image_registry_auth;
debug!(sl(), "Set registry auth file {:?}", registry_auth);
image_client.config.file_paths.auth_file = registry_auth.clone();
image_client.config.auth = true;
} }
Self { image_client }
} }
/// pause image is packaged in rootfs /// pause image is packaged in rootfs