Remove BPA from Makefile
[icn.git] / cmd / bpa-operator / vendor / k8s.io / apiextensions-apiserver / pkg / apis / apiextensions / types.go
1 /*
2 Copyright 2017 The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8     http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package apiextensions
18
19 import (
20         metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21 )
22
23 // ConversionStrategyType describes different conversion types.
24 type ConversionStrategyType string
25
26 const (
27         // NoneConverter is a converter that only sets apiversion of the CR and leave everything else unchanged.
28         NoneConverter ConversionStrategyType = "None"
29         // WebhookConverter is a converter that calls to an external webhook to convert the CR.
30         WebhookConverter ConversionStrategyType = "Webhook"
31 )
32
33 // CustomResourceDefinitionSpec describes how a user wants their resource to appear
34 type CustomResourceDefinitionSpec struct {
35         // Group is the group this resource belongs in
36         Group string
37         // Version is the version this resource belongs in
38         // Should be always first item in Versions field if provided.
39         // Optional, but at least one of Version or Versions must be set.
40         // Deprecated: Please use `Versions`.
41         Version string
42         // Names are the names used to describe this custom resource
43         Names CustomResourceDefinitionNames
44         // Scope indicates whether this resource is cluster or namespace scoped.  Default is namespaced
45         Scope ResourceScope
46         // Validation describes the validation methods for CustomResources
47         // Optional, the global validation schema for all versions.
48         // Top-level and per-version schemas are mutually exclusive.
49         // +optional
50         Validation *CustomResourceValidation
51         // Subresources describes the subresources for CustomResource
52         // Optional, the global subresources for all versions.
53         // Top-level and per-version subresources are mutually exclusive.
54         // +optional
55         Subresources *CustomResourceSubresources
56         // Versions is the list of all supported versions for this resource.
57         // If Version field is provided, this field is optional.
58         // Validation: All versions must use the same validation schema for now. i.e., top
59         // level Validation field is applied to all of these versions.
60         // Order: The version name will be used to compute the order.
61         // If the version string is "kube-like", it will sort above non "kube-like" version strings, which are ordered
62         // lexicographically. "Kube-like" versions start with a "v", then are followed by a number (the major version),
63         // then optionally the string "alpha" or "beta" and another number (the minor version). These are sorted first
64         // by GA > beta > alpha (where GA is a version with no suffix such as beta or alpha), and then by comparing
65         // major version, then minor version. An example sorted list of versions:
66         // v10, v2, v1, v11beta2, v10beta3, v3beta1, v12alpha1, v11alpha2, foo1, foo10.
67         Versions []CustomResourceDefinitionVersion
68         // AdditionalPrinterColumns are additional columns shown e.g. in kubectl next to the name. Defaults to a created-at column.
69         // Optional, the global columns for all versions.
70         // Top-level and per-version columns are mutually exclusive.
71         // +optional
72         AdditionalPrinterColumns []CustomResourceColumnDefinition
73
74         // `conversion` defines conversion settings for the CRD.
75         Conversion *CustomResourceConversion
76 }
77
78 // CustomResourceConversion describes how to convert different versions of a CR.
79 type CustomResourceConversion struct {
80         // `strategy` specifies the conversion strategy. Allowed values are:
81         // - `None`: The converter only change the apiVersion and would not touch any other field in the CR.
82         // - `Webhook`: API Server will call to an external webhook to do the conversion. Additional information is needed for this option.
83         Strategy ConversionStrategyType
84
85         // `webhookClientConfig` is the instructions for how to call the webhook if strategy is `Webhook`.
86         WebhookClientConfig *WebhookClientConfig
87 }
88
89 // WebhookClientConfig contains the information to make a TLS
90 // connection with the webhook. It has the same field as admissionregistration.internal.WebhookClientConfig.
91 type WebhookClientConfig struct {
92         // `url` gives the location of the webhook, in standard URL form
93         // (`scheme://host:port/path`). Exactly one of `url` or `service`
94         // must be specified.
95         //
96         // The `host` should not refer to a service running in the cluster; use
97         // the `service` field instead. The host might be resolved via external
98         // DNS in some apiservers (e.g., `kube-apiserver` cannot resolve
99         // in-cluster DNS as that would be a layering violation). `host` may
100         // also be an IP address.
101         //
102         // Please note that using `localhost` or `127.0.0.1` as a `host` is
103         // risky unless you take great care to run this webhook on all hosts
104         // which run an apiserver which might need to make calls to this
105         // webhook. Such installs are likely to be non-portable, i.e., not easy
106         // to turn up in a new cluster.
107         //
108         // The scheme must be "https"; the URL must begin with "https://".
109         //
110         // A path is optional, and if present may be any string permissible in
111         // a URL. You may use the path to pass an arbitrary string to the
112         // webhook, for example, a cluster identifier.
113         //
114         // Attempting to use a user or basic auth e.g. "user:password@" is not
115         // allowed. Fragments ("#...") and query parameters ("?...") are not
116         // allowed, either.
117         //
118         // +optional
119         URL *string
120
121         // `service` is a reference to the service for this webhook. Either
122         // `service` or `url` must be specified.
123         //
124         // If the webhook is running within the cluster, then you should use `service`.
125         //
126         // Port 443 will be used if it is open, otherwise it is an error.
127         //
128         // +optional
129         Service *ServiceReference
130
131         // `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate.
132         // If unspecified, system trust roots on the apiserver are used.
133         // +optional
134         CABundle []byte
135 }
136
137 // ServiceReference holds a reference to Service.legacy.k8s.io
138 type ServiceReference struct {
139         // `namespace` is the namespace of the service.
140         // Required
141         Namespace string
142         // `name` is the name of the service.
143         // Required
144         Name string
145
146         // `path` is an optional URL path which will be sent in any request to
147         // this service.
148         // +optional
149         Path *string
150 }
151
152 // CustomResourceDefinitionVersion describes a version for CRD.
153 type CustomResourceDefinitionVersion struct {
154         // Name is the version name, e.g. “v1”, “v2beta1”, etc.
155         Name string
156         // Served is a flag enabling/disabling this version from being served via REST APIs
157         Served bool
158         // Storage flags the version as storage version. There must be exactly one flagged
159         // as storage version.
160         Storage bool
161         // Schema describes the schema for CustomResource used in validation, pruning, and defaulting.
162         // Top-level and per-version schemas are mutually exclusive.
163         // Per-version schemas must not all be set to identical values (top-level validation schema should be used instead)
164         // This field is alpha-level and is only honored by servers that enable the CustomResourceWebhookConversion feature.
165         // +optional
166         Schema *CustomResourceValidation
167         // Subresources describes the subresources for CustomResource
168         // Top-level and per-version subresources are mutually exclusive.
169         // Per-version subresources must not all be set to identical values (top-level subresources should be used instead)
170         // This field is alpha-level and is only honored by servers that enable the CustomResourceWebhookConversion feature.
171         // +optional
172         Subresources *CustomResourceSubresources
173         // AdditionalPrinterColumns are additional columns shown e.g. in kubectl next to the name. Defaults to a created-at column.
174         // Top-level and per-version columns are mutually exclusive.
175         // Per-version columns must not all be set to identical values (top-level columns should be used instead)
176         // This field is alpha-level and is only honored by servers that enable the CustomResourceWebhookConversion feature.
177         // NOTE: CRDs created prior to 1.13 populated the top-level additionalPrinterColumns field by default. To apply an
178         // update that changes to per-version additionalPrinterColumns, the top-level additionalPrinterColumns field must
179         // be explicitly set to null
180         // +optional
181         AdditionalPrinterColumns []CustomResourceColumnDefinition
182 }
183
184 // CustomResourceColumnDefinition specifies a column for server side printing.
185 type CustomResourceColumnDefinition struct {
186         // name is a human readable name for the column.
187         Name string
188         // type is an OpenAPI type definition for this column.
189         // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more.
190         Type string
191         // format is an optional OpenAPI type definition for this column. The 'name' format is applied
192         // to the primary identifier column to assist in clients identifying column is the resource name.
193         // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more.
194         Format string
195         // description is a human readable description of this column.
196         Description string
197         // priority is an integer defining the relative importance of this column compared to others. Lower
198         // numbers are considered higher priority. Columns that may be omitted in limited space scenarios
199         // should be given a higher priority.
200         Priority int32
201
202         // JSONPath is a simple JSON path, i.e. without array notation.
203         JSONPath string
204 }
205
206 // CustomResourceDefinitionNames indicates the names to serve this CustomResourceDefinition
207 type CustomResourceDefinitionNames struct {
208         // Plural is the plural name of the resource to serve.  It must match the name of the CustomResourceDefinition-registration
209         // too: plural.group and it must be all lowercase.
210         Plural string
211         // Singular is the singular name of the resource.  It must be all lowercase  Defaults to lowercased <kind>
212         Singular string
213         // ShortNames are short names for the resource.  It must be all lowercase.
214         ShortNames []string
215         // Kind is the serialized kind of the resource.  It is normally CamelCase and singular.
216         Kind string
217         // ListKind is the serialized kind of the list for this resource.  Defaults to <kind>List.
218         ListKind string
219         // Categories is a list of grouped resources custom resources belong to (e.g. 'all')
220         // +optional
221         Categories []string
222 }
223
224 // ResourceScope is an enum defining the different scopes available to a custom resource
225 type ResourceScope string
226
227 const (
228         ClusterScoped   ResourceScope = "Cluster"
229         NamespaceScoped ResourceScope = "Namespaced"
230 )
231
232 type ConditionStatus string
233
234 // These are valid condition statuses. "ConditionTrue" means a resource is in the condition.
235 // "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes
236 // can't decide if a resource is in the condition or not. In the future, we could add other
237 // intermediate conditions, e.g. ConditionDegraded.
238 const (
239         ConditionTrue    ConditionStatus = "True"
240         ConditionFalse   ConditionStatus = "False"
241         ConditionUnknown ConditionStatus = "Unknown"
242 )
243
244 // CustomResourceDefinitionConditionType is a valid value for CustomResourceDefinitionCondition.Type
245 type CustomResourceDefinitionConditionType string
246
247 const (
248         // Established means that the resource has become active. A resource is established when all names are
249         // accepted without a conflict for the first time. A resource stays established until deleted, even during
250         // a later NamesAccepted due to changed names. Note that not all names can be changed.
251         Established CustomResourceDefinitionConditionType = "Established"
252         // NamesAccepted means the names chosen for this CustomResourceDefinition do not conflict with others in
253         // the group and are therefore accepted.
254         NamesAccepted CustomResourceDefinitionConditionType = "NamesAccepted"
255         // Terminating means that the CustomResourceDefinition has been deleted and is cleaning up.
256         Terminating CustomResourceDefinitionConditionType = "Terminating"
257 )
258
259 // CustomResourceDefinitionCondition contains details for the current condition of this pod.
260 type CustomResourceDefinitionCondition struct {
261         // Type is the type of the condition.
262         Type CustomResourceDefinitionConditionType
263         // Status is the status of the condition.
264         // Can be True, False, Unknown.
265         Status ConditionStatus
266         // Last time the condition transitioned from one status to another.
267         // +optional
268         LastTransitionTime metav1.Time
269         // Unique, one-word, CamelCase reason for the condition's last transition.
270         // +optional
271         Reason string
272         // Human-readable message indicating details about last transition.
273         // +optional
274         Message string
275 }
276
277 // CustomResourceDefinitionStatus indicates the state of the CustomResourceDefinition
278 type CustomResourceDefinitionStatus struct {
279         // Conditions indicate state for particular aspects of a CustomResourceDefinition
280         Conditions []CustomResourceDefinitionCondition
281
282         // AcceptedNames are the names that are actually being used to serve discovery
283         // They may be different than the names in spec.
284         AcceptedNames CustomResourceDefinitionNames
285
286         // StoredVersions are all versions of CustomResources that were ever persisted. Tracking these
287         // versions allows a migration path for stored versions in etcd. The field is mutable
288         // so the migration controller can first finish a migration to another version (i.e.
289         // that no old objects are left in the storage), and then remove the rest of the
290         // versions from this list.
291         // None of the versions in this list can be removed from the spec.Versions field.
292         StoredVersions []string
293 }
294
295 // CustomResourceCleanupFinalizer is the name of the finalizer which will delete instances of
296 // a CustomResourceDefinition
297 const CustomResourceCleanupFinalizer = "customresourcecleanup.apiextensions.k8s.io"
298
299 // +genclient
300 // +genclient:nonNamespaced
301 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
302
303 // CustomResourceDefinition represents a resource that should be exposed on the API server.  Its name MUST be in the format
304 // <.spec.name>.<.spec.group>.
305 type CustomResourceDefinition struct {
306         metav1.TypeMeta
307         metav1.ObjectMeta
308
309         // Spec describes how the user wants the resources to appear
310         Spec CustomResourceDefinitionSpec
311         // Status indicates the actual state of the CustomResourceDefinition
312         Status CustomResourceDefinitionStatus
313 }
314
315 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
316
317 // CustomResourceDefinitionList is a list of CustomResourceDefinition objects.
318 type CustomResourceDefinitionList struct {
319         metav1.TypeMeta
320         metav1.ListMeta
321
322         // Items individual CustomResourceDefinitions
323         Items []CustomResourceDefinition
324 }
325
326 // CustomResourceValidation is a list of validation methods for CustomResources.
327 type CustomResourceValidation struct {
328         // OpenAPIV3Schema is the OpenAPI v3 schema to be validated against.
329         OpenAPIV3Schema *JSONSchemaProps
330 }
331
332 // CustomResourceSubresources defines the status and scale subresources for CustomResources.
333 type CustomResourceSubresources struct {
334         // Status denotes the status subresource for CustomResources
335         Status *CustomResourceSubresourceStatus
336         // Scale denotes the scale subresource for CustomResources
337         Scale *CustomResourceSubresourceScale
338 }
339
340 // CustomResourceSubresourceStatus defines how to serve the status subresource for CustomResources.
341 // Status is represented by the `.status` JSON path inside of a CustomResource. When set,
342 // * exposes a /status subresource for the custom resource
343 // * PUT requests to the /status subresource take a custom resource object, and ignore changes to anything except the status stanza
344 // * PUT/POST/PATCH requests to the custom resource ignore changes to the status stanza
345 type CustomResourceSubresourceStatus struct{}
346
347 // CustomResourceSubresourceScale defines how to serve the scale subresource for CustomResources.
348 type CustomResourceSubresourceScale struct {
349         // SpecReplicasPath defines the JSON path inside of a CustomResource that corresponds to Scale.Spec.Replicas.
350         // Only JSON paths without the array notation are allowed.
351         // Must be a JSON Path under .spec.
352         // If there is no value under the given path in the CustomResource, the /scale subresource will return an error on GET.
353         SpecReplicasPath string
354         // StatusReplicasPath defines the JSON path inside of a CustomResource that corresponds to Scale.Status.Replicas.
355         // Only JSON paths without the array notation are allowed.
356         // Must be a JSON Path under .status.
357         // If there is no value under the given path in the CustomResource, the status replica value in the /scale subresource
358         // will default to 0.
359         StatusReplicasPath string
360         // LabelSelectorPath defines the JSON path inside of a CustomResource that corresponds to Scale.Status.Selector.
361         // Only JSON paths without the array notation are allowed.
362         // Must be a JSON Path under .status.
363         // Must be set to work with HPA.
364         // If there is no value under the given path in the CustomResource, the status label selector value in the /scale
365         // subresource will default to the empty string.
366         // +optional
367         LabelSelectorPath *string
368 }