Update godeps
This commit is contained in:
parent
1c8773fc98
commit
1bc383f9c5
1723 changed files with 287976 additions and 411028 deletions
30
vendor/k8s.io/kubernetes/pkg/runtime/scheme.go
generated
vendored
30
vendor/k8s.io/kubernetes/pkg/runtime/scheme.go
generated
vendored
|
|
@ -61,6 +61,10 @@ type Scheme struct {
|
|||
// resource field labels in that version to internal version.
|
||||
fieldLabelConversionFuncs map[string]map[string]FieldLabelConversionFunc
|
||||
|
||||
// defaulterFuncs is an array of interfaces to be called with an object to provide defaulting
|
||||
// the provided object must be a pointer.
|
||||
defaulterFuncs map[reflect.Type]func(interface{})
|
||||
|
||||
// converter stores all registered conversion functions. It also has
|
||||
// default coverting behavior.
|
||||
converter *conversion.Converter
|
||||
|
|
@ -82,6 +86,7 @@ func NewScheme() *Scheme {
|
|||
unversionedKinds: map[string]reflect.Type{},
|
||||
cloner: conversion.NewCloner(),
|
||||
fieldLabelConversionFuncs: map[string]map[string]FieldLabelConversionFunc{},
|
||||
defaulterFuncs: map[reflect.Type]func(interface{}){},
|
||||
}
|
||||
s.converter = conversion.NewConverter(s.nameFunc)
|
||||
|
||||
|
|
@ -421,6 +426,22 @@ func (s *Scheme) AddDefaultingFuncs(defaultingFuncs ...interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// AddTypeDefaultingFuncs registers a function that is passed a pointer to an
|
||||
// object and can default fields on the object. These functions will be invoked
|
||||
// when Default() is called. The function will never be called unless the
|
||||
// defaulted object matches srcType. If this function is invoked twice with the
|
||||
// same srcType, the fn passed to the later call will be used instead.
|
||||
func (s *Scheme) AddTypeDefaultingFunc(srcType Object, fn func(interface{})) {
|
||||
s.defaulterFuncs[reflect.TypeOf(srcType)] = fn
|
||||
}
|
||||
|
||||
// Default sets defaults on the provided Object.
|
||||
func (s *Scheme) Default(src Object) {
|
||||
if fn, ok := s.defaulterFuncs[reflect.TypeOf(src)]; ok {
|
||||
fn(src)
|
||||
}
|
||||
}
|
||||
|
||||
// Copy does a deep copy of an API object.
|
||||
func (s *Scheme) Copy(src Object) (Object, error) {
|
||||
dst, err := s.DeepCopy(src)
|
||||
|
|
@ -498,6 +519,15 @@ func (s *Scheme) convertToVersion(copy bool, in Object, target GroupVersioner) (
|
|||
|
||||
gvk, ok := target.KindForGroupVersionKinds(kinds)
|
||||
if !ok {
|
||||
// try to see if this type is listed as unversioned (for legacy support)
|
||||
// TODO: when we move to server API versions, we should completely remove the unversioned concept
|
||||
if unversionedKind, ok := s.unversionedTypes[t]; ok {
|
||||
if gvk, ok := target.KindForGroupVersionKinds([]unversioned.GroupVersionKind{unversionedKind}); ok {
|
||||
return copyAndSetTargetKind(copy, s, in, gvk)
|
||||
}
|
||||
return copyAndSetTargetKind(copy, s, in, unversionedKind)
|
||||
}
|
||||
|
||||
// TODO: should this be a typed error?
|
||||
return nil, fmt.Errorf("%v is not suitable for converting to %q", t, target)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue