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

1// Generated from definition com.github.openshift.api.build.v1.GitBuildSource
2
3/// GitBuildSource defines the parameters of a Git SCM
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct GitBuildSource {
6    /// httpProxy is a proxy used to reach the git repository over http
7    pub http_proxy: Option<String>,
8
9    /// httpsProxy is a proxy used to reach the git repository over https
10    pub https_proxy: Option<String>,
11
12    /// noProxy is the list of domains for which the proxy should not be used
13    pub no_proxy: Option<String>,
14
15    /// ref is the branch/tag/ref to build.
16    pub ref_: Option<String>,
17
18    /// uri points to the source that will be built. The structure of the source will depend on the type of build to run
19    pub uri: String,
20}
21
22impl<'de> serde::Deserialize<'de> for GitBuildSource {
23    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
24        #[allow(non_camel_case_types)]
25        enum Field {
26            Key_http_proxy,
27            Key_https_proxy,
28            Key_no_proxy,
29            Key_ref_,
30            Key_uri,
31            Other,
32        }
33
34        impl<'de> serde::Deserialize<'de> for Field {
35            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
36                struct Visitor;
37
38                impl<'de> serde::de::Visitor<'de> for Visitor {
39                    type Value = Field;
40
41                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42                        f.write_str("field identifier")
43                    }
44
45                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
46                        Ok(match v {
47                            "httpProxy" => Field::Key_http_proxy,
48                            "httpsProxy" => Field::Key_https_proxy,
49                            "noProxy" => Field::Key_no_proxy,
50                            "ref" => Field::Key_ref_,
51                            "uri" => Field::Key_uri,
52                            _ => Field::Other,
53                        })
54                    }
55                }
56
57                deserializer.deserialize_identifier(Visitor)
58            }
59        }
60
61        struct Visitor;
62
63        impl<'de> serde::de::Visitor<'de> for Visitor {
64            type Value = GitBuildSource;
65
66            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
67                f.write_str("GitBuildSource")
68            }
69
70            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
71                let mut value_http_proxy: Option<String> = None;
72                let mut value_https_proxy: Option<String> = None;
73                let mut value_no_proxy: Option<String> = None;
74                let mut value_ref_: Option<String> = None;
75                let mut value_uri: Option<String> = None;
76
77                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
78                    match key {
79                        Field::Key_http_proxy => value_http_proxy = serde::de::MapAccess::next_value(&mut map)?,
80                        Field::Key_https_proxy => value_https_proxy = serde::de::MapAccess::next_value(&mut map)?,
81                        Field::Key_no_proxy => value_no_proxy = serde::de::MapAccess::next_value(&mut map)?,
82                        Field::Key_ref_ => value_ref_ = serde::de::MapAccess::next_value(&mut map)?,
83                        Field::Key_uri => value_uri = Some(serde::de::MapAccess::next_value(&mut map)?),
84                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
85                    }
86                }
87
88                Ok(GitBuildSource {
89                    http_proxy: value_http_proxy,
90                    https_proxy: value_https_proxy,
91                    no_proxy: value_no_proxy,
92                    ref_: value_ref_,
93                    uri: value_uri.ok_or_else(|| serde::de::Error::missing_field("uri"))?,
94                })
95            }
96        }
97
98        deserializer.deserialize_struct(
99            "GitBuildSource",
100            &[
101                "httpProxy",
102                "httpsProxy",
103                "noProxy",
104                "ref",
105                "uri",
106            ],
107            Visitor,
108        )
109    }
110}
111
112impl serde::Serialize for GitBuildSource {
113    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
114        let mut state = serializer.serialize_struct(
115            "GitBuildSource",
116            1 +
117            self.http_proxy.as_ref().map_or(0, |_| 1) +
118            self.https_proxy.as_ref().map_or(0, |_| 1) +
119            self.no_proxy.as_ref().map_or(0, |_| 1) +
120            self.ref_.as_ref().map_or(0, |_| 1),
121        )?;
122        if let Some(value) = &self.http_proxy {
123            serde::ser::SerializeStruct::serialize_field(&mut state, "httpProxy", value)?;
124        }
125        if let Some(value) = &self.https_proxy {
126            serde::ser::SerializeStruct::serialize_field(&mut state, "httpsProxy", value)?;
127        }
128        if let Some(value) = &self.no_proxy {
129            serde::ser::SerializeStruct::serialize_field(&mut state, "noProxy", value)?;
130        }
131        if let Some(value) = &self.ref_ {
132            serde::ser::SerializeStruct::serialize_field(&mut state, "ref", value)?;
133        }
134        serde::ser::SerializeStruct::serialize_field(&mut state, "uri", &self.uri)?;
135        serde::ser::SerializeStruct::end(state)
136    }
137}