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

1// Generated from definition com.github.openshift.api.build.v1.BinaryBuildSource
2
3/// BinaryBuildSource describes a binary file to be used for the Docker and Source build strategies, where the file will be extracted and used as the build source.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct BinaryBuildSource {
6    /// asFile indicates that the provided binary input should be considered a single file within the build input. For example, specifying "webapp.war" would place the provided binary as `/webapp.war` for the builder. If left empty, the Docker and Source build strategies assume this file is a zip, tar, or tar.gz file and extract it as the source. The custom strategy receives this binary as standard input. This filename may not contain slashes or be '..' or '.'.
7    pub as_file: Option<String>,
8}
9
10impl<'de> serde::Deserialize<'de> for BinaryBuildSource {
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_as_file,
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                            "asFile" => Field::Key_as_file,
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 = BinaryBuildSource;
45
46            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47                f.write_str("BinaryBuildSource")
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_as_file: Option<String> = None;
52
53                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
54                    match key {
55                        Field::Key_as_file => value_as_file = 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(BinaryBuildSource {
61                    as_file: value_as_file,
62                })
63            }
64        }
65
66        deserializer.deserialize_struct(
67            "BinaryBuildSource",
68            &[
69                "asFile",
70            ],
71            Visitor,
72        )
73    }
74}
75
76impl serde::Serialize for BinaryBuildSource {
77    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
78        let mut state = serializer.serialize_struct(
79            "BinaryBuildSource",
80            self.as_file.as_ref().map_or(0, |_| 1),
81        )?;
82        if let Some(value) = &self.as_file {
83            serde::ser::SerializeStruct::serialize_field(&mut state, "asFile", value)?;
84        }
85        serde::ser::SerializeStruct::end(state)
86    }
87}