Skip to content

Commit 877af96

Browse files
committed
spec: impl Display for ImageReference
I want this in a followup patch. Signed-off-by: Colin Walters <[email protected]>
1 parent b075e03 commit 877af96

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/src/spec.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! The definition for host system state.
22
3+
use std::fmt::Display;
4+
5+
use ostree_ext::container::OstreeImageReference;
36
use schemars::JsonSchema;
47
use serde::{Deserialize, Serialize};
58

@@ -149,8 +152,17 @@ impl Default for Host {
149152
}
150153
}
151154

155+
impl Display for ImageReference {
156+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
157+
let ostree_imgref = OstreeImageReference::from(self.clone());
158+
ostree_imgref.fmt(f)
159+
}
160+
}
161+
152162
#[cfg(test)]
153163
mod tests {
164+
use std::str::FromStr;
165+
154166
use super::*;
155167

156168
#[test]
@@ -183,4 +195,13 @@ mod tests {
183195
Some(ImageSignature::OstreeRemote("fedora".into()))
184196
);
185197
}
198+
199+
#[test]
200+
fn test_display_imgref() {
201+
let src = "ostree-unverified-registry:quay.io/example/foo:sometag";
202+
let s = OstreeImageReference::from_str(src).unwrap();
203+
let s = ImageReference::from(s);
204+
let displayed = format!("{s}");
205+
assert_eq!(displayed.as_str(), src);
206+
}
186207
}

0 commit comments

Comments
 (0)