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

1// Generated from definition com.github.openshift.api.build.v1.DockerBuildStrategy
2
3/// DockerBuildStrategy defines input parameters specific to container image build.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DockerBuildStrategy {
6    /// buildArgs contains build arguments that will be resolved in the Dockerfile.  See https://docs.docker.com/engine/reference/builder/#/arg for more details.
7    pub build_args: Option<Vec<k8s_openapi::api::core::v1::EnvVar>>,
8
9    /// dockerfilePath is the path of the Dockerfile that will be used to build the container image, relative to the root of the context (contextDir).
10    pub dockerfile_path: Option<String>,
11
12    /// env contains additional environment variables you want to pass into a builder container.
13    pub env: Option<Vec<k8s_openapi::api::core::v1::EnvVar>>,
14
15    /// forcePull describes if the builder should pull the images from registry prior to building.
16    pub force_pull: Option<bool>,
17
18    /// from is reference to an DockerImage, ImageStreamTag, or ImageStreamImage from which the container image should be pulled the resulting image will be used in the FROM line of the Dockerfile for this build.
19    pub from: Option<k8s_openapi::api::core::v1::ObjectReference>,
20
21    /// imageOptimizationPolicy describes what optimizations the system can use when building images to reduce the final size or time spent building the image. The default policy is 'None' which means the final build image will be equivalent to an image created by the container image build API. The experimental policy 'SkipLayers' will avoid commiting new layers in between each image step, and will fail if the Dockerfile cannot provide compatibility with the 'None' policy. An additional experimental policy 'SkipLayersAndWarn' is the same as 'SkipLayers' but simply warns if compatibility cannot be preserved.
22    pub image_optimization_policy: Option<String>,
23
24    /// noCache if set to true indicates that the container image build must be executed with the --no-cache=true flag
25    pub no_cache: Option<bool>,
26
27    /// pullSecret is the name of a Secret that would be used for setting up the authentication for pulling the container images from the private Docker registries
28    pub pull_secret: Option<k8s_openapi::api::core::v1::LocalObjectReference>,
29}
30
31impl<'de> serde::Deserialize<'de> for DockerBuildStrategy {
32    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
33        #[allow(non_camel_case_types)]
34        enum Field {
35            Key_build_args,
36            Key_dockerfile_path,
37            Key_env,
38            Key_force_pull,
39            Key_from,
40            Key_image_optimization_policy,
41            Key_no_cache,
42            Key_pull_secret,
43            Other,
44        }
45
46        impl<'de> serde::Deserialize<'de> for Field {
47            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
48                struct Visitor;
49
50                impl<'de> serde::de::Visitor<'de> for Visitor {
51                    type Value = Field;
52
53                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
54                        f.write_str("field identifier")
55                    }
56
57                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
58                        Ok(match v {
59                            "buildArgs" => Field::Key_build_args,
60                            "dockerfilePath" => Field::Key_dockerfile_path,
61                            "env" => Field::Key_env,
62                            "forcePull" => Field::Key_force_pull,
63                            "from" => Field::Key_from,
64                            "imageOptimizationPolicy" => Field::Key_image_optimization_policy,
65                            "noCache" => Field::Key_no_cache,
66                            "pullSecret" => Field::Key_pull_secret,
67                            _ => Field::Other,
68                        })
69                    }
70                }
71
72                deserializer.deserialize_identifier(Visitor)
73            }
74        }
75
76        struct Visitor;
77
78        impl<'de> serde::de::Visitor<'de> for Visitor {
79            type Value = DockerBuildStrategy;
80
81            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
82                f.write_str("DockerBuildStrategy")
83            }
84
85            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
86                let mut value_build_args: Option<Vec<k8s_openapi::api::core::v1::EnvVar>> = None;
87                let mut value_dockerfile_path: Option<String> = None;
88                let mut value_env: Option<Vec<k8s_openapi::api::core::v1::EnvVar>> = None;
89                let mut value_force_pull: Option<bool> = None;
90                let mut value_from: Option<k8s_openapi::api::core::v1::ObjectReference> = None;
91                let mut value_image_optimization_policy: Option<String> = None;
92                let mut value_no_cache: Option<bool> = None;
93                let mut value_pull_secret: Option<k8s_openapi::api::core::v1::LocalObjectReference> = None;
94
95                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
96                    match key {
97                        Field::Key_build_args => value_build_args = serde::de::MapAccess::next_value(&mut map)?,
98                        Field::Key_dockerfile_path => value_dockerfile_path = serde::de::MapAccess::next_value(&mut map)?,
99                        Field::Key_env => value_env = serde::de::MapAccess::next_value(&mut map)?,
100                        Field::Key_force_pull => value_force_pull = serde::de::MapAccess::next_value(&mut map)?,
101                        Field::Key_from => value_from = serde::de::MapAccess::next_value(&mut map)?,
102                        Field::Key_image_optimization_policy => value_image_optimization_policy = serde::de::MapAccess::next_value(&mut map)?,
103                        Field::Key_no_cache => value_no_cache = serde::de::MapAccess::next_value(&mut map)?,
104                        Field::Key_pull_secret => value_pull_secret = serde::de::MapAccess::next_value(&mut map)?,
105                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
106                    }
107                }
108
109                Ok(DockerBuildStrategy {
110                    build_args: value_build_args,
111                    dockerfile_path: value_dockerfile_path,
112                    env: value_env,
113                    force_pull: value_force_pull,
114                    from: value_from,
115                    image_optimization_policy: value_image_optimization_policy,
116                    no_cache: value_no_cache,
117                    pull_secret: value_pull_secret,
118                })
119            }
120        }
121
122        deserializer.deserialize_struct(
123            "DockerBuildStrategy",
124            &[
125                "buildArgs",
126                "dockerfilePath",
127                "env",
128                "forcePull",
129                "from",
130                "imageOptimizationPolicy",
131                "noCache",
132                "pullSecret",
133            ],
134            Visitor,
135        )
136    }
137}
138
139impl serde::Serialize for DockerBuildStrategy {
140    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
141        let mut state = serializer.serialize_struct(
142            "DockerBuildStrategy",
143            self.build_args.as_ref().map_or(0, |_| 1) +
144            self.dockerfile_path.as_ref().map_or(0, |_| 1) +
145            self.env.as_ref().map_or(0, |_| 1) +
146            self.force_pull.as_ref().map_or(0, |_| 1) +
147            self.from.as_ref().map_or(0, |_| 1) +
148            self.image_optimization_policy.as_ref().map_or(0, |_| 1) +
149            self.no_cache.as_ref().map_or(0, |_| 1) +
150            self.pull_secret.as_ref().map_or(0, |_| 1),
151        )?;
152        if let Some(value) = &self.build_args {
153            serde::ser::SerializeStruct::serialize_field(&mut state, "buildArgs", value)?;
154        }
155        if let Some(value) = &self.dockerfile_path {
156            serde::ser::SerializeStruct::serialize_field(&mut state, "dockerfilePath", value)?;
157        }
158        if let Some(value) = &self.env {
159            serde::ser::SerializeStruct::serialize_field(&mut state, "env", value)?;
160        }
161        if let Some(value) = &self.force_pull {
162            serde::ser::SerializeStruct::serialize_field(&mut state, "forcePull", value)?;
163        }
164        if let Some(value) = &self.from {
165            serde::ser::SerializeStruct::serialize_field(&mut state, "from", value)?;
166        }
167        if let Some(value) = &self.image_optimization_policy {
168            serde::ser::SerializeStruct::serialize_field(&mut state, "imageOptimizationPolicy", value)?;
169        }
170        if let Some(value) = &self.no_cache {
171            serde::ser::SerializeStruct::serialize_field(&mut state, "noCache", value)?;
172        }
173        if let Some(value) = &self.pull_secret {
174            serde::ser::SerializeStruct::serialize_field(&mut state, "pullSecret", value)?;
175        }
176        serde::ser::SerializeStruct::end(state)
177    }
178}