openshift_openapi/v4_5/api/build/v1/
build_output.rs

1// Generated from definition com.github.openshift.api.build.v1.BuildOutput
2
3/// BuildOutput is input to a build strategy and describes the container image that the strategy should produce.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct BuildOutput {
6    /// imageLabels define a list of labels that are applied to the resulting image. If there are multiple labels with the same name then the last one in the list is used.
7    pub image_labels: Option<Vec<crate::api::build::v1::ImageLabel>>,
8
9    /// PushSecret is the name of a Secret that would be used for setting up the authentication for executing the Docker push to authentication enabled Docker Registry (or Docker Hub).
10    pub push_secret: Option<k8s_openapi::api::core::v1::LocalObjectReference>,
11
12    /// to defines an optional location to push the output of this build to. Kind must be one of 'ImageStreamTag' or 'DockerImage'. This value will be used to look up a container image repository to push to. In the case of an ImageStreamTag, the ImageStreamTag will be looked for in the namespace of the build unless Namespace is specified.
13    pub to: Option<k8s_openapi::api::core::v1::ObjectReference>,
14}
15
16impl<'de> serde::Deserialize<'de> for BuildOutput {
17    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
18        #[allow(non_camel_case_types)]
19        enum Field {
20            Key_image_labels,
21            Key_push_secret,
22            Key_to,
23            Other,
24        }
25
26        impl<'de> serde::Deserialize<'de> for Field {
27            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
28                struct Visitor;
29
30                impl<'de> serde::de::Visitor<'de> for Visitor {
31                    type Value = Field;
32
33                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
34                        f.write_str("field identifier")
35                    }
36
37                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
38                        Ok(match v {
39                            "imageLabels" => Field::Key_image_labels,
40                            "pushSecret" => Field::Key_push_secret,
41                            "to" => Field::Key_to,
42                            _ => Field::Other,
43                        })
44                    }
45                }
46
47                deserializer.deserialize_identifier(Visitor)
48            }
49        }
50
51        struct Visitor;
52
53        impl<'de> serde::de::Visitor<'de> for Visitor {
54            type Value = BuildOutput;
55
56            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
57                f.write_str("BuildOutput")
58            }
59
60            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
61                let mut value_image_labels: Option<Vec<crate::api::build::v1::ImageLabel>> = None;
62                let mut value_push_secret: Option<k8s_openapi::api::core::v1::LocalObjectReference> = None;
63                let mut value_to: Option<k8s_openapi::api::core::v1::ObjectReference> = None;
64
65                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
66                    match key {
67                        Field::Key_image_labels => value_image_labels = serde::de::MapAccess::next_value(&mut map)?,
68                        Field::Key_push_secret => value_push_secret = serde::de::MapAccess::next_value(&mut map)?,
69                        Field::Key_to => value_to = serde::de::MapAccess::next_value(&mut map)?,
70                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
71                    }
72                }
73
74                Ok(BuildOutput {
75                    image_labels: value_image_labels,
76                    push_secret: value_push_secret,
77                    to: value_to,
78                })
79            }
80        }
81
82        deserializer.deserialize_struct(
83            "BuildOutput",
84            &[
85                "imageLabels",
86                "pushSecret",
87                "to",
88            ],
89            Visitor,
90        )
91    }
92}
93
94impl serde::Serialize for BuildOutput {
95    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
96        let mut state = serializer.serialize_struct(
97            "BuildOutput",
98            self.image_labels.as_ref().map_or(0, |_| 1) +
99            self.push_secret.as_ref().map_or(0, |_| 1) +
100            self.to.as_ref().map_or(0, |_| 1),
101        )?;
102        if let Some(value) = &self.image_labels {
103            serde::ser::SerializeStruct::serialize_field(&mut state, "imageLabels", value)?;
104        }
105        if let Some(value) = &self.push_secret {
106            serde::ser::SerializeStruct::serialize_field(&mut state, "pushSecret", value)?;
107        }
108        if let Some(value) = &self.to {
109            serde::ser::SerializeStruct::serialize_field(&mut state, "to", value)?;
110        }
111        serde::ser::SerializeStruct::end(state)
112    }
113}