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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
// Generated from definition com.github.openshift.api.build.v1.BuildStatus

/// BuildStatus contains the status of a build
#[derive(Clone, Debug, Default, PartialEq)]
pub struct BuildStatus {
    /// cancelled describes if a cancel event was triggered for the build.
    pub cancelled: Option<bool>,

    /// completionTimestamp is a timestamp representing the server time when this Build was finished, whether that build failed or succeeded.  It reflects the time at which the Pod running the Build terminated. It is represented in RFC3339 form and is in UTC.
    pub completion_timestamp: Option<k8s_openapi::apimachinery::pkg::apis::meta::v1::Time>,

    /// config is an ObjectReference to the BuildConfig this Build is based on.
    pub config: Option<k8s_openapi::api::core::v1::ObjectReference>,

    /// duration contains time.Duration object describing build time.
    pub duration: Option<i64>,

    /// logSnippet is the last few lines of the build log.  This value is only set for builds that failed.
    pub log_snippet: Option<String>,

    /// message is a human-readable message indicating details about why the build has this status.
    pub message: Option<String>,

    /// output describes the container image the build has produced.
    pub output: Option<crate::api::build::v1::BuildStatusOutput>,

    /// outputDockerImageReference contains a reference to the container image that will be built by this build. Its value is computed from Build.Spec.Output.To, and should include the registry address, so that it can be used to push and pull the image.
    pub output_docker_image_reference: Option<String>,

    /// phase is the point in the build lifecycle. Possible values are "New", "Pending", "Running", "Complete", "Failed", "Error", and "Cancelled".
    pub phase: String,

    /// reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI.
    pub reason: Option<String>,

    /// stages contains details about each stage that occurs during the build including start time, duration (in milliseconds), and the steps that occured within each stage.
    pub stages: Option<Vec<crate::api::build::v1::StageInfo>>,

    /// startTimestamp is a timestamp representing the server time when this Build started running in a Pod. It is represented in RFC3339 form and is in UTC.
    pub start_timestamp: Option<k8s_openapi::apimachinery::pkg::apis::meta::v1::Time>,
}

impl<'de> serde::Deserialize<'de> for BuildStatus {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
        #[allow(non_camel_case_types)]
        enum Field {
            Key_cancelled,
            Key_completion_timestamp,
            Key_config,
            Key_duration,
            Key_log_snippet,
            Key_message,
            Key_output,
            Key_output_docker_image_reference,
            Key_phase,
            Key_reason,
            Key_stages,
            Key_start_timestamp,
            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 {
                            "cancelled" => Field::Key_cancelled,
                            "completionTimestamp" => Field::Key_completion_timestamp,
                            "config" => Field::Key_config,
                            "duration" => Field::Key_duration,
                            "logSnippet" => Field::Key_log_snippet,
                            "message" => Field::Key_message,
                            "output" => Field::Key_output,
                            "outputDockerImageReference" => Field::Key_output_docker_image_reference,
                            "phase" => Field::Key_phase,
                            "reason" => Field::Key_reason,
                            "stages" => Field::Key_stages,
                            "startTimestamp" => Field::Key_start_timestamp,
                            _ => Field::Other,
                        })
                    }
                }

                deserializer.deserialize_identifier(Visitor)
            }
        }

        struct Visitor;

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

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

            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
                let mut value_cancelled: Option<bool> = None;
                let mut value_completion_timestamp: Option<k8s_openapi::apimachinery::pkg::apis::meta::v1::Time> = None;
                let mut value_config: Option<k8s_openapi::api::core::v1::ObjectReference> = None;
                let mut value_duration: Option<i64> = None;
                let mut value_log_snippet: Option<String> = None;
                let mut value_message: Option<String> = None;
                let mut value_output: Option<crate::api::build::v1::BuildStatusOutput> = None;
                let mut value_output_docker_image_reference: Option<String> = None;
                let mut value_phase: Option<String> = None;
                let mut value_reason: Option<String> = None;
                let mut value_stages: Option<Vec<crate::api::build::v1::StageInfo>> = None;
                let mut value_start_timestamp: Option<k8s_openapi::apimachinery::pkg::apis::meta::v1::Time> = None;

                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
                    match key {
                        Field::Key_cancelled => value_cancelled = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_completion_timestamp => value_completion_timestamp = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_config => value_config = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_duration => value_duration = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_log_snippet => value_log_snippet = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_message => value_message = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_output => value_output = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_output_docker_image_reference => value_output_docker_image_reference = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_phase => value_phase = Some(serde::de::MapAccess::next_value(&mut map)?),
                        Field::Key_reason => value_reason = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_stages => value_stages = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Key_start_timestamp => value_start_timestamp = serde::de::MapAccess::next_value(&mut map)?,
                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
                    }
                }

                Ok(BuildStatus {
                    cancelled: value_cancelled,
                    completion_timestamp: value_completion_timestamp,
                    config: value_config,
                    duration: value_duration,
                    log_snippet: value_log_snippet,
                    message: value_message,
                    output: value_output,
                    output_docker_image_reference: value_output_docker_image_reference,
                    phase: value_phase.ok_or_else(|| serde::de::Error::missing_field("phase"))?,
                    reason: value_reason,
                    stages: value_stages,
                    start_timestamp: value_start_timestamp,
                })
            }
        }

        deserializer.deserialize_struct(
            "BuildStatus",
            &[
                "cancelled",
                "completionTimestamp",
                "config",
                "duration",
                "logSnippet",
                "message",
                "output",
                "outputDockerImageReference",
                "phase",
                "reason",
                "stages",
                "startTimestamp",
            ],
            Visitor,
        )
    }
}

