1// Generated from definition io.k8s.api.admissionregistration.v1alpha1.ApplyConfiguration
23/// ApplyConfiguration defines the desired configuration values of an object.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ApplyConfiguration {
6/// expression will be evaluated by CEL to create an apply configuration. ref: https://github.com/google/cel-spec
7 ///
8 /// Apply configurations are declared in CEL using object initialization. For example, this CEL expression returns an apply configuration to set a single field:
9 ///
10 /// Object{
11 /// spec: Object.spec{
12 /// serviceAccountName: "example"
13 /// }
14 /// }
15 ///
16 /// Apply configurations may not modify atomic structs, maps or arrays due to the risk of accidental deletion of values not included in the apply configuration.
17 ///
18 /// CEL expressions have access to the object types needed to create apply configurations:
19 ///
20 /// - 'Object' - CEL type of the resource object. - 'Object.\<fieldName\>' - CEL type of object field (such as 'Object.spec') - 'Object.\<fieldName1\>.\<fieldName2\>...\<fieldNameN\>` - CEL type of nested field (such as 'Object.spec.containers')
21 ///
22 /// CEL expressions have access to the contents of the API request, organized into CEL variables as well as some other useful variables:
23 ///
24 /// - 'object' - The object from the incoming request. The value is null for DELETE requests. - 'oldObject' - The existing object. The value is null for CREATE requests. - 'request' - Attributes of the API request(\[ref\](/pkg/apis/admission/types.go#AdmissionRequest)). - 'params' - Parameter resource referred to by the policy binding being evaluated. Only populated if the policy has a ParamKind. - 'namespaceObject' - The namespace object that the incoming object belongs to. The value is null for cluster-scoped resources. - 'variables' - Map of composited variables, from its name to its lazily evaluated value.
25 /// For example, a variable named 'foo' can be accessed as 'variables.foo'.
26 /// - 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.
27 /// See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz
28 /// - 'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the
29 /// request resource.
30 ///
31 /// The `apiVersion`, `kind`, `metadata.name` and `metadata.generateName` are always accessible from the root of the object. No other metadata properties are accessible.
32 ///
33 /// Only property names of the form `\[a-zA-Z_.-/\]\[a-zA-Z0-9_.-/\]*` are accessible. Required.
34pub expression: Option<std::string::String>,
35}
3637impl crate::DeepMerge for ApplyConfiguration {
38fn merge_from(&mut self, other: Self) {
39crate::DeepMerge::merge_from(&mut self.expression, other.expression);
40 }
41}
4243impl<'de> crate::serde::Deserialize<'de> for ApplyConfiguration {
44fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
45#[allow(non_camel_case_types)]
46enum Field {
47 Key_expression,
48 Other,
49 }
5051impl<'de> crate::serde::Deserialize<'de> for Field {
52fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
53struct Visitor;
5455impl crate::serde::de::Visitor<'_> for Visitor {
56type Value = Field;
5758fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
59 f.write_str("field identifier")
60 }
6162fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
63Ok(match v {
64"expression" => Field::Key_expression,
65_ => Field::Other,
66 })
67 }
68 }
6970 deserializer.deserialize_identifier(Visitor)
71 }
72 }
7374struct Visitor;
7576impl<'de> crate::serde::de::Visitor<'de> for Visitor {
77type Value = ApplyConfiguration;
7879fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
80 f.write_str("ApplyConfiguration")
81 }
8283fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
84let mut value_expression: Option<std::string::String> = None;
8586while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
87match key {
88 Field::Key_expression => value_expression = crate::serde::de::MapAccess::next_value(&mut map)?,
89 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
90 }
91 }
9293Ok(ApplyConfiguration {
94 expression: value_expression,
95 })
96 }
97 }
9899 deserializer.deserialize_struct(
100"ApplyConfiguration",
101&[
102"expression",
103 ],
104 Visitor,
105 )
106 }
107}
108109impl crate::serde::Serialize for ApplyConfiguration {
110fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
111let mut state = serializer.serialize_struct(
112"ApplyConfiguration",
113self.expression.as_ref().map_or(0, |_| 1),
114 )?;
115if let Some(value) = &self.expression {
116crate::serde::ser::SerializeStruct::serialize_field(&mut state, "expression", value)?;
117 }
118crate::serde::ser::SerializeStruct::end(state)
119 }
120}
121122#[cfg(feature = "schemars")]
123impl crate::schemars::JsonSchema for ApplyConfiguration {
124fn schema_name() -> std::string::String {
125"io.k8s.api.admissionregistration.v1alpha1.ApplyConfiguration".into()
126 }
127128fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
129crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
130 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
131 description: Some("ApplyConfiguration defines the desired configuration values of an object.".into()),
132 ..Default::default()
133 })),
134 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
135 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
136 properties: [
137 (
138"expression".into(),
139crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
140 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
141 description: Some("expression will be evaluated by CEL to create an apply configuration. ref: https://github.com/google/cel-spec\n\nApply configurations are declared in CEL using object initialization. For example, this CEL expression returns an apply configuration to set a single field:\n\n\tObject{\n\t spec: Object.spec{\n\t serviceAccountName: \"example\"\n\t }\n\t}\n\nApply configurations may not modify atomic structs, maps or arrays due to the risk of accidental deletion of values not included in the apply configuration.\n\nCEL expressions have access to the object types needed to create apply configurations:\n\n- 'Object' - CEL type of the resource object. - 'Object.<fieldName>' - CEL type of object field (such as 'Object.spec') - 'Object.<fieldName1>.<fieldName2>...<fieldNameN>` - CEL type of nested field (such as 'Object.spec.containers')\n\nCEL expressions have access to the contents of the API request, organized into CEL variables as well as some other useful variables:\n\n- 'object' - The object from the incoming request. The value is null for DELETE requests. - 'oldObject' - The existing object. The value is null for CREATE requests. - 'request' - Attributes of the API request([ref](/pkg/apis/admission/types.go#AdmissionRequest)). - 'params' - Parameter resource referred to by the policy binding being evaluated. Only populated if the policy has a ParamKind. - 'namespaceObject' - The namespace object that the incoming object belongs to. The value is null for cluster-scoped resources. - 'variables' - Map of composited variables, from its name to its lazily evaluated value.\n For example, a variable named 'foo' can be accessed as 'variables.foo'.\n- 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.\n See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz\n- 'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the\n request resource.\n\nThe `apiVersion`, `kind`, `metadata.name` and `metadata.generateName` are always accessible from the root of the object. No other metadata properties are accessible.\n\nOnly property names of the form `[a-zA-Z_.-/][a-zA-Z0-9_.-/]*` are accessible. Required.".into()),
142 ..Default::default()
143 })),
144 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
145 ..Default::default()
146 }),
147 ),
148 ].into(),
149 ..Default::default()
150 })),
151 ..Default::default()
152 })
153 }
154}