aboutsummaryrefslogtreecommitdiff
path: root/vendor/k8s.io/apimachinery/pkg/api
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/k8s.io/apimachinery/pkg/api')
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/equality/semantic.go3
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/errors/errors.go151
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/meta/default.go51
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/meta/errors.go20
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/meta/help.go3
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/meta/interfaces.go5
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/meta/lazy.go121
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/meta/meta.go73
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/meta/multirestmapper.go4
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/meta/priority.go2
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/meta/restmapper.go7
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/meta/unstructured.go18
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go2
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto3
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go25
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/resource/zz_generated.deepcopy.go27
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/validation/objectmeta.go9
17 files changed, 395 insertions, 129 deletions
diff --git a/vendor/k8s.io/apimachinery/pkg/api/equality/semantic.go b/vendor/k8s.io/apimachinery/pkg/api/equality/semantic.go
index 3ebd8c719..f02fa8e43 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/equality/semantic.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/equality/semantic.go
@@ -34,6 +34,9 @@ var Semantic = conversion.EqualitiesOrDie(
// Uninitialized quantities are equivalent to 0 quantities.
return a.Cmp(b) == 0
},
+ func(a, b metav1.MicroTime) bool {
+ return a.UTC() == b.UTC()
+ },
func(a, b metav1.Time) bool {
return a.UTC() == b.UTC()
},
diff --git a/vendor/k8s.io/apimachinery/pkg/api/errors/errors.go b/vendor/k8s.io/apimachinery/pkg/api/errors/errors.go
index 560c889b9..bcc032df9 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/errors/errors.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/errors/errors.go
@@ -28,14 +28,10 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"
)
-// HTTP Status codes not in the golang http package.
const (
- StatusUnprocessableEntity = 422
- StatusTooManyRequests = 429
- // StatusServerTimeout is an indication that a transient server error has
- // occurred and the client *should* retry, with an optional Retry-After
- // header to specify the back off window.
- StatusServerTimeout = 504
+ // StatusTooManyRequests means the server experienced too many requests within a
+ // given window and that the client must wait to perform the action again.
+ StatusTooManyRequests = 429
)
// StatusError is an error intended for consumption by a REST API server; it can also be
@@ -138,6 +134,14 @@ func NewUnauthorized(reason string) *StatusError {
// NewForbidden returns an error indicating the requested action was forbidden
func NewForbidden(qualifiedResource schema.GroupResource, name string, err error) *StatusError {
+ var message string
+ if qualifiedResource.Empty() {
+ message = fmt.Sprintf("forbidden: %v", err)
+ } else if name == "" {
+ message = fmt.Sprintf("%s is forbidden: %v", qualifiedResource.String(), err)
+ } else {
+ message = fmt.Sprintf("%s %q is forbidden: %v", qualifiedResource.String(), name, err)
+ }
return &StatusError{metav1.Status{
Status: metav1.StatusFailure,
Code: http.StatusForbidden,
@@ -147,7 +151,7 @@ func NewForbidden(qualifiedResource schema.GroupResource, name string, err error
Kind: qualifiedResource.Resource,
Name: name,
},
- Message: fmt.Sprintf("%s %q is forbidden: %v", qualifiedResource.String(), name, err),
+ Message: message,
}}
}
@@ -176,6 +180,17 @@ func NewGone(message string) *StatusError {
}}
}
+// NewResourceExpired creates an error that indicates that the requested resource content has expired from
+// the server (usually due to a resourceVersion that is too old).
+func NewResourceExpired(message string) *StatusError {
+ return &StatusError{metav1.Status{
+ Status: metav1.StatusFailure,
+ Code: http.StatusGone,
+ Reason: metav1.StatusReasonExpired,
+ Message: message,
+ }}
+}
+
// NewInvalid returns an error indicating the item is invalid and cannot be processed.
func NewInvalid(qualifiedKind schema.GroupKind, name string, errs field.ErrorList) *StatusError {
causes := make([]metav1.StatusCause, 0, len(errs))
@@ -189,7 +204,7 @@ func NewInvalid(qualifiedKind schema.GroupKind, name string, errs field.ErrorLis
}
return &StatusError{metav1.Status{
Status: metav1.StatusFailure,
- Code: StatusUnprocessableEntity, // RFC 4918: StatusUnprocessableEntity
+ Code: http.StatusUnprocessableEntity,
Reason: metav1.StatusReasonInvalid,
Details: &metav1.StatusDetails{
Group: qualifiedKind.Group,
@@ -211,6 +226,21 @@ func NewBadRequest(reason string) *StatusError {
}}
}
+// NewTooManyRequests creates an error that indicates that the client must try again later because
+// the specified endpoint is not accepting requests. More specific details should be provided
+// if client should know why the failure was limited4.
+func NewTooManyRequests(message string, retryAfterSeconds int) *StatusError {
+ return &StatusError{metav1.Status{
+ Status: metav1.StatusFailure,
+ Code: http.StatusTooManyRequests,
+ Reason: metav1.StatusReasonTooManyRequests,
+ Message: message,
+ Details: &metav1.StatusDetails{
+ RetryAfterSeconds: int32(retryAfterSeconds),
+ },
+ }}
+}
+
// NewServiceUnavailable creates an error that indicates that the requested service is unavailable.
func NewServiceUnavailable(reason string) *StatusError {
return &StatusError{metav1.Status{
@@ -276,7 +306,7 @@ func NewInternalError(err error) *StatusError {
func NewTimeoutError(message string, retryAfterSeconds int) *StatusError {
return &StatusError{metav1.Status{
Status: metav1.StatusFailure,
- Code: StatusServerTimeout,
+ Code: http.StatusGatewayTimeout,
Reason: metav1.StatusReasonTimeout,
Message: fmt.Sprintf("Timeout: %s", message),
Details: &metav1.StatusDetails{
@@ -285,6 +315,18 @@ func NewTimeoutError(message string, retryAfterSeconds int) *StatusError {
}}
}
+// NewTooManyRequestsError returns an error indicating that the request was rejected because
+// the server has received too many requests. Client should wait and retry. But if the request
+// is perishable, then the client should not retry the request.
+func NewTooManyRequestsError(message string) *StatusError {
+ return &StatusError{metav1.Status{
+ Status: metav1.StatusFailure,
+ Code: StatusTooManyRequests,
+ Reason: metav1.StatusReasonTooManyRequests,
+ Message: fmt.Sprintf("Too many requests: %s", message),
+ }}
+}
+
// NewGenericServerResponse returns a new error for server responses that are not in a recognizable form.
func NewGenericServerResponse(code int, verb string, qualifiedResource schema.GroupResource, name, serverMessage string, retryAfterSeconds int, isUnexpectedResponse bool) *StatusError {
reason := metav1.StatusReasonUnknown
@@ -310,17 +352,28 @@ func NewGenericServerResponse(code int, verb string, qualifiedResource schema.Gr
reason = metav1.StatusReasonForbidden
// the server message has details about who is trying to perform what action. Keep its message.
message = serverMessage
+ case http.StatusNotAcceptable:
+ reason = metav1.StatusReasonNotAcceptable
+ // the server message has details about what types are acceptable
+ message = serverMessage
+ case http.StatusUnsupportedMediaType:
+ reason = metav1.StatusReasonUnsupportedMediaType
+ // the server message has details about what types are acceptable
+ message = serverMessage
case http.StatusMethodNotAllowed:
reason = metav1.StatusReasonMethodNotAllowed
message = "the server does not allow this method on the requested resource"
- case StatusUnprocessableEntity:
+ case http.StatusUnprocessableEntity:
reason = metav1.StatusReasonInvalid
message = "the server rejected our request due to an error in our request"
- case StatusServerTimeout:
- reason = metav1.StatusReasonServerTimeout
- message = "the server cannot complete the requested operation at this time, try again later"
- case StatusTooManyRequests:
+ case http.StatusServiceUnavailable:
+ reason = metav1.StatusReasonServiceUnavailable
+ message = "the server is currently unable to handle the request"
+ case http.StatusGatewayTimeout:
reason = metav1.StatusReasonTimeout
+ message = "the server was unable to return a response in the time allotted, but may still be processing the request"
+ case http.StatusTooManyRequests:
+ reason = metav1.StatusReasonTooManyRequests
message = "the server has received too many requests and has asked us to try again later"
default:
if code >= 500 {
@@ -363,71 +416,99 @@ func NewGenericServerResponse(code int, verb string, qualifiedResource schema.Gr
// IsNotFound returns true if the specified error was created by NewNotFound.
func IsNotFound(err error) bool {
- return reasonForError(err) == metav1.StatusReasonNotFound
+ return ReasonForError(err) == metav1.StatusReasonNotFound
}
// IsAlreadyExists determines if the err is an error which indicates that a specified resource already exists.
func IsAlreadyExists(err error) bool {
- return reasonForError(err) == metav1.StatusReasonAlreadyExists
+ return ReasonForError(err) == metav1.StatusReasonAlreadyExists
}
// IsConflict determines if the err is an error which indicates the provided update conflicts.
func IsConflict(err error) bool {
- return reasonForError(err) == metav1.StatusReasonConflict
+ return ReasonForError(err) == metav1.StatusReasonConflict
}
// IsInvalid determines if the err is an error which indicates the provided resource is not valid.
func IsInvalid(err error) bool {
- return reasonForError(err) == metav1.StatusReasonInvalid
+ return ReasonForError(err) == metav1.StatusReasonInvalid
+}
+
+// IsGone is true if the error indicates the requested resource is no longer available.
+func IsGone(err error) bool {
+ return ReasonForError(err) == metav1.StatusReasonGone
+}
+
+// IsResourceExpired is true if the error indicates the resource has expired and the current action is
+// no longer possible.
+func IsResourceExpired(err error) bool {
+ return ReasonForError(err) == metav1.StatusReasonExpired
+}
+
+// IsNotAcceptable determines if err is an error which indicates that the request failed due to an invalid Accept header
+func IsNotAcceptable(err error) bool {
+ return ReasonForError(err) == metav1.StatusReasonNotAcceptable
+}
+
+// IsUnsupportedMediaType determines if err is an error which indicates that the request failed due to an invalid Content-Type header
+func IsUnsupportedMediaType(err error) bool {
+ return ReasonForError(err) == metav1.StatusReasonUnsupportedMediaType
}
// IsMethodNotSupported determines if the err is an error which indicates the provided action could not
// be performed because it is not supported by the server.
func IsMethodNotSupported(err error) bool {
- return reasonForError(err) == metav1.StatusReasonMethodNotAllowed
+ return ReasonForError(err) == metav1.StatusReasonMethodNotAllowed
+}
+
+// IsServiceUnavailable is true if the error indicates the underlying service is no longer available.
+func IsServiceUnavailable(err error) bool {
+ return ReasonForError(err) == metav1.StatusReasonServiceUnavailable
}
// IsBadRequest determines if err is an error which indicates that the request is invalid.
func IsBadRequest(err error) bool {
- return reasonForError(err) == metav1.StatusReasonBadRequest
+ return ReasonForError(err) == metav1.StatusReasonBadRequest
}
// IsUnauthorized determines if err is an error which indicates that the request is unauthorized and
// requires authentication by the user.
func IsUnauthorized(err error) bool {
- return reasonForError(err) == metav1.StatusReasonUnauthorized
+ return ReasonForError(err) == metav1.StatusReasonUnauthorized
}
// IsForbidden determines if err is an error which indicates that the request is forbidden and cannot
// be completed as requested.
func IsForbidden(err error) bool {
- return reasonForError(err) == metav1.StatusReasonForbidden
+ return ReasonForError(err) == metav1.StatusReasonForbidden
}
// IsTimeout determines if err is an error which indicates that request times out due to long
// processing.
func IsTimeout(err error) bool {
- return reasonForError(err) == metav1.StatusReasonTimeout
+ return ReasonForError(err) == metav1.StatusReasonTimeout
}
// IsServerTimeout determines if err is an error which indicates that the request needs to be retried
// by the client.
func IsServerTimeout(err error) bool {
- return reasonForError(err) == metav1.StatusReasonServerTimeout
+ return ReasonForError(err) == metav1.StatusReasonServerTimeout
}
// IsInternalError determines if err is an error which indicates an internal server error.
func IsInternalError(err error) bool {
- return reasonForError(err) == metav1.StatusReasonInternalError
+ return ReasonForError(err) == metav1.StatusReasonInternalError
}
// IsTooManyRequests determines if err is an error which indicates that there are too many requests
// that the server cannot handle.
-// TODO: update IsTooManyRequests() when the TooManyRequests(429) error returned from the API server has a non-empty Reason field
func IsTooManyRequests(err error) bool {
+ if ReasonForError(err) == metav1.StatusReasonTooManyRequests {
+ return true
+ }
switch t := err.(type) {
case APIStatus:
- return t.Status().Code == StatusTooManyRequests
+ return t.Status().Code == http.StatusTooManyRequests
}
return false
}
@@ -455,13 +536,20 @@ func IsUnexpectedObjectError(err error) bool {
}
// SuggestsClientDelay returns true if this error suggests a client delay as well as the
-// suggested seconds to wait, or false if the error does not imply a wait.
+// suggested seconds to wait, or false if the error does not imply a wait. It does not
+// address whether the error *should* be retried, since some errors (like a 3xx) may
+// request delay without retry.
func SuggestsClientDelay(err error) (int, bool) {
switch t := err.(type) {
case APIStatus:
if t.Status().Details != nil {
switch t.Status().Reason {
- case metav1.StatusReasonServerTimeout, metav1.StatusReasonTimeout:
+ // this StatusReason explicitly requests the caller to delay the action
+ case metav1.StatusReasonServerTimeout:
+ return int(t.Status().Details.RetryAfterSeconds), true
+ }
+ // If the client requests that we retry after a certain number of seconds
+ if t.Status().Details.RetryAfterSeconds > 0 {
return int(t.Status().Details.RetryAfterSeconds), true
}
}
@@ -469,7 +557,8 @@ func SuggestsClientDelay(err error) (int, bool) {
return 0, false
}
-func reasonForError(err error) metav1.StatusReason {
+// ReasonForError returns the HTTP status for a particular error.
+func ReasonForError(err error) metav1.StatusReason {
switch t := err.(type) {
case APIStatus:
return t.Status().Reason
diff --git a/vendor/k8s.io/apimachinery/pkg/api/meta/default.go b/vendor/k8s.io/apimachinery/pkg/api/meta/default.go
deleted file mode 100644
index 5ea906a2a..000000000
--- a/vendor/k8s.io/apimachinery/pkg/api/meta/default.go
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-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.
-*/
-
-package meta
-
-import (
- "strings"
-
- "k8s.io/apimachinery/pkg/runtime"
- "k8s.io/apimachinery/pkg/runtime/schema"
- "k8s.io/apimachinery/pkg/util/sets"
-)
-
-// NewDefaultRESTMapperFromScheme instantiates a DefaultRESTMapper based on types registered in the given scheme.
-func NewDefaultRESTMapperFromScheme(defaultGroupVersions []schema.GroupVersion, interfacesFunc VersionInterfacesFunc,
- importPathPrefix string, ignoredKinds, rootScoped sets.String, scheme *runtime.Scheme) *DefaultRESTMapper {
-
- mapper := NewDefaultRESTMapper(defaultGroupVersions, interfacesFunc)
- // enumerate all supported versions, get the kinds, and register with the mapper how to address
- // our resources.
- for _, gv := range defaultGroupVersions {
- for kind, oType := range scheme.KnownTypes(gv) {
- gvk := gv.WithKind(kind)
- // TODO: Remove import path check.
- // We check the import path because we currently stuff both "api" and "extensions" objects
- // into the same group within Scheme since Scheme has no notion of groups yet.
- if !strings.Contains(oType.PkgPath(), importPathPrefix) || ignoredKinds.Has(kind) {
- continue
- }
- scope := RESTScopeNamespace
- if rootScoped.Has(kind) {
- scope = RESTScopeRoot
- }
- mapper.Add(gvk, scope)
- }
- }
- return mapper
-}
diff --git a/vendor/k8s.io/apimachinery/pkg/api/meta/errors.go b/vendor/k8s.io/apimachinery/pkg/api/meta/errors.go
index 1503bd6d8..cbf5d0263 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/meta/errors.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/meta/errors.go
@@ -20,6 +20,7 @@ import (
"fmt"
"k8s.io/apimachinery/pkg/runtime/schema"
+ "k8s.io/apimachinery/pkg/util/sets"
)
// AmbiguousResourceError is returned if the RESTMapper finds multiple matches for a resource
@@ -85,11 +86,26 @@ func (e *NoResourceMatchError) Error() string {
// NoKindMatchError is returned if the RESTMapper can't find any match for a kind
type NoKindMatchError struct {
- PartialKind schema.GroupVersionKind
+ // GroupKind is the API group and kind that was searched
+ GroupKind schema.GroupKind
+ // SearchedVersions is the optional list of versions the search was restricted to
+ SearchedVersions []string
}
func (e *NoKindMatchError) Error() string {
- return fmt.Sprintf("no matches for %v", e.PartialKind)
+ searchedVersions := sets.NewString()
+ for _, v := range e.SearchedVersions {
+ searchedVersions.Insert(schema.GroupVersion{Group: e.GroupKind.Group, Version: v}.String())
+ }
+
+ switch len(searchedVersions) {
+ case 0:
+ return fmt.Sprintf("no matches for kind %q in group %q", e.GroupKind.Kind, e.GroupKind.Group)
+ case 1:
+ return fmt.Sprintf("no matches for kind %q in version %q", e.GroupKind.Kind, searchedVersions.List()[0])
+ default:
+ return fmt.Sprintf("no matches for kind %q in versions %q", e.GroupKind.Kind, searchedVersions.List())
+ }
}
func IsNoMatchError(err error) bool {
diff --git a/vendor/k8s.io/apimachinery/pkg/api/meta/help.go b/vendor/k8s.io/apimachinery/pkg/api/meta/help.go
index 9e0fb152a..c70b3d2b6 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/meta/help.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/meta/help.go
@@ -67,6 +67,9 @@ func GetItemsPtr(list runtime.Object) (interface{}, error) {
// EachListItem invokes fn on each runtime.Object in the list. Any error immediately terminates
// the loop.
func EachListItem(obj runtime.Object, fn func(runtime.Object) error) error {
+ if unstructured, ok := obj.(runtime.Unstructured); ok {
+ return unstructured.EachListItem(fn)
+ }
// TODO: Change to an interface call?
itemsPtr, err := GetItemsPtr(obj)
if err != nil {
diff --git a/vendor/k8s.io/apimachinery/pkg/api/meta/interfaces.go b/vendor/k8s.io/apimachinery/pkg/api/meta/interfaces.go
index b2c8c97b1..5dc9d89e6 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/meta/interfaces.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/meta/interfaces.go
@@ -36,7 +36,7 @@ type ListMetaAccessor interface {
// List lets you work with list metadata from any of the versioned or
// internal API objects. Attempting to set or retrieve a field on an object that does
// not support that field will be a no-op and return a default value.
-type List metav1.List
+type List metav1.ListInterface
// Type exposes the type and APIVersion of versioned or internal API objects.
type Type metav1.Type
@@ -75,6 +75,9 @@ type MetadataAccessor interface {
Annotations(obj runtime.Object) (map[string]string, error)
SetAnnotations(obj runtime.Object, annotations map[string]string) error
+ Continue(obj runtime.Object) (string, error)
+ SetContinue(obj runtime.Object, c string) error
+
runtime.ResourceVersioner
}
diff --git a/vendor/k8s.io/apimachinery/pkg/api/meta/lazy.go b/vendor/k8s.io/apimachinery/pkg/api/meta/lazy.go
new file mode 100644
index 000000000..7f92f39a4
--- /dev/null
+++ b/vendor/k8s.io/apimachinery/pkg/api/meta/lazy.go
@@ -0,0 +1,121 @@
+/*
+Copyright 2017 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.
+*/
+
+package meta
+
+import (
+ "sync"
+
+ "k8s.io/apimachinery/pkg/runtime"
+ "k8s.io/apimachinery/pkg/runtime/schema"
+)
+
+// lazyObject defers loading the mapper and typer until necessary.
+type lazyObject struct {
+ loader func() (RESTMapper, runtime.ObjectTyper, error)
+
+ lock sync.Mutex
+ loaded bool
+ err error
+ mapper RESTMapper
+ typer runtime.ObjectTyper
+}
+
+// NewLazyObjectLoader handles unrecoverable errors when creating a RESTMapper / ObjectTyper by
+// returning those initialization errors when the interface methods are invoked. This defers the
+// initialization and any server calls until a client actually needs to perform the action.
+func NewLazyObjectLoader(fn func() (RESTMapper, runtime.ObjectTyper, error)) (RESTMapper, runtime.ObjectTyper) {
+ obj := &lazyObject{loader: fn}
+ return obj, obj
+}
+
+// init lazily loads the mapper and typer, returning an error if initialization has failed.
+func (o *lazyObject) init() error {
+ o.lock.Lock()
+ defer o.lock.Unlock()
+ if o.loaded {
+ return o.err
+ }
+ o.mapper, o.typer, o.err = o.loader()
+ o.loaded = true
+ return o.err
+}
+
+var _ RESTMapper = &lazyObject{}
+var _ runtime.ObjectTyper = &lazyObject{}
+
+func (o *lazyObject) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error) {
+ if err := o.init(); err != nil {
+ return schema.GroupVersionKind{}, err
+ }
+ return o.mapper.KindFor(resource)
+}
+
+func (o *lazyObject) KindsFor(resource schema.GroupVersionResource) ([]schema.GroupVersionKind, error) {
+ if err := o.init(); err != nil {
+ return []schema.GroupVersionKind{}, err
+ }
+ return o.mapper.KindsFor(resource)
+}
+
+func (o *lazyObject) ResourceFor(input schema.GroupVersionResource) (schema.GroupVersionResource, error) {
+ if err := o.init(); err != nil {
+ return schema.GroupVersionResource{}, err
+ }
+ return o.mapper.ResourceFor(input)
+}
+
+func (o *lazyObject) ResourcesFor(input schema.GroupVersionResource) ([]schema.GroupVersionResource, error) {
+ if err := o.init(); err != nil {
+ return []schema.GroupVersionResource{}, err
+ }
+ return o.mapper.ResourcesFor(input)
+}
+
+func (o *lazyObject) RESTMapping(gk schema.GroupKind, versions ...string) (*RESTMapping, error) {
+ if err := o.init(); err != nil {
+ return nil, err
+ }
+ return o.mapper.RESTMapping(gk, versions...)
+}
+
+func (o *lazyObject) RESTMappings(gk schema.GroupKind, versions ...string) ([]*RESTMapping, error) {
+ if err := o.init(); err != nil {
+ return nil, err
+ }
+ return o.mapper.RESTMappings(gk, versions...)
+}
+
+func (o *lazyObject) ResourceSingularizer(resource string) (singular string, err error) {
+ if err := o.init(); err != nil {
+ return "", err
+ }
+ return o.mapper.ResourceSingularizer(resource)
+}
+
+func (o *lazyObject) ObjectKinds(obj runtime.Object) ([]schema.GroupVersionKind, bool, error) {
+ if err := o.init(); err != nil {
+ return nil, false, err
+ }
+ return o.typer.ObjectKinds(obj)
+}
+
+func (o *lazyObject) Recognizes(gvk schema.GroupVersionKind) bool {
+ if err := o.init(); err != nil {
+ return false
+ }
+ return o.typer.Recognizes(gvk)
+}
diff --git a/vendor/k8s.io/apimachinery/pkg/api/meta/meta.go b/vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
index 45d850ea8..b9670071c 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
@@ -23,7 +23,7 @@ import (
"github.com/golang/glog"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- metav1alpha1 "k8s.io/apimachinery/pkg/apis/meta/v1alpha1"
+ metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -34,33 +34,59 @@ import (
// interfaces.
var errNotList = fmt.Errorf("object does not implement the List interfaces")
-// ListAccessor returns a List interface for the provided object or an error if the object does
+var errNotCommon = fmt.Errorf("object does not implement the common interface for accessing the SelfLink")
+
+// CommonAccessor returns a Common interface for the provided object or an error if the object does
// not provide List.
-// IMPORTANT: Objects are a superset of lists, so all Objects return List metadata. Do not use this
-// check to determine whether an object *is* a List.
// TODO: return bool instead of error
-func ListAccessor(obj interface{}) (List, error) {
+func CommonAccessor(obj interface{}) (metav1.Common, error) {
switch t := obj.(type) {
case List:
return t, nil
- case metav1.List:
+ case metav1.ListInterface:
return t, nil
case ListMetaAccessor:
if m := t.GetListMeta(); m != nil {
return m, nil
}
- return nil, errNotList
+ return nil, errNotCommon
case metav1.ListMetaAccessor:
if m := t.GetListMeta(); m != nil {
return m, nil
}
- return nil, errNotList
+ return nil, errNotCommon
case metav1.Object:
return t, nil
case metav1.ObjectMetaAccessor:
if m := t.GetObjectMeta(); m != nil {
return m, nil
}
+ return nil, errNotCommon
+ default:
+ return nil, errNotCommon
+ }
+}
+
+// ListAccessor returns a List interface for the provided object or an error if the object does
+// not provide List.
+// IMPORTANT: Objects are NOT a superset of lists. Do not use this check to determine whether an
+// object *is* a List.
+// TODO: return bool instead of error
+func ListAccessor(obj interface{}) (List, error) {
+ switch t := obj.(type) {
+ case List:
+ return t, nil
+ case metav1.ListInterface:
+ return t, nil
+ case ListMetaAccessor:
+ if m := t.GetListMeta(); m != nil {
+ return m, nil
+ }
+ return nil, errNotList
+ case metav1.ListMetaAccessor:
+ if m := t.GetListMeta(); m != nil {
+ return m, nil
+ }
return nil, errNotList
default:
return nil, errNotList
@@ -92,12 +118,12 @@ func Accessor(obj interface{}) (metav1.Object, error) {
// AsPartialObjectMetadata takes the metav1 interface and returns a partial object.
// TODO: consider making this solely a conversion action.
-func AsPartialObjectMetadata(m metav1.Object) *metav1alpha1.PartialObjectMetadata {
+func AsPartialObjectMetadata(m metav1.Object) *metav1beta1.PartialObjectMetadata {
switch t := m.(type) {
case *metav1.ObjectMeta:
- return &metav1alpha1.PartialObjectMetadata{ObjectMeta: *t}
+ return &metav1beta1.PartialObjectMetadata{ObjectMeta: *t}
default:
- return &metav1alpha1.PartialObjectMetadata{
+ return &metav1beta1.PartialObjectMetadata{
ObjectMeta: metav1.ObjectMeta{
Name: m.GetName(),
GenerateName: m.GetGenerateName(),
@@ -274,7 +300,7 @@ func (resourceAccessor) SetUID(obj runtime.Object, uid types.UID) error {
}
func (resourceAccessor) SelfLink(obj runtime.Object) (string, error) {
- accessor, err := ListAccessor(obj)
+ accessor, err := CommonAccessor(obj)
if err != nil {
return "", err
}
@@ -282,7 +308,7 @@ func (resourceAccessor) SelfLink(obj runtime.Object) (string, error) {
}
func (resourceAccessor) SetSelfLink(obj runtime.Object, selfLink string) error {
- accessor, err := ListAccessor(obj)
+ accessor, err := CommonAccessor(obj)
if err != nil {
return err
}
@@ -325,7 +351,7 @@ func (resourceAccessor) SetAnnotations(obj runtime.Object, annotations map[strin
}
func (resourceAccessor) ResourceVersion(obj runtime.Object) (string, error) {
- accessor, err := ListAccessor(obj)
+ accessor, err := CommonAccessor(obj)
if err != nil {
return "", err
}
@@ -333,7 +359,7 @@ func (resourceAccessor) ResourceVersion(obj runtime.Object) (string, error) {
}
func (resourceAccessor) SetResourceVersion(obj runtime.Object, version string) error {
- accessor, err := ListAccessor(obj)
+ accessor, err := CommonAccessor(obj)
if err != nil {
return err
}
@@ -341,6 +367,23 @@ func (resourceAccessor) SetResourceVersion(obj runtime.Object, version string) e
return nil
}
+func (resourceAccessor) Continue(obj runtime.Object) (string, error) {
+ accessor, err := ListAccessor(obj)
+ if err != nil {
+ return "", err
+ }
+ return accessor.GetContinue(), nil
+}
+
+func (resourceAccessor) SetContinue(obj runtime.Object, version string) error {
+ accessor, err := ListAccessor(obj)
+ if err != nil {
+ return err
+ }
+ accessor.SetContinue(version)
+ return nil
+}
+
// extractFromOwnerReference extracts v to o. v is the OwnerReferences field of an object.
func extractFromOwnerReference(v reflect.Value, o *metav1.OwnerReference) error {
if err := runtime.Field(v, "APIVersion", &o.APIVersion); err != nil {
diff --git a/vendor/k8s.io/apimachinery/pkg/api/meta/multirestmapper.go b/vendor/k8s.io/apimachinery/pkg/api/meta/multirestmapper.go
index 679098fe5..6b01bf197 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/meta/multirestmapper.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/meta/multirestmapper.go
@@ -179,7 +179,7 @@ func (m MultiRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (*
if len(errors) > 0 {
return nil, utilerrors.NewAggregate(errors)
}
- return nil, &NoKindMatchError{PartialKind: gk.WithVersion("")}
+ return nil, &NoKindMatchError{GroupKind: gk, SearchedVersions: versions}
}
// RESTMappings returns all possible RESTMappings for the provided group kind, or an error
@@ -204,7 +204,7 @@ func (m MultiRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) (
return nil, utilerrors.NewAggregate(errors)
}
if len(allMappings) == 0 {
- return nil, &NoKindMatchError{PartialKind: gk.WithVersion("")}
+ return nil, &NoKindMatchError{GroupKind: gk, SearchedVersions: versions}
}
return allMappings, nil
}
diff --git a/vendor/k8s.io/apimachinery/pkg/api/meta/priority.go b/vendor/k8s.io/apimachinery/pkg/api/meta/priority.go
index 2a14aa7ab..df28e64ff 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/meta/priority.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/meta/priority.go
@@ -153,7 +153,7 @@ func kindMatches(pattern schema.GroupVersionKind, kind schema.GroupVersionKind)
}
func (m PriorityRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (mapping *RESTMapping, err error) {
- mappings, err := m.Delegate.RESTMappings(gk)
+ mappings, err := m.Delegate.RESTMappings(gk, versions...)
if err != nil {
return nil, err
}
diff --git a/vendor/k8s.io/apimachinery/pkg/api/meta/restmapper.go b/vendor/k8s.io/apimachinery/pkg/api/meta/restmapper.go
index c6b2597dd..ff945acd1 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/meta/restmapper.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/meta/restmapper.go
@@ -117,7 +117,10 @@ func NewDefaultRESTMapper(defaultGroupVersions []schema.GroupVersion, f VersionI
func (m *DefaultRESTMapper) Add(kind schema.GroupVersionKind, scope RESTScope) {
plural, singular := UnsafeGuessKindToResource(kind)
+ m.AddSpecific(kind, plural, singular, scope)
+}
+func (m *DefaultRESTMapper) AddSpecific(kind schema.GroupVersionKind, plural, singular schema.GroupVersionResource, scope RESTScope) {
m.singularToPlural[singular] = plural
m.pluralToSingular[plural] = singular
@@ -469,7 +472,7 @@ func (m *DefaultRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string)
return nil, err
}
if len(mappings) == 0 {
- return nil, &NoKindMatchError{PartialKind: gk.WithVersion("")}
+ return nil, &NoKindMatchError{GroupKind: gk, SearchedVersions: versions}
}
// since we rely on RESTMappings method
// take the first match and return to the caller
@@ -507,7 +510,7 @@ func (m *DefaultRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string
}
if len(potentialGVK) == 0 {
- return nil, &NoKindMatchError{PartialKind: gk.WithVersion("")}
+ return nil, &NoKindMatchError{GroupKind: gk, SearchedVersions: versions}
}
for _, gvk := range potentialGVK {
diff --git a/vendor/k8s.io/apimachinery/pkg/api/meta/unstructured.go b/vendor/k8s.io/apimachinery/pkg/api/meta/unstructured.go
index 3ebf24815..4e13efea3 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/meta/unstructured.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/meta/unstructured.go
@@ -21,8 +21,24 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
)
+// InterfacesForUnstructuredConversion returns VersionInterfaces suitable for
+// dealing with unstructured.Unstructured objects and supports conversion
+// from typed objects (provided by parent) to untyped objects.
+func InterfacesForUnstructuredConversion(parent VersionInterfacesFunc) VersionInterfacesFunc {
+ return func(version schema.GroupVersion) (*VersionInterfaces, error) {
+ if i, err := parent(version); err == nil {
+ return &VersionInterfaces{
+ ObjectConvertor: i.ObjectConvertor,
+ MetadataAccessor: NewAccessor(),
+ }, nil
+ }
+ return InterfacesForUnstructured(version)
+ }
+}
+
// InterfacesForUnstructured returns VersionInterfaces suitable for
-// dealing with unstructured.Unstructured objects.
+// dealing with unstructured.Unstructured objects. It will return errors for
+// other conversions.
func InterfacesForUnstructured(schema.GroupVersion) (*VersionInterfaces, error) {
return &VersionInterfaces{
ObjectConvertor: &unstructured.UnstructuredObjectConverter{},
diff --git a/vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go b/vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
index 8b2e338a7..6de71e508 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
@@ -1,5 +1,5 @@
/*
-Copyright 2017 The Kubernetes Authors.
+Copyright 2018 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.
diff --git a/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto b/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto
index 608299da4..40185777e 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto
+++ b/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto
@@ -1,5 +1,5 @@
/*
-Copyright 2017 The Kubernetes Authors.
+Copyright 2018 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.
@@ -87,6 +87,7 @@ option go_package = "resource";
// +protobuf.embed=string
// +protobuf.options.marshal=false
// +protobuf.options.(gogoproto.goproto_stringer)=false
+// +k8s:deepcopy-gen=true
// +k8s:openapi-gen=true
message Quantity {
optional string string = 1;
diff --git a/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go b/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
index 3a9560882..6a8bb9972 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
@@ -27,9 +27,7 @@ import (
flag "github.com/spf13/pflag"
- "github.com/go-openapi/spec"
inf "gopkg.in/inf.v0"
- "k8s.io/apimachinery/pkg/openapi"
)
// Quantity is a fixed-point representation of a number.
@@ -93,6 +91,7 @@ import (
// +protobuf.embed=string
// +protobuf.options.marshal=false
// +protobuf.options.(gogoproto.goproto_stringer)=false
+// +k8s:deepcopy-gen=true
// +k8s:openapi-gen=true
type Quantity struct {
// i is the quantity in int64 scaled form, if d.Dec == nil
@@ -398,24 +397,22 @@ func (q Quantity) DeepCopy() Quantity {
return q
}
-// OpenAPIDefinition returns openAPI definition for this type.
-func (_ Quantity) OpenAPIDefinition() openapi.OpenAPIDefinition {
- return openapi.OpenAPIDefinition{
- Schema: spec.Schema{
- SchemaProps: spec.SchemaProps{
- Type: []string{"string"},
- Format: "",
- },
- },
- }
-}
+// OpenAPISchemaType is used by the kube-openapi generator when constructing
+// the OpenAPI spec of this type.
+//
+// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators
+func (_ Quantity) OpenAPISchemaType() []string { return []string{"string"} }
+
+// OpenAPISchemaFormat is used by the kube-openapi generator when constructing
+// the OpenAPI spec of this type.
+func (_ Quantity) OpenAPISchemaFormat() string { return "" }
// CanonicalizeBytes returns the canonical form of q and its suffix (see comment on Quantity).
//
// Note about BinarySI:
// * If q.Format is set to BinarySI and q.Amount represents a non-zero value between
// -1 and +1, it will be emitted as if q.Format were DecimalSI.
-// * Otherwise, if q.Format is set to BinarySI, frational parts of q.Amount will be
+// * Otherwise, if q.Format is set to BinarySI, fractional parts of q.Amount will be
// rounded up. (1.1i becomes 2i.)
func (q *Quantity) CanonicalizeBytes(out []byte) (result, suffix []byte) {
if q.IsZero() {
diff --git a/vendor/k8s.io/apimachinery/pkg/api/resource/zz_generated.deepcopy.go b/vendor/k8s.io/apimachinery/pkg/api/resource/zz_generated.deepcopy.go
new file mode 100644
index 000000000..186d9007e
--- /dev/null
+++ b/vendor/k8s.io/apimachinery/pkg/api/resource/zz_generated.deepcopy.go
@@ -0,0 +1,27 @@
+// +build !ignore_autogenerated
+
+/*
+Copyright 2018 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 file was autogenerated by deepcopy-gen. Do not edit it manually!
+
+package resource
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *Quantity) DeepCopyInto(out *Quantity) {
+ *out = in.DeepCopy()
+ return
+}
diff --git a/vendor/k8s.io/apimachinery/pkg/api/validation/objectmeta.go b/vendor/k8s.io/apimachinery/pkg/api/validation/objectmeta.go
index 84bd9cded..3c32a937a 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/validation/objectmeta.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/validation/objectmeta.go
@@ -195,14 +195,9 @@ func ValidateInitializers(initializers *metav1.Initializers, fldPath *field.Path
return allErrs
}
for i, initializer := range initializers.Pending {
- for _, msg := range validation.IsQualifiedName(initializer.Name) {
- allErrs = append(allErrs, field.Invalid(fldPath.Child("pending").Index(i), initializer.Name, msg))
- }
+ allErrs = append(allErrs, validation.IsFullyQualifiedName(fldPath.Child("pending").Index(i).Child("name"), initializer.Name)...)
}
allErrs = append(allErrs, validateInitializersResult(initializers.Result, fldPath.Child("result"))...)
- if len(initializers.Pending) == 0 && initializers.Result == nil {
- allErrs = append(allErrs, field.Invalid(fldPath.Child("pending"), nil, "must be non-empty when result is not set"))
- }
return allErrs
}
@@ -288,7 +283,7 @@ func ValidateObjectMetaAccessorUpdate(newMeta, oldMeta metav1.Object, fldPath *f
if newMeta.GetDeletionGracePeriodSeconds() != nil && (oldMeta.GetDeletionGracePeriodSeconds() == nil || *newMeta.GetDeletionGracePeriodSeconds() != *oldMeta.GetDeletionGracePeriodSeconds()) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("deletionGracePeriodSeconds"), newMeta.GetDeletionGracePeriodSeconds(), "field is immutable; may only be changed via deletion"))
}
- if newMeta.GetDeletionTimestamp() != nil && (oldMeta.GetDeletionTimestamp() == nil || !newMeta.GetDeletionTimestamp().Equal(*oldMeta.GetDeletionTimestamp())) {
+ if newMeta.GetDeletionTimestamp() != nil && (oldMeta.GetDeletionTimestamp() == nil || !newMeta.GetDeletionTimestamp().Equal(oldMeta.GetDeletionTimestamp())) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("deletionTimestamp"), newMeta.GetDeletionTimestamp(), "field is immutable; may only be changed via deletion"))
}