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

1// Generated from definition com.github.openshift.api.build.v1.BuildSource
2
3/// BuildSource is the SCM used for the build.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct BuildSource {
6    /// binary builds accept a binary as their input. The binary is generally assumed to be a tar, gzipped tar, or zip file depending on the strategy. For container image builds, this is the build context and an optional Dockerfile may be specified to override any Dockerfile in the build context. For Source builds, this is assumed to be an archive as described above. For Source and container image builds, if binary.asFile is set the build will receive a directory with a single file. contextDir may be used when an archive is provided. Custom builds will receive this binary as input on STDIN.
7    pub binary: Option<crate::api::build::v1::BinaryBuildSource>,
8
9    /// configMaps represents a list of configMaps and their destinations that will be used for the build.
10    pub config_maps: Option<Vec<crate::api::build::v1::ConfigMapBuildSource>>,
11
12    /// contextDir specifies the sub-directory where the source code for the application exists. This allows to have buildable sources in directory other than root of repository.
13    pub context_dir: Option<String>,
14
15    /// dockerfile is the raw contents of a Dockerfile which should be built. When this option is specified, the FROM may be modified based on your strategy base image and additional ENV stanzas from your strategy environment will be added after the FROM, but before the rest of your Dockerfile stanzas. The Dockerfile source type may be used with other options like git - in those cases the Git repo will have any innate Dockerfile replaced in the context dir.
16    pub dockerfile: Option<String>,
17
18    /// git contains optional information about git build source
19    pub git: Option<crate::api::build::v1::GitBuildSource>,
20
21    /// images describes a set of images to be used to provide source for the build
22    pub images: Option<Vec<crate::api::build::v1::ImageSource>>,
23
24    /// secrets represents a list of secrets and their destinations that will be used only for the build.
25    pub secrets: Option<Vec<crate::api::build::v1::SecretBuildSource>>,
26
27    /// sourceSecret is the name of a Secret that would be used for setting up the authentication for cloning private repository. The secret contains valid credentials for remote repository, where the data's key represent the authentication method to be used and value is the base64 encoded credentials. Supported auth methods are: ssh-privatekey.
28    pub source_secret: Option<k8s_openapi::api::core::v1::LocalObjectReference>,
29
30    /// type of build input to accept
31    pub type_: String,
32}
33
34impl<'de> serde::Deserialize<'de> for BuildSource {
35    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
36        #[allow(non_camel_case_types)]
37        enum Field {
38            Key_binary,
39            Key_config_maps,
40            Key_context_dir,
41            Key_dockerfile,
42            Key_git,
43            Key_images,
44            Key_secrets,
45            Key_source_secret,
46            Key_type_,
47            Other,
48        }
49
50        impl<'de> serde::Deserialize<'de> for Field {
51            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
52                struct Visitor;
53
54                impl<'de> serde::de::Visitor<'de> for Visitor {
55                    type Value = Field;
56
57                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
58                        f.write_str("field identifier")
59                    }
60
61                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
62                        Ok(match v {
63                            "binary" => Field::Key_binary,
64                            "configMaps" => Field::Key_config_maps,
65                            "contextDir" => Field::Key_context_dir,
66                            "dockerfile" => Field::Key_dockerfile,
67                            "git" => Field::Key_git,
68                            "images" => Field::Key_images,
69                            "secrets" => Field::Key_secrets,
70                            "sourceSecret" => Field::Key_source_secret,
71                            "type" => Field::Key_type_,
72                            _ => Field::Other,
73                        })
74                    }
75                }
76
77                deserializer.deserialize_identifier(Visitor)
78            }
79        }
80
81        struct Visitor;
82
83        impl<'de> serde::de::Visitor<'de> for Visitor {
84            type Value = BuildSource;
85
86            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
87                f.write_str("BuildSource")
88            }
89
90            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
91                let mut value_binary: Option<crate::api::build::v1::BinaryBuildSource> = None;
92                let mut value_config_maps: Option<Vec<crate::api::build::v1::ConfigMapBuildSource>> = None;
93                let mut value_context_dir: Option<String> = None;
94                let mut value_dockerfile: Option<String> = None;
95                let mut value_git: Option<crate::api::build::v1::GitBuildSource> = None;
96                let mut value_images: Option<Vec<crate::api::build::v1::ImageSource>> = None;
97                let mut value_secrets: Option<Vec<crate::api::build::v1::SecretBuildSource>> = None;
98                let mut value_source_secret: Option<k8s_openapi::api::core::v1::LocalObjectReference> = None;
99                let mut value_type_: Option<String> = None;
100
101                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
102                    match key {
103                        Field::Key_binary => value_binary = serde::de::MapAccess::next_value(&mut map)?,
104                        Field::Key_config_maps => value_config_maps = serde::de::MapAccess::next_value(&mut map)?,
105                        Field::Key_context_dir => value_context_dir = serde::de::MapAccess::next_value(&mut map)?,
106                        Field::Key_dockerfile => value_dockerfile = serde::de::MapAccess::next_value(&mut map)?,
107                        Field::Key_git => value_git = serde::de::MapAccess::next_value(&mut map)?,
108                        Field::Key_images => value_images = serde::de::MapAccess::next_value(&mut map)?,
109                        Field::Key_secrets => value_secrets = serde::de::MapAccess::next_value(&mut map)?,
110                        Field::Key_source_secret => value_source_secret = serde::de::MapAccess::next_value(&mut map)?,
111                        Field::Key_type_ => value_type_ = Some(serde::de::MapAccess::next_value(&mut map)?),
112                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
113                    }
114                }
115
116                Ok(BuildSource {
117                    binary: value_binary,
118                    config_maps: value_config_maps,
119                    context_dir: value_context_dir,
120                    dockerfile: value_dockerfile,
121                    git: value_git,
122                    images: value_images,
123                    secrets: value_secrets,
124                    source_secret: value_source_secret,
125                    type_: value_type_.ok_or_else(|| serde::de::Error::missing_field("type"))?,
126                })
127            }
128        }
129
130        deserializer.deserialize_struct(
131            "BuildSource",
132            &[
133                "binary",
134                "configMaps",
135                "contextDir",
136                "dockerfile",
137                "git",
138                "images",
139                "secrets",
140                "sourceSecret",
141                "type",
142            ],
143            Visitor,
144        )
145    }
146}
147
148impl serde::Serialize for BuildSource {
149    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
150        let mut state = serializer.serialize_struct(
151            "BuildSource",
152            1 +
153            self.binary.as_ref().map_or(0, |_| 1) +
154            self.config_maps.as_ref().map_or(0, |_| 1) +
155            self.context_dir.as_ref().map_or(0, |_| 1) +
156            self.dockerfile.as_ref().map_or(0, |_| 1) +
157            self.git.as_ref().map_or(0, |_| 1) +
158            self.images.as_ref().map_or(0, |_| 1) +
159            self.secrets.as_ref().map_or(0, |_| 1) +
160            self.source_secret.as_ref().map_or(0, |_| 1),
161        )?;
162        if let Some(value) = &self.binary {
163            serde::ser::SerializeStruct::serialize_field(&mut state, "binary", value)?;
164        }
165        if let Some(value) = &self.config_maps {
166            serde::ser::SerializeStruct::serialize_field(&mut state, "configMaps", value)?;
167        }
168        if let Some(value) = &self.context_dir {
169            serde::ser::SerializeStruct::serialize_field(&mut state, "contextDir", value)?;
170        }
171        if let Some(value) = &self.dockerfile {
172            serde::ser::SerializeStruct::serialize_field(&mut state, "dockerfile", value)?;
173        }
174        if let Some(value) = &self.git {
175            serde::ser::SerializeStruct::serialize_field(&mut state, "git", value)?;
176        }
177        if let Some(value) = &self.images {
178            serde::ser::SerializeStruct::serialize_field(&mut state, "images", value)?;
179        }
180        if let Some(value) = &self.secrets {
181            serde::ser::SerializeStruct::serialize_field(&mut state, "secrets", value)?;
182        }
183        if let Some(value) = &self.source_secret {
184            serde::ser::SerializeStruct::serialize_field(&mut state, "sourceSecret", value)?;
185        }
186        serde::ser::SerializeStruct::serialize_field(&mut state, "type", &self.type_)?;
187        serde::ser::SerializeStruct::end(state)
188    }
189}