1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// Generated from definition com.github.openshift.api.build.v1.DockerBuildStrategy

/// DockerBuildStrategy defines input parameters specific to container image build.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct DockerBuildStrategy {
    /// buildArgs contains build arguments that will be resolved in the Dockerfile.  See https://docs.docker.com/engine/reference/builder/#/arg for more details.
    pub build_args: Option<Vec<k8s_openapi::api::core::v1::EnvVar>>,

    /// dockerfilePath is the path of the Dockerfile that will be used to build the container image, relative to the root of the context (contextDir).
    pub dockerfile_path: Option<String>,

    /// env contains additional environment variables you want to pass into a builder container.
    pub env: Option<Vec<k8s_openapi::api::core::v1::EnvVar>>,

    /// forcePull describes if the builder should pull the images from registry prior to building.
    pub force_pull: Option<bool>,

    /// 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.
    pub from: Option<k8s_openapi::api::core::v1::ObjectReference>,

    /// 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.
    pub image_optimization_policy: Option<String>,

    /// noCache if set to true indicates that the container image build must be executed with the --no-cache=true flag
    pub no_cache: Option<bool>,

    /// 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
    pub pull_secret: Option<k8s_openapi::api::core::v1::LocalObjectReference>,
}

impl<'de> serde::Deserialize<'de> for DockerBuildStrategy {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
        #[allow(non_camel_case_types)]
        enum Field {
            Key_build_args,
            Key_dockerfile_path,
            Key_env,
            Key_force_pull,
            Key_from,
            Key_image_optimization_policy,
            Key_no_cache,
            Key_pull_secret,
            Other,
        }

        impl<'de> serde::Deserialize<'de> for Field {
            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
                struct Visitor;

                impl<'de> serde::de::Visitor<'de> for Visitor {
                    type Value = Field;

                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
                        f.write_str("field identifier")
                    }

                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
                        Ok(match v {
                            "buildArgs" => Field::Key_build_args,
                            "dockerfilePath" => Field::Key_dockerfile_path,
                            "env" => Field::Key_env,
                            "forcePull" => Field::Key_force_pull,
                            "from" => Field::Key_from,
                            "imageOptimizationPolicy" => Field::Key_image_optimization_policy,
                            "noCache" => Field::Key_no_cache,
                            "pullSecret" => Field::Key_pull_secret,
                            _ => Field::Other,
                        })
                    }
                }

                deserializer.deserialize_identifier(Visitor)
            }
        }

        struct Visitor;

        impl<'de> serde::de::Visitor<'de> for Visitor {
            type Value = DockerBuildStrategy;

            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
                f.write_str("DockerBuildStrategy")
            }

            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
                let mut value_build_args: Option<Vec<k8s_openapi::api::core::v1::EnvVar>> = None;
                let mut value_dockerfile_path: Option<String> = None;
                let mut value_env: Option<Vec<k8s_openapi::api::core::v1::EnvVar>> = None;
                let mut value_force_pull: Option<bool> = None;
                let mut value_from: Option<k8s_openapi::api::core::v1::ObjectReference> = None;
                let mut value_image_optimization_policy: Option<String> = None;
                let mut value_no_cache: Option<bool> = None;
                let mut value_pull_secret: Option<k8s_openapi::api::core::v1::LocalObjectReference> = None;

                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
                    match key {
                        Field::Key_build_args => value_build_args = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_dockerfile_path => value_dockerfile_path = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_env => value_env = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_force_pull => value_force_pull = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_from => value_from = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_image_optimization_policy => value_image_optimization_policy = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_no_cache => value_no_cache = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_pull_secret => value_pull_secret = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
                    }
                }

                Ok(DockerBuildStrategy {
                    build_args: value_build_args,
                    dockerfile_path: value_dockerfile_path,
                    env: value_env,
                    force_pull: value_force_pull,
                    from: value_from,
                    image_optimization_policy: value_image_optimization_policy,
                    no_cache: value_no_cache,
                    pull_secret: value_pull_secret,
                })
            }
        }

        deserializer.deserialize_struct(
            "DockerBuildStrategy",
            &[
                "buildArgs",
                "dockerfilePath",
                "env",
                "forcePull",
                "from",
                "imageOptimizationPolicy",
                "noCache",
                "pullSecret",
            ],
            Visitor,
        )
    }
}

impl serde::Serialize for DockerBuildStrategy {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
        let mut state = serializer.serialize_struct(
            "DockerBuildStrategy",
            self.build_args.as_ref().map_or(0, |_| 1) +
            self.dockerfile_path.as_ref().map_or(0, |_| 1) +
            self.env.as_ref().map_or(0, |_| 1) +
            self.force_pull.as_ref().map_or(0, |_| 1) +
            self.from.as_ref().map_or(0, |_| 1) +
            self.image_optimization_policy.as_ref().map_or(0, |_| 1) +
            self.no_cache.as_ref().map_or(0, |_| 1) +
            self.pull_secret.as_ref().map_or(0, |_| 1),
        )?;
        if let Some(value) = &self.build_args {
            serde::ser::SerializeStruct::serialize_field(&mut state, "buildArgs", value)?;
        }
        if let Some(value) = &self.dockerfile_path {
            serde::ser::SerializeStruct::serialize_field(&mut state, "dockerfilePath", value)?;
        }
        if let Some(value) = &self.env {
            serde::ser::SerializeStruct::serialize_field(&mut state, "env", value)?;
        }
        if let Some(value) = &self.force_pull {
            serde::ser::SerializeStruct::serialize_field(&mut state, "forcePull", value)?;
        }
        if let Some(value) = &self.from {
            serde::ser::SerializeStruct::serialize_field(&mut state, "from", value)?;
        }
        if let Some(value) = &self.image_optimization_policy {
            serde::ser::SerializeStruct::serialize_field(&mut state, "imageOptimizationPolicy", value)?;
        }
        if let Some(value) = &self.no_cache {
            serde::ser::SerializeStruct::serialize_field(&mut state, "noCache", value)?;
        }
        if let Some(value) = &self.pull_secret {
            serde::ser::SerializeStruct::serialize_field(&mut state, "pullSecret", value)?;
        }
        serde::ser::SerializeStruct::end(state)
    }
}