openshift_openapi/v4_5/api/image/v1/
image_lookup_policy.rs

1// Generated from definition com.github.openshift.api.image.v1.ImageLookupPolicy
2
3/// ImageLookupPolicy describes how an image stream can be used to override the image references used by pods, builds, and other resources in a namespace.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ImageLookupPolicy {
6    /// local will change the docker short image references (like "mysql" or "php:latest") on objects in this namespace to the image ID whenever they match this image stream, instead of reaching out to a remote registry. The name will be fully qualified to an image ID if found. The tag's referencePolicy is taken into account on the replaced value. Only works within the current namespace.
7    pub local: bool,
8}
9
10impl<'de> serde::Deserialize<'de> for ImageLookupPolicy {
11    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
12        #[allow(non_camel_case_types)]
13        enum Field {
14            Key_local,
15            Other,
16        }
17
18        impl<'de> serde::Deserialize<'de> for Field {
19            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
20                struct Visitor;
21
22                impl<'de> serde::de::Visitor<'de> for Visitor {
23                    type Value = Field;
24
25                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26                        f.write_str("field identifier")
27                    }
28
29                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
30                        Ok(match v {
31                            "local" => Field::Key_local,
32                            _ => Field::Other,
33                        })
34                    }
35                }
36
37                deserializer.deserialize_identifier(Visitor)
38            }
39        }
40
41        struct Visitor;
42
43        impl<'de> serde::de::Visitor<'de> for Visitor {
44            type Value = ImageLookupPolicy;
45
46            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47                f.write_str("ImageLookupPolicy")
48            }
49
50            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
51                let mut value_local: Option<bool> = None;
52
53                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
54                    match key {
55                        Field::Key_local => value_local = Some(serde::de::MapAccess::next_value(&mut map)?),
56                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
57                    }
58                }
59
60                Ok(ImageLookupPolicy {
61                    local: value_local.ok_or_else(|| serde::de::Error::missing_field("local"))?,
62                })
63            }
64        }
65
66        deserializer.deserialize_struct(
67            "ImageLookupPolicy",
68            &[
69                "local",
70            ],
71            Visitor,
72        )
73    }
74}
75
76impl serde::Serialize for ImageLookupPolicy {
77    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
78        let mut state = serializer.serialize_struct(
79            "ImageLookupPolicy",
80            1,
81        )?;
82        serde::ser::SerializeStruct::serialize_field(&mut state, "local", &self.local)?;
83        serde::ser::SerializeStruct::end(state)
84    }
85}