PageRenderTime 157ms CodeModel.GetById 41ms RepoModel.GetById 21ms app.codeStats 0ms

/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types.go

https://gitlab.com/unofficial-mirrors/kubernetes
Go | 228 lines | 80 code | 26 blank | 122 comment | 0 complexity | d2bf2b5cff5b0de23500d8fe31aafb6a MD5 | raw file
  1. /*
  2. Copyright 2017 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package v1beta1
  14. import (
  15. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  16. )
  17. // CustomResourceDefinitionSpec describes how a user wants their resource to appear
  18. type CustomResourceDefinitionSpec struct {
  19. // Group is the group this resource belongs in
  20. Group string `json:"group" protobuf:"bytes,1,opt,name=group"`
  21. // Version is the version this resource belongs in
  22. // Should be always first item in Versions field if provided.
  23. // Optional, but at least one of Version or Versions must be set.
  24. // Deprecated: Please use `Versions`.
  25. // +optional
  26. Version string `json:"version,omitempty" protobuf:"bytes,2,opt,name=version"`
  27. // Names are the names used to describe this custom resource
  28. Names CustomResourceDefinitionNames `json:"names" protobuf:"bytes,3,opt,name=names"`
  29. // Scope indicates whether this resource is cluster or namespace scoped. Default is namespaced
  30. Scope ResourceScope `json:"scope" protobuf:"bytes,4,opt,name=scope,casttype=ResourceScope"`
  31. // Validation describes the validation methods for CustomResources
  32. // +optional
  33. Validation *CustomResourceValidation `json:"validation,omitempty" protobuf:"bytes,5,opt,name=validation"`
  34. // Subresources describes the subresources for CustomResources
  35. // +optional
  36. Subresources *CustomResourceSubresources `json:"subresources,omitempty" protobuf:"bytes,6,opt,name=subresources"`
  37. // Versions is the list of all supported versions for this resource.
  38. // If Version field is provided, this field is optional.
  39. // Validation: All versions must use the same validation schema for now. i.e., top
  40. // level Validation field is applied to all of these versions.
  41. // Order: The version name will be used to compute the order.
  42. // If the version string is "kube-like", it will sort above non "kube-like" version strings, which are ordered
  43. // lexicographically. "Kube-like" versions start with a "v", then are followed by a number (the major version),
  44. // then optionally the string "alpha" or "beta" and another number (the minor version). These are sorted first
  45. // by GA > beta > alpha, and then by comparing major version, then minor version. An example sorted list of
  46. // versions: v10, v2, v1, v11beta2, v10beta3, v3beta1, v12alpha1, v11alpha2, foo1, foo10.
  47. Versions []CustomResourceDefinitionVersion `json:"versions,omitempty" protobuf:"bytes,7,rep,name=versions"`
  48. }
  49. type CustomResourceDefinitionVersion struct {
  50. // Name is the version name, e.g. “v1”, “v2beta1”, etc.
  51. Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
  52. // Served is a flag enabling/disabling this version from being served via REST APIs
  53. Served bool `json:"served" protobuf:"varint,2,opt,name=served"`
  54. // Storage flags the version as storage version. There must be exactly one
  55. // flagged as storage version.
  56. Storage bool `json:"storage" protobuf:"varint,3,opt,name=storage"`
  57. }
  58. // CustomResourceDefinitionNames indicates the names to serve this CustomResourceDefinition
  59. type CustomResourceDefinitionNames struct {
  60. // Plural is the plural name of the resource to serve. It must match the name of the CustomResourceDefinition-registration
  61. // too: plural.group and it must be all lowercase.
  62. Plural string `json:"plural" protobuf:"bytes,1,opt,name=plural"`
  63. // Singular is the singular name of the resource. It must be all lowercase Defaults to lowercased <kind>
  64. Singular string `json:"singular,omitempty" protobuf:"bytes,2,opt,name=singular"`
  65. // ShortNames are short names for the resource. It must be all lowercase.
  66. ShortNames []string `json:"shortNames,omitempty" protobuf:"bytes,3,opt,name=shortNames"`
  67. // Kind is the serialized kind of the resource. It is normally CamelCase and singular.
  68. Kind string `json:"kind" protobuf:"bytes,4,opt,name=kind"`
  69. // ListKind is the serialized kind of the list for this resource. Defaults to <kind>List.
  70. ListKind string `json:"listKind,omitempty" protobuf:"bytes,5,opt,name=listKind"`
  71. // Categories is a list of grouped resources custom resources belong to (e.g. 'all')
  72. // +optional
  73. Categories []string `json:"categories,omitempty" protobuf:"bytes,6,rep,name=categories"`
  74. }
  75. // ResourceScope is an enum defining the different scopes available to a custom resource
  76. type ResourceScope string
  77. const (
  78. ClusterScoped ResourceScope = "Cluster"
  79. NamespaceScoped ResourceScope = "Namespaced"
  80. )
  81. type ConditionStatus string
  82. // These are valid condition statuses. "ConditionTrue" means a resource is in the condition.
  83. // "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes
  84. // can't decide if a resource is in the condition or not. In the future, we could add other
  85. // intermediate conditions, e.g. ConditionDegraded.
  86. const (
  87. ConditionTrue ConditionStatus = "True"
  88. ConditionFalse ConditionStatus = "False"
  89. ConditionUnknown ConditionStatus = "Unknown"
  90. )
  91. // CustomResourceDefinitionConditionType is a valid value for CustomResourceDefinitionCondition.Type
  92. type CustomResourceDefinitionConditionType string
  93. const (
  94. // Established means that the resource has become active. A resource is established when all names are
  95. // accepted without a conflict for the first time. A resource stays established until deleted, even during
  96. // a later NamesAccepted due to changed names. Note that not all names can be changed.
  97. Established CustomResourceDefinitionConditionType = "Established"
  98. // NamesAccepted means the names chosen for this CustomResourceDefinition do not conflict with others in
  99. // the group and are therefore accepted.
  100. NamesAccepted CustomResourceDefinitionConditionType = "NamesAccepted"
  101. // Terminating means that the CustomResourceDefinition has been deleted and is cleaning up.
  102. Terminating CustomResourceDefinitionConditionType = "Terminating"
  103. )
  104. // CustomResourceDefinitionCondition contains details for the current condition of this pod.
  105. type CustomResourceDefinitionCondition struct {
  106. // Type is the type of the condition.
  107. Type CustomResourceDefinitionConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=CustomResourceDefinitionConditionType"`
  108. // Status is the status of the condition.
  109. // Can be True, False, Unknown.
  110. Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"`
  111. // Last time the condition transitioned from one status to another.
  112. // +optional
  113. LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"`
  114. // Unique, one-word, CamelCase reason for the condition's last transition.
  115. // +optional
  116. Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
  117. // Human-readable message indicating details about last transition.
  118. // +optional
  119. Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
  120. }
  121. // CustomResourceDefinitionStatus indicates the state of the CustomResourceDefinition
  122. type CustomResourceDefinitionStatus struct {
  123. // Conditions indicate state for particular aspects of a CustomResourceDefinition
  124. Conditions []CustomResourceDefinitionCondition `json:"conditions" protobuf:"bytes,1,opt,name=conditions"`
  125. // AcceptedNames are the names that are actually being used to serve discovery
  126. // They may be different than the names in spec.
  127. AcceptedNames CustomResourceDefinitionNames `json:"acceptedNames" protobuf:"bytes,2,opt,name=acceptedNames"`
  128. // StoredVersions are all versions of CustomResources that were ever persisted. Tracking these
  129. // versions allows a migration path for stored versions in etcd. The field is mutable
  130. // so the migration controller can first finish a migration to another version (i.e.
  131. // that no old objects are left in the storage), and then remove the rest of the
  132. // versions from this list.
  133. // None of the versions in this list can be removed from the spec.Versions field.
  134. StoredVersions []string `json:"storedVersions" protobuf:"bytes,3,rep,name=storedVersions"`
  135. }
  136. // CustomResourceCleanupFinalizer is the name of the finalizer which will delete instances of
  137. // a CustomResourceDefinition
  138. const CustomResourceCleanupFinalizer = "customresourcecleanup.apiextensions.k8s.io"
  139. // +genclient
  140. // +genclient:nonNamespaced
  141. // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
  142. // CustomResourceDefinition represents a resource that should be exposed on the API server. Its name MUST be in the format
  143. // <.spec.name>.<.spec.group>.
  144. type CustomResourceDefinition struct {
  145. metav1.TypeMeta `json:",inline"`
  146. metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
  147. // Spec describes how the user wants the resources to appear
  148. Spec CustomResourceDefinitionSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
  149. // Status indicates the actual state of the CustomResourceDefinition
  150. Status CustomResourceDefinitionStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
  151. }
  152. // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
  153. // CustomResourceDefinitionList is a list of CustomResourceDefinition objects.
  154. type CustomResourceDefinitionList struct {
  155. metav1.TypeMeta `json:",inline"`
  156. metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
  157. // Items individual CustomResourceDefinitions
  158. Items []CustomResourceDefinition `json:"items" protobuf:"bytes,2,rep,name=items"`
  159. }
  160. // CustomResourceValidation is a list of validation methods for CustomResources.
  161. type CustomResourceValidation struct {
  162. // OpenAPIV3Schema is the OpenAPI v3 schema to be validated against.
  163. OpenAPIV3Schema *JSONSchemaProps `json:"openAPIV3Schema,omitempty" protobuf:"bytes,1,opt,name=openAPIV3Schema"`
  164. }
  165. // CustomResourceSubresources defines the status and scale subresources for CustomResources.
  166. type CustomResourceSubresources struct {
  167. // Status denotes the status subresource for CustomResources
  168. Status *CustomResourceSubresourceStatus `json:"status,omitempty" protobuf:"bytes,1,opt,name=status"`
  169. // Scale denotes the scale subresource for CustomResources
  170. Scale *CustomResourceSubresourceScale `json:"scale,omitempty" protobuf:"bytes,2,opt,name=scale"`
  171. }
  172. // CustomResourceSubresourceStatus defines how to serve the status subresource for CustomResources.
  173. // Status is represented by the `.status` JSON path inside of a CustomResource. When set,
  174. // * exposes a /status subresource for the custom resource
  175. // * PUT requests to the /status subresource take a custom resource object, and ignore changes to anything except the status stanza
  176. // * PUT/POST/PATCH requests to the custom resource ignore changes to the status stanza
  177. type CustomResourceSubresourceStatus struct{}
  178. // CustomResourceSubresourceScale defines how to serve the scale subresource for CustomResources.
  179. type CustomResourceSubresourceScale struct {
  180. // SpecReplicasPath defines the JSON path inside of a CustomResource that corresponds to Scale.Spec.Replicas.
  181. // Only JSON paths without the array notation are allowed.
  182. // Must be a JSON Path under .spec.
  183. // If there is no value under the given path in the CustomResource, the /scale subresource will return an error on GET.
  184. SpecReplicasPath string `json:"specReplicasPath" protobuf:"bytes,1,name=specReplicasPath"`
  185. // StatusReplicasPath defines the JSON path inside of a CustomResource that corresponds to Scale.Status.Replicas.
  186. // Only JSON paths without the array notation are allowed.
  187. // Must be a JSON Path under .status.
  188. // If there is no value under the given path in the CustomResource, the status replica value in the /scale subresource
  189. // will default to 0.
  190. StatusReplicasPath string `json:"statusReplicasPath" protobuf:"bytes,2,opt,name=statusReplicasPath"`
  191. // LabelSelectorPath defines the JSON path inside of a CustomResource that corresponds to Scale.Status.Selector.
  192. // Only JSON paths without the array notation are allowed.
  193. // Must be a JSON Path under .status.
  194. // Must be set to work with HPA.
  195. // If there is no value under the given path in the CustomResource, the status label selector value in the /scale
  196. // subresource will default to the empty string.
  197. // +optional
  198. LabelSelectorPath *string `json:"labelSelectorPath,omitempty" protobuf:"bytes,3,opt,name=labelSelectorPath"`
  199. }