Skip to content

Commit e89694b

Browse files
authored
Merge pull request #61 from harche/decryption_keys
Add support for setting decryption keys
2 parents 929070b + 598896f commit e89694b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/imageproxy.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ pub struct ImageProxyConfig {
119119
// Equivalent to `skopeo --cert-dir`
120120
pub certificate_directory: Option<PathBuf>,
121121

122+
/// Decryption keys to decrypt an encrypted container image.
123+
/// equivalent to `skopeo copy --decryption-key <path_to_decryption_key> `
124+
pub decryption_keys: Option<Vec<String>>,
125+
122126
/// If set, disable TLS verification. Equivalent to `skopeo --tls-verify=false`.
123127
pub insecure_skip_tls_verification: Option<bool>,
124128

@@ -208,6 +212,14 @@ impl TryFrom<ImageProxyConfig> for Command {
208212
c.arg("--cert-dir");
209213
c.arg(certificate_directory);
210214
}
215+
216+
if let Some(decryption_keys) = config.decryption_keys {
217+
for decryption_key in &decryption_keys {
218+
c.arg("--decryption-key");
219+
c.arg(decryption_key);
220+
}
221+
}
222+
211223
if config.insecure_skip_tls_verification.unwrap_or_default() {
212224
c.arg("--tls-verify=false");
213225
}
@@ -555,6 +567,14 @@ mod tests {
555567
.unwrap();
556568
validate(c, &[r"--authfile", "/path/to/authfile"], &[]);
557569

570+
let decryption_key_path = "/path/to/decryption_key";
571+
let c = Command::try_from(ImageProxyConfig {
572+
decryption_keys: Some(vec![decryption_key_path.to_string()]),
573+
..Default::default()
574+
})
575+
.unwrap();
576+
validate(c, &[r"--decryption-key", "/path/to/decryption_key"], &[]);
577+
558578
let c = Command::try_from(ImageProxyConfig {
559579
certificate_directory: Some(PathBuf::from("/path/to/certs")),
560580
..Default::default()

0 commit comments

Comments
 (0)