Skip to content

Commit

Permalink
Add support for setting decryption keys
Browse files Browse the repository at this point in the history
Signed-off-by: Harshal Patil <harpatil@redhat.com>
  • Loading branch information
harche committed Nov 14, 2023
1 parent 929070b commit 598896f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/imageproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ pub struct ImageProxyConfig {
// Equivalent to `skopeo --cert-dir`
pub certificate_directory: Option<PathBuf>,

/// Decryption keys to decrypt an encrypted container image.
/// equivalent to `skopeo copy --decryption-key <path_to_decryption_key> `
pub decryption_keys: Option<Vec<String>>,

/// If set, disable TLS verification. Equivalent to `skopeo --tls-verify=false`.
pub insecure_skip_tls_verification: Option<bool>,

Expand Down Expand Up @@ -208,6 +212,14 @@ impl TryFrom<ImageProxyConfig> for Command {
c.arg("--cert-dir");
c.arg(certificate_directory);
}

if let Some(decryption_keys) = config.decryption_keys {
for decryption_key in &decryption_keys {
c.arg("--decryption-key");
c.arg(decryption_key);
}
}

if config.insecure_skip_tls_verification.unwrap_or_default() {
c.arg("--tls-verify=false");
}
Expand Down Expand Up @@ -555,6 +567,14 @@ mod tests {
.unwrap();
validate(c, &[r"--authfile", "/path/to/authfile"], &[]);

let decryption_key_path = "/path/to/decryption_key";
let c = Command::try_from(ImageProxyConfig {
decryption_keys: Some(vec![decryption_key_path.to_string()]),
..Default::default()
})
.unwrap();
validate(c, &[r"--decryption-key", "/path/to/decryption_key"], &[]);

let c = Command::try_from(ImageProxyConfig {
certificate_directory: Some(PathBuf::from("/path/to/certs")),
..Default::default()
Expand Down

0 comments on commit 598896f

Please sign in to comment.