k8s_openapi/v1_30/api/core/v1/
exec_action.rs

1// Generated from definition io.k8s.api.core.v1.ExecAction
2
3/// ExecAction describes a "run in container" action.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ExecAction {
6    /// Command is the command line to execute inside the container, the working directory for the command  is root ('/') in the container's filesystem. The command is simply exec'd, it is not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and non-zero is unhealthy.
7    pub command: Option<Vec<String>>,
8}
9
10impl crate::DeepMerge for ExecAction {
11    fn merge_from(&mut self, other: Self) {
12        crate::merge_strategies::list::atomic(&mut self.command, other.command);
13    }
14}
15
16impl<'de> crate::serde::Deserialize<'de> for ExecAction {
17    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
18        #[allow(non_camel_case_types)]
19        enum Field {
20            Key_command,
21            Other,
22        }
23
24        impl<'de> crate::serde::Deserialize<'de> for Field {
25            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
26                struct Visitor;
27
28                impl crate::serde::de::Visitor<'_> for Visitor {
29                    type Value = Field;
30
31                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32                        f.write_str("field identifier")
33                    }
34
35                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
36                        Ok(match v {
37                            "command" => Field::Key_command,
38                            _ => Field::Other,
39                        })
40                    }
41                }
42
43                deserializer.deserialize_identifier(Visitor)
44            }
45        }
46
47        struct Visitor;
48
49        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
50            type Value = ExecAction;
51
52            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
53                f.write_str("ExecAction")
54            }
55
56            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
57                let mut value_command: Option<Vec<String>> = None;
58
59                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
60                    match key {
61                        Field::Key_command => value_command = crate::serde::de::MapAccess::next_value(&mut map)?,
62                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
63                    }
64                }
65
66                Ok(ExecAction {
67                    command: value_command,
68                })
69            }
70        }
71
72        deserializer.deserialize_struct(
73            "ExecAction",
74            &[
75                "command",
76            ],
77            Visitor,
78        )
79    }
80}
81
82impl crate::serde::Serialize for ExecAction {
83    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
84        let mut state = serializer.serialize_struct(
85            "ExecAction",
86            self.command.as_ref().map_or(0, |_| 1),
87        )?;
88        if let Some(value) = &self.command {
89            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "command", value)?;
90        }
91        crate::serde::ser::SerializeStruct::end(state)
92    }
93}
94
95#[cfg(feature = "schemars")]
96impl crate::schemars::JsonSchema for ExecAction {
97    fn schema_name() -> String {
98        "io.k8s.api.core.v1.ExecAction".to_owned()
99    }
100
101    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
102        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
103            metadata: Some(Box::new(crate::schemars::schema::Metadata {
104                description: Some("ExecAction describes a \"run in container\" action.".to_owned()),
105                ..Default::default()
106            })),
107            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
108            object: Some(Box::new(crate::schemars::schema::ObjectValidation {
109                properties: [
110                    (
111                        "command".to_owned(),
112                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
113                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
114                                description: Some("Command is the command line to execute inside the container, the working directory for the command  is root ('/') in the container's filesystem. The command is simply exec'd, it is not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and non-zero is unhealthy.".to_owned()),
115                                ..Default::default()
116                            })),
117                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
118                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
119                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(
120                                    crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
121                                        instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
122                                        ..Default::default()
123                                    })
124                                ))),
125                                ..Default::default()
126                            })),
127                            ..Default::default()
128                        }),
129                    ),
130                ].into(),
131                ..Default::default()
132            })),
133            ..Default::default()
134        })
135    }
136}