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

1// Generated from definition com.github.openshift.api.build.v1.ConfigMapBuildSource
2
3/// ConfigMapBuildSource describes a configmap and its destination directory that will be used only at the build time. The content of the configmap referenced here will be copied into the destination directory instead of mounting.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ConfigMapBuildSource {
6    /// configMap is a reference to an existing configmap that you want to use in your build.
7    pub config_map: k8s_openapi::api::core::v1::LocalObjectReference,
8
9    /// destinationDir is the directory where the files from the configmap should be available for the build time. For the Source build strategy, these will be injected into a container where the assemble script runs. For the container image build strategy, these will be copied into the build directory, where the Dockerfile is located, so users can ADD or COPY them during container image build.
10    pub destination_dir: Option<String>,
11}
12
13impl<'de> serde::Deserialize<'de> for ConfigMapBuildSource {
14    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
15        #[allow(non_camel_case_types)]
16        enum Field {
17            Key_config_map,
18            Key_destination_dir,
19            Other,
20        }
21
22        impl<'de> serde::Deserialize<'de> for Field {
23            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
24                struct Visitor;
25
26                impl<'de> serde::de::Visitor<'de> for Visitor {
27                    type Value = Field;
28
29                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30                        f.write_str("field identifier")
31                    }
32
33                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
34                        Ok(match v {
35                            "configMap" => Field::Key_config_map,
36                            "destinationDir" => Field::Key_destination_dir,
37                            _ => Field::Other,
38                        })
39                    }
40                }
41
42                deserializer.deserialize_identifier(Visitor)
43            }
44        }
45
46        struct Visitor;
47
48        impl<'de> serde::de::Visitor<'de> for Visitor {
49            type Value = ConfigMapBuildSource;
50
51            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
52                f.write_str("ConfigMapBuildSource")
53            }
54
55            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
56                let mut value_config_map: Option<k8s_openapi::api::core::v1::LocalObjectReference> = None;
57                let mut value_destination_dir: Option<String> = None;
58
59                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
60                    match key {
61                        Field::Key_config_map => value_config_map = Some(serde::de::MapAccess::next_value(&mut map)?),
62                        Field::Key_destination_dir => value_destination_dir = serde::de::MapAccess::next_value(&mut map)?,
63                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
64                    }
65                }
66
67                Ok(ConfigMapBuildSource {
68                    config_map: value_config_map.ok_or_else(|| serde::de::Error::missing_field("configMap"))?,
69                    destination_dir: value_destination_dir,
70                })
71            }
72        }
73
74        deserializer.deserialize_struct(
75            "ConfigMapBuildSource",
76            &[
77                "configMap",
78                "destinationDir",
79            ],
80            Visitor,
81        )
82    }
83}
84
85impl serde::Serialize for ConfigMapBuildSource {
86    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
87        let mut state = serializer.serialize_struct(
88            "ConfigMapBuildSource",
89            1 +
90            self.destination_dir.as_ref().map_or(0, |_| 1),
91        )?;
92        serde::ser::SerializeStruct::serialize_field(&mut state, "configMap", &self.config_map)?;
93        if let Some(value) = &self.destination_dir {
94            serde::ser::SerializeStruct::serialize_field(&mut state, "destinationDir", value)?;
95        }
96        serde::ser::SerializeStruct::end(state)
97    }
98}