cluster_api_rs/api/capi_extensionconfig.rs
1// WARNING: generated by kopium - manual changes will be overwritten
2// kopium command: kopium --smart-derive-elision -D Default -D PartialEq -A -d -f -
3// kopium version: 0.21.2
4
5#[allow(unused_imports)]
6mod prelude {
7 pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
8 pub use kube::CustomResource;
9 pub use schemars::JsonSchema;
10 pub use serde::{Deserialize, Serialize};
11 pub use std::collections::BTreeMap;
12}
13use self::prelude::*;
14
15/// spec is the desired state of the ExtensionConfig.
16#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
17#[kube(
18 group = "runtime.cluster.x-k8s.io",
19 version = "v1alpha1",
20 kind = "ExtensionConfig",
21 plural = "extensionconfigs"
22)]
23#[kube(status = "ExtensionConfigStatus")]
24#[kube(derive = "Default")]
25#[kube(derive = "PartialEq")]
26pub struct ExtensionConfigSpec {
27 /// clientConfig defines how to communicate with the Extension server.
28 #[serde(rename = "clientConfig")]
29 pub client_config: ExtensionConfigClientConfig,
30 /// namespaceSelector decides whether to call the hook for an object based
31 /// on whether the namespace for that object matches the selector.
32 /// Defaults to the empty LabelSelector, which matches all objects.
33 #[serde(
34 default,
35 skip_serializing_if = "Option::is_none",
36 rename = "namespaceSelector"
37 )]
38 pub namespace_selector: Option<ExtensionConfigNamespaceSelector>,
39 /// settings defines key value pairs to be passed to all calls
40 /// to all supported RuntimeExtensions.
41 /// Note: Settings can be overridden on the ClusterClass.
42 #[serde(default, skip_serializing_if = "Option::is_none")]
43 pub settings: Option<BTreeMap<String, String>>,
44}
45
46/// clientConfig defines how to communicate with the Extension server.
47#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
48pub struct ExtensionConfigClientConfig {
49 /// caBundle is a PEM encoded CA bundle which will be used to validate the Extension server's server certificate.
50 #[serde(default, skip_serializing_if = "Option::is_none", rename = "caBundle")]
51 pub ca_bundle: Option<String>,
52 /// service is a reference to the Kubernetes service for the Extension server.
53 /// Note: Exactly one of `url` or `service` must be specified.
54 ///
55 /// If the Extension server is running within a cluster, then you should use `service`.
56 #[serde(default, skip_serializing_if = "Option::is_none")]
57 pub service: Option<ExtensionConfigClientConfigService>,
58 /// url gives the location of the Extension server, in standard URL form
59 /// (`scheme://host:port/path`).
60 /// Note: Exactly one of `url` or `service` must be specified.
61 ///
62 /// The scheme must be "https".
63 ///
64 /// The `host` should not refer to a service running in the cluster; use
65 /// the `service` field instead.
66 ///
67 /// A path is optional, and if present may be any string permissible in
68 /// a URL. If a path is set it will be used as prefix to the hook-specific path.
69 ///
70 /// Attempting to use a user or basic auth e.g. "user:password@" is not
71 /// allowed. Fragments ("#...") and query parameters ("?...") are not
72 /// allowed either.
73 #[serde(default, skip_serializing_if = "Option::is_none")]
74 pub url: Option<String>,
75}
76
77/// service is a reference to the Kubernetes service for the Extension server.
78/// Note: Exactly one of `url` or `service` must be specified.
79///
80/// If the Extension server is running within a cluster, then you should use `service`.
81#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
82pub struct ExtensionConfigClientConfigService {
83 /// name is the name of the service.
84 pub name: String,
85 /// namespace is the namespace of the service.
86 pub namespace: String,
87 /// path is an optional URL path and if present may be any string permissible in
88 /// a URL. If a path is set it will be used as prefix to the hook-specific path.
89 #[serde(default, skip_serializing_if = "Option::is_none")]
90 pub path: Option<String>,
91 /// port is the port on the service that's hosting the Extension server.
92 /// Defaults to 443.
93 /// Port should be a valid port number (1-65535, inclusive).
94 #[serde(default, skip_serializing_if = "Option::is_none")]
95 pub port: Option<i32>,
96}
97
98/// namespaceSelector decides whether to call the hook for an object based
99/// on whether the namespace for that object matches the selector.
100/// Defaults to the empty LabelSelector, which matches all objects.
101#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
102pub struct ExtensionConfigNamespaceSelector {
103 /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
104 #[serde(
105 default,
106 skip_serializing_if = "Option::is_none",
107 rename = "matchExpressions"
108 )]
109 pub match_expressions: Option<Vec<ExtensionConfigNamespaceSelectorMatchExpressions>>,
110 /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
111 /// map is equivalent to an element of matchExpressions, whose key field is "key", the
112 /// operator is "In", and the values array contains only "value". The requirements are ANDed.
113 #[serde(
114 default,
115 skip_serializing_if = "Option::is_none",
116 rename = "matchLabels"
117 )]
118 pub match_labels: Option<BTreeMap<String, String>>,
119}
120
121/// A label selector requirement is a selector that contains values, a key, and an operator that
122/// relates the key and values.
123#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
124pub struct ExtensionConfigNamespaceSelectorMatchExpressions {
125 /// key is the label key that the selector applies to.
126 pub key: String,
127 /// operator represents a key's relationship to a set of values.
128 /// Valid operators are In, NotIn, Exists and DoesNotExist.
129 pub operator: String,
130 /// values is an array of string values. If the operator is In or NotIn,
131 /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
132 /// the values array must be empty. This array is replaced during a strategic
133 /// merge patch.
134 #[serde(default, skip_serializing_if = "Option::is_none")]
135 pub values: Option<Vec<String>>,
136}
137
138/// status is the current state of the ExtensionConfig
139#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
140pub struct ExtensionConfigStatus {
141 /// conditions define the current service state of the ExtensionConfig.
142 #[serde(default, skip_serializing_if = "Option::is_none")]
143 pub conditions: Option<Vec<Condition>>,
144 /// handlers defines the current ExtensionHandlers supported by an Extension.
145 #[serde(default, skip_serializing_if = "Option::is_none")]
146 pub handlers: Option<Vec<ExtensionConfigStatusHandlers>>,
147 /// v1beta2 groups all the fields that will be added or modified in ExtensionConfig's status with the V1Beta2 version.
148 #[serde(default, skip_serializing_if = "Option::is_none")]
149 pub v1beta2: Option<ExtensionConfigStatusV1beta2>,
150}
151
152/// ExtensionHandler specifies the details of a handler for a particular runtime hook registered by an Extension server.
153#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
154pub struct ExtensionConfigStatusHandlers {
155 /// failurePolicy defines how failures in calls to the ExtensionHandler should be handled by a client.
156 /// Defaults to Fail if not set.
157 #[serde(
158 default,
159 skip_serializing_if = "Option::is_none",
160 rename = "failurePolicy"
161 )]
162 pub failure_policy: Option<ExtensionConfigStatusHandlersFailurePolicy>,
163 /// name is the unique name of the ExtensionHandler.
164 pub name: String,
165 /// requestHook defines the versioned runtime hook which this ExtensionHandler serves.
166 #[serde(rename = "requestHook")]
167 pub request_hook: ExtensionConfigStatusHandlersRequestHook,
168 /// timeoutSeconds defines the timeout duration for client calls to the ExtensionHandler.
169 /// Defaults to 10 is not set.
170 #[serde(
171 default,
172 skip_serializing_if = "Option::is_none",
173 rename = "timeoutSeconds"
174 )]
175 pub timeout_seconds: Option<i32>,
176}
177
178/// ExtensionHandler specifies the details of a handler for a particular runtime hook registered by an Extension server.
179#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
180pub enum ExtensionConfigStatusHandlersFailurePolicy {
181 Ignore,
182 Fail,
183}
184
185/// requestHook defines the versioned runtime hook which this ExtensionHandler serves.
186#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
187pub struct ExtensionConfigStatusHandlersRequestHook {
188 /// apiVersion is the group and version of the Hook.
189 #[serde(rename = "apiVersion")]
190 pub api_version: String,
191 /// hook is the name of the hook.
192 pub hook: String,
193}
194
195/// v1beta2 groups all the fields that will be added or modified in ExtensionConfig's status with the V1Beta2 version.
196#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
197pub struct ExtensionConfigStatusV1beta2 {
198 /// conditions represents the observations of a ExtensionConfig's current state.
199 /// Known condition types are Discovered, Paused.
200 #[serde(default, skip_serializing_if = "Option::is_none")]
201 pub conditions: Option<Vec<Condition>>,
202}