-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go-f015bb5ae9a1fb1082cfc90596f06cdba8acab315785ff5cfc1bc73d09e8562a
313 lines (276 loc) · 14.9 KB
/
types.go-f015bb5ae9a1fb1082cfc90596f06cdba8acab315785ff5cfc1bc73d09e8562a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
// PUBLISH-CODE
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This code is from github.com/kubernetes/apimachinery/pkg/apis/meta/v1/types.go
// and modified.
package v1
import (
"go.tectonic.network/lib/k8s/imp/apimachinery/types"
)
// ObjectNameField is the name of the object
const ObjectNameField = "metadata.name"
// TypeMeta describes an individual object in an API response or
// request with strings representing the type of the object and its
// API schema version.
type TypeMeta struct {
// Kind is a string value representing the REST resource this
// object represents. Cannot be updated. In CamelCase.
Kind string `json:"kind"`
// APIVersion defines the versioned schema of this representation of an object.
APIVersion string `json:"apiVersion"`
}
// ObjectMeta is metadata that all persisted resources must have,
// which includes all objects users must create.
type ObjectMeta struct {
// Name must be unique within a namespace. Is required when
// creating resources, although some resources may allow a
// client to request the generation of an appropriate name
// automatically. Name is primarily intended for creation
// idempotence and configuration definition. Cannot be
// updated.
Name string `json:"name,omitempty"`
// Namespace defines the space within which each name must be
// unique. An empty namespace is equivalent to the "default"
// namespace, but "default" is the canonical representation.
// Must be a DNS_LABEL. Cannot be updated.
Namespace string `json:"namespace,omitempty"`
// UID is the unique in time and space value for this
// object. It is typically generated by the server on
// successful creation of a resource and is not allowed to
// change on PUT operations.
UID types.UID `json:"uid,omitempty"`
// An opaque value that represents the internal version of
// this object that can be used by clients to determine when
// objects have changed. May be used for optimistic
// concurrency, change detection, and the watch operation on a
// resource or set of resources. Clients must treat these
// values as opaque and passed unmodified back to the server.
// They may only be valid for a particular resource or set of
// resources.
//
// Populated by the system. Read-only.
ResourceVersion string `json:"resourceVersion,omitempty"`
// CreationTimestamp is a timestamp representing the server
// time when this object was created. It is not guaranteed to
// be set in happens-before order across separate operations.
// Clients may not set this value. It is represented in
// RFC3339 form and is in UTC.
//
// Populated by the system. Read-only.
CreationTimestamp Time `json:"creationTimestamp,omitempty"`
// DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This
// field is set by the server when a graceful deletion is requested by the user, and is not
// directly settable by a client. The resource is expected to be deleted (no longer visible
// from resource lists, and not reachable by name) after the time in this field, once the
// finalizers list is empty. As long as the finalizers list contains items, deletion is blocked.
// Once the deletionTimestamp is set, this value may not be unset or be set further into the
// future, although it may be shortened or the resource may be deleted prior to this time.
// For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react
// by sending a graceful termination signal to the containers in the pod. After that 30 seconds,
// the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup,
// remove the pod from the API. In the presence of network partitions, this object may still
// exist after this timestamp, until an administrator or automated process can determine the
// resource is fully terminated.
// If not set, graceful deletion of the object has not been requested.
//
// Populated by the system when a graceful deletion is requested.
// Read-only.
DeletionTimestamp *Time `json:"deletionTimestamp,omitempty"`
// Map of string keys and values that can be used to organize
// and categorize (scope and select) objects. May match
// selectors of replication controllers and services.
Labels map[string]string `json:"labels,omitempty"`
// Annotations is an unstructured key value map stored with a
// resource that may be set by external tools to store and
// retrieve arbitrary metadata. They are not queryable and
// should be preserved when modifying objects.
Annotations map[string]string `json:"annotations,omitempty"`
// List of objects depended by this object. If ALL objects in
// the list have been deleted, this object will be garbage
// collected. If this object is managed by a controller, then
// an entry in this list will point to this controller, with
// the controller field set to true. There cannot be more
// than one managing controller.
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"`
// Must be empty before the object is deleted from the registry. Each entry
// is an identifier for the responsible component that will remove the entry
// from the list. If the deletionTimestamp of the object is non-nil, entries
// in this list can only be removed.
// Finalizers may be processed and removed in any order. Order is NOT enforced
// because it introduces significant risk of stuck finalizers.
// finalizers is a shared field, any actor with permission can reorder it.
// If the finalizer list is processed in order, then this can lead to a situation
// in which the component responsible for the first finalizer in the list is
// waiting for a signal (field value, external system, or other) produced by a
// component responsible for a finalizer later in the list, resulting in a deadlock.
// Without enforced ordering finalizers are free to order amongst themselves and
// are not vulnerable to ordering changes in the list.
Finalizers []string `json:"finalizers,omitempty" patchStrategy:"merge" protobuf:"bytes,14,rep,name=finalizers"`
}
const (
// NamespaceDefault means the object is in the default namespace which is applied when not specified by clients
NamespaceDefault = "default"
// NamespaceAll is the default argument to specify on a context when you want to list or filter resources across all namespaces
NamespaceAll = ""
// NamespaceNone is the argument for a context when there is no namespace.
NamespaceNone = ""
// NamespaceSystem is the system namespace where we place system components.
NamespaceSystem = "kube-system"
// NamespacePublic is the namespace where we place public info (ConfigMaps)
NamespacePublic = "kube-public"
)
// OwnerReference contains enough information to let you identify an
// owning object. An owning object must be in the same namespace as
// the dependent, or be cluster-scoped, so there is no namespace
// field.
type OwnerReference struct {
// API version of the referent.
APIVersion string `json:"apiVersion"`
// Kind of the referent.
Kind string `json:"kind"`
// Name of the referent.
Name string `json:"name"`
// UID of the referent.
UID types.UID `json:"uid"`
}
// ListMeta describes metadata that synthetic resources must have, including lists and
// various status objects. A resource may have only one of {ObjectMeta, ListMeta}.
type ListMeta struct {
// String that identifies the server's internal version of
// this object that can be used by clients to determine when
// objects have changed. Value must be treated as opaque by
// clients and passed unmodified back to the server.
// Populated by the system. Read-only.
ResourceVersion string `json:"resourceVersion,omitempty"`
// continue may be set if the user set a limit on the number
// of items returned, and indicates that the server has more
// data available. The value is opaque and may be used to
// issue another request to the endpoint that served this list
// to retrieve the next set of available objects. Continuing a
// consistent list may not be possible if the server
// configuration has changed or more than a few minutes have
// passed. The resourceVersion field returned when using this
// continue value will be identical to the value in the first
// response, unless you have received this token from an error
// message.
Continue string `json:"continue,omitempty"`
}
// LabelSelector is a label query over a set of resources. The result
// of matchLabels and matchExpressions are ANDed. An empty label
// selector matches all objects. A null label selector matches no
// objects.
type LabelSelector struct {
// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
// map is equivalent to an element of matchExpressions, whose key field is "key", the
// operator is "In", and the values array contains only "value". The requirements are ANDed.
MatchLabels map[string]string `json:"matchLabels,omitempty"`
// matchExpressions is a list of label selector requirements. The requirements are ANDed.
MatchExpressions []LabelSelectorRequirement `json:"matchExpressions,omitempty"`
}
// LabelSelectorRequirement is a selector that contains values, a key,
// and an operator that relates the key and values.
type LabelSelectorRequirement struct {
// key is the label key that the selector applies to.
Key string `json:"key" patchStrategy:"merge" patchMergeKey:"key"`
// operator represents a key's relationship to a set of values.
// Valid operators are In, NotIn, Exists and DoesNotExist.
Operator LabelSelectorOperator `json:"operator"`
// values is an array of string values. If the operator is In or NotIn,
// the values array must be non-empty. If the operator is Exists or DoesNotExist,
// the values array must be empty. This array is replaced during a strategic
// merge patch.
Values []string `json:"values,omitempty"`
}
// LabelSelectorOperator is the set of operators that can be used in a selector requirement.
type LabelSelectorOperator string
// Allowed operators for label selectors
const (
LabelSelectorOpIn LabelSelectorOperator = "In"
LabelSelectorOpNotIn LabelSelectorOperator = "NotIn"
LabelSelectorOpExists LabelSelectorOperator = "Exists"
LabelSelectorOpDoesNotExist LabelSelectorOperator = "DoesNotExist"
)
// CauseType is a machine readable value providing more detail about what
// occurred in a status response. An operation may have multiple causes for a
// status (whether Failure or Success).
type CauseType string
const (
// CauseTypeFieldValueNotFound is used to report failure to find a requested value
// (e.g. looking up an ID).
CauseTypeFieldValueNotFound CauseType = "FieldValueNotFound"
// CauseTypeFieldValueRequired is used to report required values that are not
// provided (e.g. empty strings, null values, or empty arrays).
CauseTypeFieldValueRequired CauseType = "FieldValueRequired"
// CauseTypeFieldValueDuplicate is used to report collisions of values that must be
// unique (e.g. unique IDs).
CauseTypeFieldValueDuplicate CauseType = "FieldValueDuplicate"
// CauseTypeFieldValueInvalid is used to report malformed values (e.g. failed regex
// match).
CauseTypeFieldValueInvalid CauseType = "FieldValueInvalid"
// CauseTypeFieldValueNotSupported is used to report valid (as per formatting rules)
// values that can not be handled (e.g. an enumerated string).
CauseTypeFieldValueNotSupported CauseType = "FieldValueNotSupported"
// CauseTypeUnexpectedServerResponse is used to report when the server responded to the client
// without the expected return type. The presence of this cause indicates the error may be
// due to an intervening proxy or the server software malfunctioning.
CauseTypeUnexpectedServerResponse CauseType = "UnexpectedServerResponse"
// CauseTypeFieldManagerConflict is used to report when another client claims to manage this field,
// It should only be returned for a request using server-side apply.
CauseTypeFieldManagerConflict CauseType = "FieldManagerConflict"
// CauseTypeResourceVersionTooLarge is used to report that the requested resource version
// is newer than the data observed by the API server, so the request cannot be served.
CauseTypeResourceVersionTooLarge CauseType = "ResourceVersionTooLarge"
)
// Status is a return value for calls that don't return other objects.
type Status struct {
// Kind of the referent.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
Kind string `json:"kind"`
// A machine-readable description of why this operation is in the
// "Failure" status. If this value is empty there
// is no information available. A Reason clarifies an HTTP status
// code but does not override it.
Reason StatusReason `json:"reason,omitempty"`
// A human-readable string giving more intel into the problem
Message string `json:"message,omitempty"`
}
// StatusReason is an enumeration of possible failure causes. Each StatusReason
// must map to a single HTTP status code, but multiple reasons may map
// to the same HTTP status code.
type StatusReason string
const (
// StatusReasonNotFound means one or more resources required for this operation
// could not be found.
StatusReasonNotFound StatusReason = "NotFound"
// StatusReasonUnauthorized means the server can be reached and understood the request, but requires
// the user to present appropriate authorization credentials (identified by the WWW-Authenticate header)
// in order for the action to be completed. If the user has specified credentials on the request, the
// server considers them insufficient.
StatusReasonUnauthorized StatusReason = "Unauthorized"
// StatusReasonForbidden means the server can be reached and understood the request, but refuses
// to take any further action. It is the result of the server being configured to deny access for some reason
// to the requested resource by the client.
StatusReasonForbidden StatusReason = "Forbidden"
// StatusReasonInvalid means the requested create or update operation cannot be
// completed due to invalid data provided as part of the request. The client may
// need to alter the request. When set, the client may use the StatusDetails
// message field as a summary of the issues encountered.
// Details (optional):
// "kind" string - the kind attribute of the invalid resource
// "id" string - the identifier of the invalid resource
// "causes" - one or more StatusCause entries indicating the data in the
// provided resource that was invalid. The code, message, and
// field attributes will be set.
// Status code 422
StatusReasonInvalid StatusReason = "Invalid"
)