impl serde::Serialize for BuildStatus {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
        let mut state = serializer.serialize_struct(
            "BuildStatus",
            1 +
            self.cancelled.as_ref().map_or(0, |_| 1) +
            self.completion_timestamp.as_ref().map_or(0, |_| 1) +
            self.config.as_ref().map_or(0, |_| 1) +
            self.duration.as_ref().map_or(0, |_| 1) +
            self.log_snippet.as_ref().map_or(0, |_| 1) +
            self.message.as_ref().map_or(0, |_| 1) +
            self.output.as_ref().map_or(0, |_| 1) +
            self.output_docker_image_reference.as_ref().map_or(0, |_| 1) +
            self.reason.as_ref().map_or(0, |_| 1) +
            self.stages.as_ref().map_or(0, |_| 1) +
            self.start_timestamp.as_ref().map_or(0, |_| 1),
        )?;
        if let Some(value) = &self.cancelled {
            serde::ser::SerializeStruct::serialize_field(&mut state, "cancelled", value)?;
        }
        if let Some(value) = &self.completion_timestamp {
            serde::ser::SerializeStruct::serialize_field(&mut state, "completionTimestamp", value)?;
        }
        if let Some(value) = &self.config {
            serde::ser::SerializeStruct::serialize_field(&mut state, "config", value)?;
        }
        if let Some(value) = &self.duration {
            serde::ser::SerializeStruct::serialize_field(&mut state, "duration", value)?;
        }
        if let Some(value) = &self.log_snippet {
            serde::ser::SerializeStruct::serialize_field(&mut state, "logSnippet", value)?;
        }
        if let Some(value) = &self.message {
            serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
        }
        if let Some(value) = &self.output {
            serde::ser::SerializeStruct::serialize_field(&mut state, "output", value)?;
        }
        if let Some(value) = &self.output_docker_image_reference {
            serde::ser::SerializeStruct::serialize_field(&mut state, "outputDockerImageReference", value)?;
        }
        serde::ser::SerializeStruct::serialize_field(&mut state, "phase", &self.phase)?;
        if let Some(value) = &self.reason {
            serde::ser::SerializeStruct::serialize_field(&mut state, "reason", value)?;
        }
        if let Some(value) = &self.stages {
            serde::ser::SerializeStruct::serialize_field(&mut state, "stages", value)?;
        }
        if let Some(value) = &self.start_timestamp {
            serde::ser::SerializeStruct::serialize_field(&mut state, "startTimestamp", value)?;
        }
        serde::ser::SerializeStruct::end(state)
    }
}