Update go dependencies and cleanup deprecated packages
This commit is contained in:
parent
03a1e20fde
commit
44fd79d061
1099 changed files with 75691 additions and 31913 deletions
1
vendor/k8s.io/apimachinery/pkg/api/equality/BUILD
generated
vendored
1
vendor/k8s.io/apimachinery/pkg/api/equality/BUILD
generated
vendored
|
|
@ -8,6 +8,7 @@ load(
|
|||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["semantic.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/equality",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/api/errors/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/api/errors/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["errors_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/errors",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
|
@ -24,6 +25,7 @@ go_library(
|
|||
"doc.go",
|
||||
"errors.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/errors",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
|
|
|
|||
1
vendor/k8s.io/apimachinery/pkg/api/errors/OWNERS
generated
vendored
1
vendor/k8s.io/apimachinery/pkg/api/errors/OWNERS
generated
vendored
|
|
@ -20,7 +20,6 @@ reviewers:
|
|||
- dims
|
||||
- hongchaodeng
|
||||
- krousey
|
||||
- satnam6502
|
||||
- cjcullen
|
||||
- david-mcmahon
|
||||
- goltermann
|
||||
|
|
|
|||
33
vendor/k8s.io/apimachinery/pkg/api/errors/errors.go
generated
vendored
33
vendor/k8s.io/apimachinery/pkg/api/errors/errors.go
generated
vendored
|
|
@ -405,84 +405,84 @@ 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
|
||||
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
|
||||
return ReasonForError(err) == metav1.StatusReasonExpired
|
||||
}
|
||||
|
||||
// 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
|
||||
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.
|
||||
func IsTooManyRequests(err error) bool {
|
||||
if reasonForError(err) == metav1.StatusReasonTooManyRequests {
|
||||
if ReasonForError(err) == metav1.StatusReasonTooManyRequests {
|
||||
return true
|
||||
}
|
||||
switch t := err.(type) {
|
||||
|
|
@ -536,7 +536,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
|
||||
|
|
|
|||
4
vendor/k8s.io/apimachinery/pkg/api/errors/errors_test.go
generated
vendored
4
vendor/k8s.io/apimachinery/pkg/api/errors/errors_test.go
generated
vendored
|
|
@ -188,8 +188,8 @@ func TestNewInvalid(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func Test_reasonForError(t *testing.T) {
|
||||
if e, a := metav1.StatusReasonUnknown, reasonForError(nil); e != a {
|
||||
func TestReasonForError(t *testing.T) {
|
||||
if e, a := metav1.StatusReasonUnknown, ReasonForError(nil); e != a {
|
||||
t.Errorf("unexpected reason type: %#v", a)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
3
vendor/k8s.io/apimachinery/pkg/api/meta/BUILD
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/api/meta/BUILD
generated
vendored
|
|
@ -14,6 +14,7 @@ go_test(
|
|||
"priority_test.go",
|
||||
"restmapper_test.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/meta",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
|
|
@ -33,12 +34,14 @@ go_library(
|
|||
"firsthit_restmapper.go",
|
||||
"help.go",
|
||||
"interfaces.go",
|
||||
"lazy.go",
|
||||
"meta.go",
|
||||
"multirestmapper.go",
|
||||
"priority.go",
|
||||
"restmapper.go",
|
||||
"unstructured.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/meta",
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
|
|
|||
3
vendor/k8s.io/apimachinery/pkg/api/meta/interfaces.go
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/api/meta/interfaces.go
generated
vendored
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
121
vendor/k8s.io/apimachinery/pkg/api/meta/lazy.go
generated
vendored
Normal file
121
vendor/k8s.io/apimachinery/pkg/api/meta/lazy.go
generated
vendored
Normal file
|
|
@ -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)
|
||||
}
|
||||
19
vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
generated
vendored
19
vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
generated
vendored
|
|
@ -89,7 +89,7 @@ func ListAccessor(obj interface{}) (List, error) {
|
|||
}
|
||||
return nil, errNotList
|
||||
default:
|
||||
panic(fmt.Errorf("%T does not implement the List interface", obj))
|
||||
return nil, errNotList
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -367,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 {
|
||||
|
|
|
|||
18
vendor/k8s.io/apimachinery/pkg/api/meta/unstructured.go
generated
vendored
18
vendor/k8s.io/apimachinery/pkg/api/meta/unstructured.go
generated
vendored
|
|
@ -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{},
|
||||
|
|
|
|||
4
vendor/k8s.io/apimachinery/pkg/api/resource/BUILD
generated
vendored
4
vendor/k8s.io/apimachinery/pkg/api/resource/BUILD
generated
vendored
|
|
@ -15,6 +15,7 @@ go_test(
|
|||
"quantity_test.go",
|
||||
"scale_int_test.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/resource",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
|
|
@ -33,7 +34,9 @@ go_library(
|
|||
"quantity_proto.go",
|
||||
"scale_int.go",
|
||||
"suffix.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/resource",
|
||||
deps = [
|
||||
"//vendor/github.com/go-openapi/spec:go_default_library",
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
|
|
@ -46,6 +49,7 @@ go_library(
|
|||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["quantity_example_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/resource_test",
|
||||
deps = ["//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library"],
|
||||
)
|
||||
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
generated
vendored
|
|
@ -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.
|
||||
|
|
|
|||
3
vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto
generated
vendored
|
|
@ -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;
|
||||
|
|
|
|||
3
vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
|
|
@ -93,6 +93,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
|
||||
|
|
@ -415,7 +416,7 @@ func (_ Quantity) OpenAPIDefinition() openapi.OpenAPIDefinition {
|
|||
// 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() {
|
||||
|
|
|
|||
6
vendor/k8s.io/apimachinery/pkg/api/resource/quantity_test.go
generated
vendored
6
vendor/k8s.io/apimachinery/pkg/api/resource/quantity_test.go
generated
vendored
|
|
@ -29,8 +29,6 @@ import (
|
|||
inf "gopkg.in/inf.v0"
|
||||
)
|
||||
|
||||
var useInfDec bool
|
||||
|
||||
func amount(i int64, exponent int) infDecAmount {
|
||||
// See the below test-- scale is the negative of an exponent.
|
||||
return infDecAmount{inf.NewDec(i, inf.Scale(-exponent))}
|
||||
|
|
@ -79,7 +77,7 @@ func TestQuantityParseZero(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestQuantityParseNonNumericError ensures that when a non-numeric string is parsed
|
||||
// TestQuantityParseNonNumericPanic ensures that when a non-numeric string is parsed
|
||||
// it panics
|
||||
func TestQuantityParseNonNumericPanic(t *testing.T) {
|
||||
defer func() {
|
||||
|
|
@ -140,7 +138,7 @@ func TestQuantitySubZeroPreservesSuffix(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Verifies that you get 0 as canonical value if internal value is 0, and not 0<suffix>
|
||||
// TestQuantityCanocicalizeZero verifies that you get 0 as canonical value if internal value is 0, and not 0<suffix>
|
||||
func TestQuantityCanocicalizeZero(t *testing.T) {
|
||||
val := MustParse("1000m")
|
||||
val.i.Sub(int64Amount{value: 1})
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
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.
|
||||
|
|
@ -14,6 +16,12 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package unstructured provides conversion from runtime objects
|
||||
// to map[string]interface{} representation.
|
||||
package unstructured // import "k8s.io/apimachinery/pkg/conversion/unstructured"
|
||||
// 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
|
||||
}
|
||||
2
vendor/k8s.io/apimachinery/pkg/api/validation/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/api/validation/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["objectmeta_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/validation",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
|
@ -23,6 +24,7 @@ go_library(
|
|||
"generic.go",
|
||||
"objectmeta.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/validation",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/apimachinery/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apimachinery/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["types_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/apimachinery",
|
||||
library = ":go_default_library",
|
||||
deps = ["//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library"],
|
||||
)
|
||||
|
|
@ -19,6 +20,7 @@ go_library(
|
|||
"doc.go",
|
||||
"types.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/apimachinery",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/apimachinery/announced/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apimachinery/announced/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["announced_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/apimachinery/announced",
|
||||
library = ":go_default_library",
|
||||
deps = ["//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library"],
|
||||
)
|
||||
|
|
@ -19,6 +20,7 @@ go_library(
|
|||
"announced.go",
|
||||
"group_factory.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/apimachinery/announced",
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/apimachinery/registered/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apimachinery/registered/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["registered_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/apimachinery/registered",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apimachinery:go_default_library",
|
||||
|
|
@ -19,6 +20,7 @@ go_test(
|
|||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["registered.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/apimachinery/registered",
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/apimachinery/registered/registered.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apimachinery/registered/registered.go
generated
vendored
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package to keep track of API Versions that can be registered and are enabled in api.Scheme.
|
||||
// Package to keep track of API Versions that can be registered and are enabled in a Scheme.
|
||||
package registered
|
||||
|
||||
import (
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/apimachinery/types.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apimachinery/types.go
generated
vendored
|
|
@ -38,7 +38,7 @@ type GroupMeta struct {
|
|||
// to go through the InterfacesFor method below.
|
||||
SelfLinker runtime.SelfLinker
|
||||
|
||||
// RESTMapper provides the default mapping between REST paths and the objects declared in api.Scheme and all known
|
||||
// RESTMapper provides the default mapping between REST paths and the objects declared in a Scheme and all known
|
||||
// versions.
|
||||
RESTMapper meta.RESTMapper
|
||||
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion/BUILD
generated
vendored
|
|
@ -12,6 +12,7 @@ go_test(
|
|||
"register_test.go",
|
||||
"roundtrip_test.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/apis/meta/internalversion",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/testing/roundtrip:go_default_library",
|
||||
|
|
@ -31,6 +32,7 @@ go_library(
|
|||
"zz_generated.conversion.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/apis/meta/internalversion",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1:go_default_library",
|
||||
|
|
|
|||
3
vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion/register.go
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion/register.go
generated
vendored
|
|
@ -38,9 +38,6 @@ var (
|
|||
AddToScheme = localSchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Copier exposes copying on this scheme.
|
||||
var Copier runtime.ObjectCopier = scheme
|
||||
|
||||
// Codecs provides access to encoding and decoding for the scheme.
|
||||
var Codecs = serializer.NewCodecFactory(scheme)
|
||||
|
||||
|
|
|
|||
8
vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion/register_test.go
generated
vendored
8
vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion/register_test.go
generated
vendored
|
|
@ -59,11 +59,11 @@ func TestListOptions(t *testing.T) {
|
|||
}
|
||||
|
||||
// verify kind registration
|
||||
if gvk, unversioned, err := scheme.ObjectKind(in); err != nil || unversioned || gvk != metav1.SchemeGroupVersion.WithKind("ListOptions") {
|
||||
t.Errorf("unexpected: %v %v %v", gvk, unversioned, err)
|
||||
if gvks, unversioned, err := scheme.ObjectKinds(in); err != nil || unversioned || gvks[0] != metav1.SchemeGroupVersion.WithKind("ListOptions") {
|
||||
t.Errorf("unexpected: %v %v %v", gvks[0], unversioned, err)
|
||||
}
|
||||
if gvk, unversioned, err := scheme.ObjectKind(out); err != nil || unversioned || gvk != SchemeGroupVersion.WithKind("ListOptions") {
|
||||
t.Errorf("unexpected: %v %v %v", gvk, unversioned, err)
|
||||
if gvks, unversioned, err := scheme.ObjectKinds(out); err != nil || unversioned || gvks[0] != SchemeGroupVersion.WithKind("ListOptions") {
|
||||
t.Errorf("unexpected: %v %v %v", gvks[0], unversioned, err)
|
||||
}
|
||||
|
||||
actual = &metav1.ListOptions{}
|
||||
|
|
|
|||
20
vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion/zz_generated.deepcopy.go
generated
vendored
20
vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion/zz_generated.deepcopy.go
generated
vendored
|
|
@ -1,7 +1,7 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
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.
|
||||
|
|
@ -21,27 +21,9 @@ limitations under the License.
|
|||
package internalversion
|
||||
|
||||
import (
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// GetGeneratedDeepCopyFuncs returns the generated funcs, since we aren't registering them.
|
||||
//
|
||||
// Deprecated: deepcopy registration will go away when static deepcopy is fully implemented.
|
||||
func GetGeneratedDeepCopyFuncs() []conversion.GeneratedDeepCopyFunc {
|
||||
return []conversion.GeneratedDeepCopyFunc{
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*List).DeepCopyInto(out.(*List))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&List{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*ListOptions).DeepCopyInto(out.(*ListOptions))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&ListOptions{})},
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *List) DeepCopyInto(out *List) {
|
||||
*out = *in
|
||||
|
|
|
|||
12
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/BUILD
generated
vendored
12
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/BUILD
generated
vendored
|
|
@ -18,6 +18,7 @@ go_test(
|
|||
"time_test.go",
|
||||
"types_test.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/github.com/ghodss/yaml:go_default_library",
|
||||
|
|
@ -50,6 +51,7 @@ go_library(
|
|||
"zz_generated.deepcopy.go",
|
||||
"zz_generated.defaults.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
deps = [
|
||||
"//vendor/github.com/go-openapi/spec:go_default_library",
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
|
|
@ -91,3 +93,13 @@ filegroup(
|
|||
srcs = ["generated.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["conversion_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1_test",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
|
|||
8
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/conversion.go
generated
vendored
8
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/conversion.go
generated
vendored
|
|
@ -38,6 +38,7 @@ func AddConversionFuncs(scheme *runtime.Scheme) error {
|
|||
Convert_intstr_IntOrString_To_intstr_IntOrString,
|
||||
|
||||
Convert_unversioned_Time_To_unversioned_Time,
|
||||
Convert_unversioned_MicroTime_To_unversioned_MicroTime,
|
||||
|
||||
Convert_Pointer_v1_Duration_To_v1_Duration,
|
||||
Convert_v1_Duration_To_Pointer_v1_Duration,
|
||||
|
|
@ -199,6 +200,12 @@ func Convert_v1_Duration_To_Pointer_v1_Duration(in *Duration, out **Duration, s
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_unversioned_MicroTime_To_unversioned_MicroTime(in *MicroTime, out *MicroTime, s conversion.Scope) error {
|
||||
// Cannot deep copy these, because time.Time has unexported fields.
|
||||
*out = *in
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_Slice_string_To_unversioned_Time allows converting a URL query parameter value
|
||||
func Convert_Slice_string_To_unversioned_Time(input *[]string, out *Time, s conversion.Scope) error {
|
||||
str := ""
|
||||
|
|
@ -252,7 +259,6 @@ func Convert_map_to_unversioned_LabelSelector(in *map[string]string, out *LabelS
|
|||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out = new(LabelSelector)
|
||||
for labelKey, labelValue := range *in {
|
||||
AddLabelToSelector(out, labelKey, labelValue)
|
||||
}
|
||||
|
|
|
|||
49
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/conversion_test.go
generated
vendored
Normal file
49
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/conversion_test.go
generated
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
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 v1_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func TestMapToLabelSelectorRoundTrip(t *testing.T) {
|
||||
// We should be able to round-trip a map-only selector through LabelSelector.
|
||||
inputs := []map[string]string{
|
||||
nil,
|
||||
{},
|
||||
{"one": "foo"},
|
||||
{"one": "foo", "two": "bar"},
|
||||
}
|
||||
for _, in := range inputs {
|
||||
ls := &v1.LabelSelector{}
|
||||
if err := v1.Convert_map_to_unversioned_LabelSelector(&in, ls, nil); err != nil {
|
||||
t.Errorf("Convert_map_to_unversioned_LabelSelector(%#v): %v", in, err)
|
||||
continue
|
||||
}
|
||||
out := map[string]string{}
|
||||
if err := v1.Convert_unversioned_LabelSelector_to_map(ls, &out, nil); err != nil {
|
||||
t.Errorf("Convert_unversioned_LabelSelector_to_map(%#v): %v", ls, err)
|
||||
continue
|
||||
}
|
||||
if !apiequality.Semantic.DeepEqual(in, out) {
|
||||
t.Errorf("map-selector conversion round-trip failed: got %v; want %v", out, in)
|
||||
}
|
||||
}
|
||||
}
|
||||
380
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.pb.go
generated
vendored
380
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.pb.go
generated
vendored
|
|
@ -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.
|
||||
|
|
@ -50,6 +50,7 @@ limitations under the License.
|
|||
MicroTime
|
||||
ObjectMeta
|
||||
OwnerReference
|
||||
Patch
|
||||
Preconditions
|
||||
RootPaths
|
||||
ServerAddressByClientCIDR
|
||||
|
|
@ -196,51 +197,55 @@ func (m *OwnerReference) Reset() { *m = OwnerReference{} }
|
|||
func (*OwnerReference) ProtoMessage() {}
|
||||
func (*OwnerReference) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{24} }
|
||||
|
||||
func (m *Patch) Reset() { *m = Patch{} }
|
||||
func (*Patch) ProtoMessage() {}
|
||||
func (*Patch) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{25} }
|
||||
|
||||
func (m *Preconditions) Reset() { *m = Preconditions{} }
|
||||
func (*Preconditions) ProtoMessage() {}
|
||||
func (*Preconditions) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{25} }
|
||||
func (*Preconditions) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{26} }
|
||||
|
||||
func (m *RootPaths) Reset() { *m = RootPaths{} }
|
||||
func (*RootPaths) ProtoMessage() {}
|
||||
func (*RootPaths) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{26} }
|
||||
func (*RootPaths) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{27} }
|
||||
|
||||
func (m *ServerAddressByClientCIDR) Reset() { *m = ServerAddressByClientCIDR{} }
|
||||
func (*ServerAddressByClientCIDR) ProtoMessage() {}
|
||||
func (*ServerAddressByClientCIDR) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptorGenerated, []int{27}
|
||||
return fileDescriptorGenerated, []int{28}
|
||||
}
|
||||
|
||||
func (m *Status) Reset() { *m = Status{} }
|
||||
func (*Status) ProtoMessage() {}
|
||||
func (*Status) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{28} }
|
||||
func (*Status) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{29} }
|
||||
|
||||
func (m *StatusCause) Reset() { *m = StatusCause{} }
|
||||
func (*StatusCause) ProtoMessage() {}
|
||||
func (*StatusCause) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{29} }
|
||||
func (*StatusCause) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{30} }
|
||||
|
||||
func (m *StatusDetails) Reset() { *m = StatusDetails{} }
|
||||
func (*StatusDetails) ProtoMessage() {}
|
||||
func (*StatusDetails) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{30} }
|
||||
func (*StatusDetails) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{31} }
|
||||
|
||||
func (m *Time) Reset() { *m = Time{} }
|
||||
func (*Time) ProtoMessage() {}
|
||||
func (*Time) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{31} }
|
||||
func (*Time) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{32} }
|
||||
|
||||
func (m *Timestamp) Reset() { *m = Timestamp{} }
|
||||
func (*Timestamp) ProtoMessage() {}
|
||||
func (*Timestamp) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{32} }
|
||||
func (*Timestamp) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{33} }
|
||||
|
||||
func (m *TypeMeta) Reset() { *m = TypeMeta{} }
|
||||
func (*TypeMeta) ProtoMessage() {}
|
||||
func (*TypeMeta) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{33} }
|
||||
func (*TypeMeta) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{34} }
|
||||
|
||||
func (m *Verbs) Reset() { *m = Verbs{} }
|
||||
func (*Verbs) ProtoMessage() {}
|
||||
func (*Verbs) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{34} }
|
||||
func (*Verbs) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{35} }
|
||||
|
||||
func (m *WatchEvent) Reset() { *m = WatchEvent{} }
|
||||
func (*WatchEvent) ProtoMessage() {}
|
||||
func (*WatchEvent) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{35} }
|
||||
func (*WatchEvent) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{36} }
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*APIGroup)(nil), "k8s.io.apimachinery.pkg.apis.meta.v1.APIGroup")
|
||||
|
|
@ -268,6 +273,7 @@ func init() {
|
|||
proto.RegisterType((*MicroTime)(nil), "k8s.io.apimachinery.pkg.apis.meta.v1.MicroTime")
|
||||
proto.RegisterType((*ObjectMeta)(nil), "k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta")
|
||||
proto.RegisterType((*OwnerReference)(nil), "k8s.io.apimachinery.pkg.apis.meta.v1.OwnerReference")
|
||||
proto.RegisterType((*Patch)(nil), "k8s.io.apimachinery.pkg.apis.meta.v1.Patch")
|
||||
proto.RegisterType((*Preconditions)(nil), "k8s.io.apimachinery.pkg.apis.meta.v1.Preconditions")
|
||||
proto.RegisterType((*RootPaths)(nil), "k8s.io.apimachinery.pkg.apis.meta.v1.RootPaths")
|
||||
proto.RegisterType((*ServerAddressByClientCIDR)(nil), "k8s.io.apimachinery.pkg.apis.meta.v1.ServerAddressByClientCIDR")
|
||||
|
|
@ -1317,6 +1323,24 @@ func (m *OwnerReference) MarshalTo(dAtA []byte) (int, error) {
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *Patch) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalTo(dAtA)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *Patch) MarshalTo(dAtA []byte) (int, error) {
|
||||
var i int
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *Preconditions) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
|
|
@ -2065,6 +2089,12 @@ func (m *OwnerReference) Size() (n int) {
|
|||
return n
|
||||
}
|
||||
|
||||
func (m *Patch) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *Preconditions) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
|
|
@ -2464,6 +2494,15 @@ func (this *OwnerReference) String() string {
|
|||
}, "")
|
||||
return s
|
||||
}
|
||||
func (this *Patch) String() string {
|
||||
if this == nil {
|
||||
return "nil"
|
||||
}
|
||||
s := strings.Join([]string{`&Patch{`,
|
||||
`}`,
|
||||
}, "")
|
||||
return s
|
||||
}
|
||||
func (this *Preconditions) String() string {
|
||||
if this == nil {
|
||||
return "nil"
|
||||
|
|
@ -6382,6 +6421,56 @@ func (m *OwnerReference) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (m *Patch) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowGenerated
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Patch: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Patch: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipGenerated(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthGenerated
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *Preconditions) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
|
@ -7715,7 +7804,7 @@ func init() {
|
|||
}
|
||||
|
||||
var fileDescriptorGenerated = []byte{
|
||||
// 2428 bytes of a gzipped FileDescriptorProto
|
||||
// 2435 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x59, 0x4d, 0x6c, 0x23, 0x49,
|
||||
0x15, 0x4e, 0xdb, 0xb1, 0x63, 0x3f, 0xc7, 0xf9, 0xa9, 0xcd, 0x80, 0x37, 0x02, 0x3b, 0xdb, 0x8b,
|
||||
0x56, 0x59, 0x98, 0xb5, 0x49, 0x16, 0x56, 0xc3, 0x00, 0x03, 0xe9, 0x38, 0x33, 0x8a, 0x76, 0x32,
|
||||
|
|
@ -7723,7 +7812,7 @@ var fileDescriptorGenerated = []byte{
|
|||
0x33, 0x09, 0x1c, 0xd8, 0x03, 0x48, 0x1c, 0x10, 0x9a, 0x23, 0x27, 0xb4, 0x23, 0xb8, 0x70, 0xe5,
|
||||
0xc4, 0x05, 0x4e, 0x48, 0xcc, 0x71, 0x24, 0x2e, 0x7b, 0x40, 0xd6, 0x8e, 0xf7, 0xc0, 0x09, 0x71,
|
||||
0xcf, 0x09, 0x55, 0x75, 0xf5, 0x9f, 0x1d, 0x4f, 0xda, 0x3b, 0x0b, 0xe2, 0x14, 0xf7, 0xfb, 0xf9,
|
||||
0xde, 0xab, 0xaa, 0xf7, 0x5e, 0xbd, 0x7a, 0x81, 0xbd, 0xe3, 0x6b, 0xac, 0x6e, 0x7b, 0x8d, 0xe3,
|
||||
0xde, 0xab, 0x57, 0xaf, 0x5e, 0xbd, 0x7a, 0x81, 0xbd, 0xe3, 0x6b, 0xac, 0x6e, 0x7b, 0x8d, 0xe3,
|
||||
0xfe, 0x01, 0xa1, 0x2e, 0xe1, 0x84, 0x35, 0x4e, 0x88, 0xdb, 0xf6, 0x68, 0x43, 0x31, 0xcc, 0x9e,
|
||||
0xdd, 0x35, 0xad, 0x23, 0xdb, 0x25, 0xf4, 0xac, 0xd1, 0x3b, 0xee, 0x08, 0x02, 0x6b, 0x74, 0x09,
|
||||
0x37, 0x1b, 0x27, 0x1b, 0x8d, 0x0e, 0x71, 0x09, 0x35, 0x39, 0x69, 0xd7, 0x7b, 0xd4, 0xe3, 0x1e,
|
||||
|
|
@ -7735,137 +7824,138 @@ var fileDescriptorGenerated = []byte{
|
|||
0xff, 0x96, 0x85, 0xc2, 0x56, 0x6b, 0xf7, 0x16, 0xf5, 0xfa, 0x3d, 0xb4, 0x06, 0xb3, 0xae, 0xd9,
|
||||
0x25, 0x15, 0x6d, 0x4d, 0x5b, 0x2f, 0x1a, 0xf3, 0x4f, 0x07, 0xb5, 0x99, 0xe1, 0xa0, 0x36, 0x7b,
|
||||
0xc7, 0xec, 0x12, 0x2c, 0x39, 0xc8, 0x81, 0xc2, 0x09, 0xa1, 0xcc, 0xf6, 0x5c, 0x56, 0xc9, 0xac,
|
||||
0x65, 0xd7, 0x4b, 0x9b, 0x37, 0xea, 0x69, 0x36, 0xad, 0x2e, 0x0d, 0xdc, 0xf7, 0x55, 0x6f, 0x7a,
|
||||
0xb4, 0x69, 0x33, 0xcb, 0x3b, 0x21, 0xf4, 0xcc, 0x58, 0x52, 0x56, 0x0a, 0x8a, 0xc9, 0x70, 0x68,
|
||||
0x01, 0xfd, 0x5c, 0x83, 0xa5, 0x1e, 0x25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f2, 0x27, 0xf6, 0x41, 0x50, 0x1d, 0x80, 0x1d, 0x79, 0x94, 0x4b,
|
||||
0x77, 0x2a, 0xb9, 0xb5, 0xec, 0x7a, 0xd1, 0x58, 0x10, 0xfe, 0xed, 0x87, 0x54, 0x1c, 0x93, 0x40,
|
||||
0xd7, 0x60, 0x9e, 0xd9, 0x6e, 0xa7, 0xef, 0x98, 0x54, 0x10, 0x2a, 0x79, 0xe9, 0xe7, 0x8a, 0xf2,
|
||||
0x73, 0x7e, 0x3f, 0xc6, 0xc3, 0x09, 0x49, 0x61, 0xc9, 0x32, 0x39, 0xe9, 0x78, 0xd4, 0x26, 0xac,
|
||||
0x32, 0x17, 0x59, 0xda, 0x0e, 0xa9, 0x38, 0x26, 0x81, 0x5e, 0x87, 0x9c, 0xdc, 0xf9, 0x4a, 0x41,
|
||||
0x9a, 0x28, 0x2b, 0x13, 0x39, 0x79, 0x2c, 0xd8, 0xe7, 0xa1, 0x37, 0x61, 0x4e, 0x65, 0x4d, 0xa5,
|
||||
0x28, 0xc5, 0x16, 0x95, 0xd8, 0x5c, 0x10, 0xd6, 0x01, 0x5f, 0xff, 0xa3, 0x06, 0x8b, 0xb1, 0xf3,
|
||||
0x93, 0xb1, 0x72, 0x0d, 0xe6, 0x3b, 0xb1, 0x4c, 0x51, 0x67, 0x19, 0xae, 0x26, 0x9e, 0x45, 0x38,
|
||||
0x21, 0x89, 0x08, 0x14, 0xa9, 0x42, 0x0a, 0x2a, 0xc2, 0x46, 0xea, 0x40, 0x0b, 0x7c, 0x88, 0x2c,
|
||||
0xc5, 0x88, 0x0c, 0x47, 0xc8, 0xfa, 0x3f, 0x35, 0x19, 0x74, 0x41, 0x8d, 0x40, 0xeb, 0xb1, 0x3a,
|
||||
0xa4, 0xc9, 0x2d, 0x9c, 0x9f, 0x50, 0x43, 0x2e, 0x49, 0xde, 0xcc, 0xff, 0x45, 0xf2, 0x5e, 0x2f,
|
||||
0x65, 0xd7, 0x4b, 0x9b, 0x37, 0xea, 0x69, 0x82, 0x56, 0x97, 0x06, 0xee, 0xfb, 0xaa, 0x37, 0x3d,
|
||||
0xda, 0xb4, 0x99, 0xe5, 0x9d, 0x10, 0x7a, 0x66, 0x2c, 0x29, 0x2b, 0x05, 0xc5, 0x64, 0x38, 0xb4,
|
||||
0x80, 0x7e, 0xae, 0xc1, 0x52, 0x8f, 0x92, 0x43, 0x42, 0x29, 0x69, 0x2b, 0x7e, 0x25, 0xbb, 0xa6,
|
||||
0x7d, 0x06, 0x66, 0x2b, 0xca, 0xec, 0x52, 0x6b, 0x04, 0x1f, 0x8f, 0x59, 0x44, 0xbf, 0xd3, 0x60,
|
||||
0x95, 0x11, 0x7a, 0x42, 0xe8, 0x56, 0xbb, 0x4d, 0x09, 0x63, 0xc6, 0xd9, 0xb6, 0x63, 0x13, 0x97,
|
||||
0x6f, 0xef, 0x36, 0x31, 0xab, 0xcc, 0xca, 0x38, 0x7c, 0x27, 0x9d, 0x43, 0xfb, 0x93, 0x70, 0x0c,
|
||||
0x5d, 0x79, 0xb4, 0x3a, 0x51, 0x84, 0xe1, 0x17, 0xb8, 0xa1, 0x1f, 0xc2, 0x7c, 0xb0, 0x91, 0xb7,
|
||||
0x6d, 0xc6, 0xd1, 0x7d, 0xc8, 0x77, 0xc4, 0x07, 0xab, 0x68, 0xd2, 0xc1, 0x7a, 0x3a, 0x07, 0x03,
|
||||
0x0c, 0x63, 0x41, 0xf9, 0x93, 0x97, 0x9f, 0x0c, 0x2b, 0x34, 0xfd, 0xcf, 0x59, 0x28, 0x6d, 0xb5,
|
||||
0x76, 0x31, 0x61, 0x5e, 0x9f, 0x5a, 0x24, 0x45, 0xd2, 0x6c, 0x02, 0x88, 0xbf, 0xac, 0x67, 0x5a,
|
||||
0xa4, 0x5d, 0xc9, 0xac, 0x69, 0xeb, 0x05, 0x03, 0x29, 0x39, 0xb8, 0x13, 0x72, 0x70, 0x4c, 0x4a,
|
||||
0xa0, 0x1e, 0xdb, 0x6e, 0x5b, 0xee, 0x76, 0x0c, 0xf5, 0x5d, 0xdb, 0x6d, 0x63, 0xc9, 0x41, 0xb7,
|
||||
0x21, 0x77, 0x42, 0xe8, 0x81, 0x88, 0xbf, 0x48, 0x88, 0xaf, 0xa4, 0x5b, 0xde, 0x7d, 0xa1, 0x62,
|
||||
0x14, 0x87, 0x83, 0x5a, 0x4e, 0xfe, 0xc4, 0x3e, 0x08, 0xaa, 0x03, 0xb0, 0x23, 0x8f, 0x72, 0xe9,
|
||||
0x4e, 0x25, 0xb7, 0x96, 0x5d, 0x2f, 0x1a, 0x0b, 0xc2, 0xbf, 0xfd, 0x90, 0x8a, 0x63, 0x12, 0xe8,
|
||||
0x1a, 0xcc, 0x33, 0xdb, 0xed, 0xf4, 0x1d, 0x93, 0x0a, 0x42, 0x25, 0x2f, 0xfd, 0x5c, 0x51, 0x7e,
|
||||
0xce, 0xef, 0xc7, 0x78, 0x38, 0x21, 0x29, 0x2c, 0x59, 0x26, 0x27, 0x1d, 0x8f, 0xda, 0x84, 0x55,
|
||||
0xe6, 0x22, 0x4b, 0xdb, 0x21, 0x15, 0xc7, 0x24, 0xd0, 0xeb, 0x90, 0x93, 0x91, 0xaf, 0x14, 0xa4,
|
||||
0x89, 0xb2, 0x32, 0x91, 0x93, 0xdb, 0x82, 0x7d, 0x1e, 0x7a, 0x13, 0xe6, 0xd4, 0xa9, 0xa9, 0x14,
|
||||
0xa5, 0xd8, 0xa2, 0x12, 0x9b, 0x0b, 0xd2, 0x3a, 0xe0, 0xeb, 0x7f, 0xd4, 0x60, 0x31, 0xb6, 0x7f,
|
||||
0x32, 0x57, 0xae, 0xc1, 0x7c, 0x27, 0x76, 0x52, 0xd4, 0x5e, 0x86, 0xab, 0x89, 0x9f, 0x22, 0x9c,
|
||||
0x90, 0x44, 0x04, 0x8a, 0x54, 0x21, 0x05, 0x15, 0x61, 0x23, 0x75, 0xa2, 0x05, 0x3e, 0x44, 0x96,
|
||||
0x62, 0x44, 0x86, 0x23, 0x64, 0xfd,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91, 0x07, 0xcb, 0x6d, 0xf5,
|
||||
0xea, 0x89, 0x8c, 0x16, 0xa7, 0x36, 0x7a, 0x45, 0x18, 0x6c, 0x8e, 0x02, 0xe1, 0x71, 0x6c, 0xf4,
|
||||
0x43, 0x58, 0x0d, 0x88, 0xe3, 0x4f, 0xcf, 0x0a, 0xc8, 0x9d, 0xaa, 0x8a, 0xc7, 0x70, 0x73, 0xa2,
|
||||
0x14, 0x7e, 0x01, 0x02, 0x6a, 0x43, 0xde, 0xf1, 0xbb, 0x8b, 0x92, 0xbc, 0x11, 0xbe, 0x95, 0x6e,
|
||||
0x15, 0x51, 0xf4, 0xd7, 0xe3, 0x5d, 0x45, 0xf8, 0xfc, 0x52, 0x0d, 0x85, 0xc2, 0x46, 0xa7, 0x50,
|
||||
0x32, 0x5d, 0xd7, 0xe3, 0xa6, 0xff, 0x18, 0x9e, 0x97, 0xa6, 0xb6, 0xa6, 0x36, 0xb5, 0x15, 0x61,
|
||||
0x8c, 0x74, 0x31, 0x31, 0x0e, 0x8e, 0x9b, 0x42, 0x8f, 0x60, 0xd1, 0x7b, 0xe4, 0x12, 0x8a, 0xc9,
|
||||
0x21, 0xa1, 0xc4, 0xb5, 0x08, 0xab, 0x94, 0xa5, 0xf5, 0xaf, 0xa5, 0xb4, 0x9e, 0x50, 0x8e, 0x42,
|
||||
0x3a, 0x49, 0x67, 0x78, 0xd4, 0x0a, 0xaa, 0x03, 0x1c, 0xda, 0xae, 0xea, 0x45, 0x2b, 0x0b, 0xd1,
|
||||
0xe8, 0xe9, 0x66, 0x48, 0xc5, 0x31, 0x09, 0xf4, 0x75, 0x28, 0x59, 0x4e, 0x9f, 0x71, 0xe2, 0xcf,
|
||||
0xb8, 0x16, 0x65, 0x06, 0x85, 0xeb, 0xdb, 0x8e, 0x58, 0x38, 0x2e, 0x87, 0x8e, 0x60, 0xde, 0x8e,
|
||||
0x35, 0xbd, 0x95, 0x25, 0x19, 0x8b, 0x9b, 0x53, 0x77, 0xba, 0x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, 0x16, 0x3f, 0xd1, 0x0a, 0xe4, 0x4e, 0x4c, 0xa7, 0xaf, 0xea, 0x0f, 0xf6,
|
||||
0x3f, 0xae, 0x67, 0xae, 0x69, 0xfa, 0xef, 0x35, 0xa8, 0x4c, 0x72, 0x04, 0x7d, 0x31, 0x06, 0x64,
|
||||
0x94, 0x94, 0x57, 0xd9, 0x77, 0xc9, 0x99, 0x8f, 0xba, 0x03, 0x05, 0xaf, 0x27, 0x9e, 0x70, 0x1e,
|
||||
0x55, 0x79, 0xfe, 0x66, 0x90, 0xbb, 0x77, 0x15, 0xfd, 0x7c, 0x50, 0xbb, 0x92, 0x80, 0x0f, 0x18,
|
||||
0x38, 0x54, 0x45, 0x3a, 0xe4, 0xa5, 0x3f, 0xe2, 0x52, 0x16, 0xed, 0x93, 0xdc, 0xfc, 0xfb, 0x92,
|
||||
0x82, 0x15, 0x47, 0xff, 0x93, 0x06, 0xb3, 0xb2, 0x3d, 0x7c, 0x08, 0x05, 0x11, 0xbf, 0xb6, 0xc9,
|
||||
0x4d, 0xe9, 0x57, 0xea, 0xc7, 0x84, 0xd0, 0xde, 0x23, 0xdc, 0x8c, 0xce, 0x57, 0x40, 0xc1, 0x21,
|
||||
0x22, 0xc2, 0x90, 0xb3, 0x39, 0xe9, 0x06, 0x1b, 0xf9, 0xd6, 0x44, 0x68, 0xf5, 0xfe, 0xad, 0x63,
|
||||
0xf3, 0xd1, 0xce, 0x29, 0x27, 0xae, 0xd8, 0x8c, 0xa8, 0x18, 0xec, 0x0a, 0x0c, 0xec, 0x43, 0xe9,
|
||||
0x7f, 0xd0, 0x20, 0x34, 0x25, 0x8e, 0x3b, 0x23, 0xce, 0xe1, 0x6d, 0xdb, 0x3d, 0x56, 0x61, 0x0d,
|
||||
0xdd, 0xd9, 0x57, 0x74, 0x1c, 0x4a, 0x5c, 0x74, 0xc5, 0x66, 0xa6, 0xbc, 0x62, 0xaf, 0x42, 0xc1,
|
||||
0xf2, 0x5c, 0x6e, 0xbb,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xcb, 0xa0,
|
||||
0x2a, 0x67, 0x27, 0x56, 0x65, 0x55, 0xfc, 0x66, 0x5f, 0xa6, 0xf8, 0x6d, 0x02, 0x98, 0x3d, 0x3b,
|
||||
0xa8, 0x7b, 0x7e, 0x1d, 0x0d, 0x2b, 0x57, 0x34, 0x45, 0xc3, 0x31, 0x29, 0x39, 0x95, 0xf4, 0x5c,
|
||||
0x4e, 0x3d, 0xc7, 0x21, 0x54, 0x5d, 0xa6, 0xfe, 0x54, 0x32, 0xa4, 0xe2, 0x98, 0x04, 0xba, 0x09,
|
||||
0xe8, 0xc0, 0xf1, 0xac, 0x63, 0x19, 0x82, 0xe0, 0x9c, 0xcb, 0x2a, 0x59, 0xf0, 0x87, 0x52, 0xc6,
|
||||
0x18, 0x17, 0x5f, 0xa0, 0xa1, 0xcf, 0x41, 0xae, 0x25, 0xda, 0x0a, 0xfd, 0x2e, 0x24, 0xe7, 0x49,
|
||||
0xe8, 0x86, 0x1f, 0x09, 0x2d, 0x1c, 0xf8, 0x4c, 0x17, 0x05, 0xfd, 0x2a, 0x14, 0xb1, 0xe7, 0xf1,
|
||||
0x96, 0xc9, 0x8f, 0x18, 0xaa, 0x41, 0xae, 0x27, 0x7e, 0xa8, 0x61, 0xa1, 0x9c, 0xff, 0x4a, 0x0e,
|
||||
0xf6, 0xe9, 0xfa, 0xaf, 0x34, 0x78, 0x75, 0xe2, 0xec, 0x4e, 0x44, 0xd4, 0x0a, 0xbf, 0x94, 0x4b,
|
||||
0x61, 0x44, 0x23, 0x39, 0x1c, 0x93, 0x12, 0x9d, 0x58, 0x62, 0xe0, 0x37, 0xda, 0x89, 0x25, 0xac,
|
||||
0xe1, 0xa4, 0xac, 0xfe, 0xef, 0x0c, 0xe4, 0xfd, 0x67, 0xd9, 0x7f, 0xb9, 0xf9, 0x7e, 0x03, 0xf2,
|
||||
0x4c, 0xda, 0x51, 0xee, 0x85, 0xd5, 0xd2, 0xb7, 0x8e, 0x15, 0x57, 0x34, 0x31, 0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 0x4e, 0xcf, 0xb6, 0x0e, 0x39,
|
||||
0xa1, 0xf1, 0xfe, 0x3f, 0x17, 0xf5, 0x3d, 0x78, 0x54, 0x00, 0x8f, 0xeb, 0x04, 0xa5, 0x32, 0xff,
|
||||
0x12, 0xa5, 0x52, 0x77, 0x60, 0xf6, 0x7f, 0xd8, 0xa3, 0xff, 0x00, 0x8a, 0x51, 0x17, 0xf5, 0x19,
|
||||
0x9b, 0xd4, 0x7f, 0x04, 0x05, 0x91, 0x8d, 0x41, 0xf7, 0x7f, 0xc9, 0x4d, 0x94, 0xbc, 0x23, 0x32,
|
||||
0x69, 0xee, 0x08, 0x7d, 0x13, 0xfc, 0xff, 0x99, 0x89, 0x6a, 0xea, 0xbf, 0xd8, 0x63, 0xd5, 0x34,
|
||||
0xfe, 0xfc, 0x8e, 0x8d, 0xcc, 0x7e, 0xa1, 0x01, 0xc8, 0xe7, 0xe3, 0xce, 0x09, 0x71, 0xb9, 0x70,
|
||||
0x4c, 0xec, 0xc0, 0xa8, 0x63, 0xf2, 0x18, 0x49, 0x0e, 0xba, 0x07, 0x79, 0x4f, 0x76, 0x57, 0x6a,
|
||||
0x86, 0x35, 0xe5, 0x38, 0x20, 0xcc, 0x3a, 0xbf, 0x45, 0xc3, 0x0a, 0xcc, 0x58, 0x7f, 0xfa, 0xbc,
|
||||
0x3a, 0xf3, 0xec, 0x79, 0x75, 0xe6, 0xa3, 0xe7, 0xd5, 0x99, 0x0f, 0x86, 0x55, 0xed, 0xe9, 0xb0,
|
||||
0xaa, 0x3d, 0x1b, 0x56, 0xb5, 0x8f, 0x86, 0x55, 0xed, 0xe3, 0x61, 0x55, 0x7b, 0xfc, 0x49, 0x75,
|
||||
0xe6, 0x41, 0xe6, 0x64, 0xe3, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x6c, 0xc5, 0x28, 0xb2, 0x54,
|
||||
0x20, 0x00, 0x00,
|
||||
}
|
||||
|
|
|
|||
29
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto
generated
vendored
29
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto
generated
vendored
|
|
@ -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.
|
||||
|
|
@ -149,6 +149,10 @@ message DeleteOptions {
|
|||
// Either this field or OrphanDependents may be set, but not both.
|
||||
// The default policy is decided by the existing finalizer set in the
|
||||
// metadata.finalizers and the resource-specific default policy.
|
||||
// Acceptable values are: 'Orphan' - orphan the dependents; 'Background' -
|
||||
// allow the garbage collector to delete the dependents in the background;
|
||||
// 'Foreground' - a cascading policy that deletes all dependents in the
|
||||
// foreground.
|
||||
// +optional
|
||||
optional string propagationPolicy = 4;
|
||||
}
|
||||
|
|
@ -510,15 +514,16 @@ message ObjectMeta {
|
|||
// 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 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.
|
||||
// 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.
|
||||
|
|
@ -616,6 +621,10 @@ message OwnerReference {
|
|||
optional bool blockOwnerDeletion = 7;
|
||||
}
|
||||
|
||||
// Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.
|
||||
message Patch {
|
||||
}
|
||||
|
||||
// Preconditions must be fulfilled before an operation (update, delete, etc.) is carried out.
|
||||
message Preconditions {
|
||||
// Specifies the target UID.
|
||||
|
|
|
|||
8
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go
generated
vendored
8
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go
generated
vendored
|
|
@ -175,10 +175,10 @@ func (t *MicroTime) Fuzz(c fuzz.Continue) {
|
|||
if t == nil {
|
||||
return
|
||||
}
|
||||
// Allow for about 1000 years of randomness. Leave off nanoseconds
|
||||
// because JSON doesn't represent them so they can't round-trip
|
||||
// properly.
|
||||
t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60*1000*1000), 0)
|
||||
// Allow for about 1000 years of randomness. Accurate to a tenth of
|
||||
// micro second. Leave off nanoseconds because JSON doesn't
|
||||
// represent them so they can't round-trip properly.
|
||||
t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60), 1000*c.Rand.Int63n(1000000))
|
||||
}
|
||||
|
||||
var _ fuzz.Interface = &MicroTime{}
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/register.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/register.go
generated
vendored
|
|
@ -70,7 +70,6 @@ func AddToGroupVersion(scheme *runtime.Scheme, groupVersion schema.GroupVersion)
|
|||
)
|
||||
|
||||
// register manually. This usually goes through the SchemeBuilder, which we cannot use here.
|
||||
scheme.AddGeneratedDeepCopyFuncs(GetGeneratedDeepCopyFuncs()...)
|
||||
AddConversionFuncs(scheme)
|
||||
RegisterDefaults(scheme)
|
||||
}
|
||||
|
|
@ -90,6 +89,5 @@ func init() {
|
|||
)
|
||||
|
||||
// register manually. This usually goes through the SchemeBuilder, which we cannot use here.
|
||||
scheme.AddGeneratedDeepCopyFuncs(GetGeneratedDeepCopyFuncs()...)
|
||||
RegisterDefaults(scheme)
|
||||
}
|
||||
|
|
|
|||
8
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
generated
vendored
8
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
generated
vendored
|
|
@ -80,7 +80,13 @@ func (t *Time) Before(u *Time) bool {
|
|||
|
||||
// Equal reports whether the time instant t is equal to u.
|
||||
func (t *Time) Equal(u *Time) bool {
|
||||
return t.Time.Equal(u.Time)
|
||||
if t == nil && u == nil {
|
||||
return true
|
||||
}
|
||||
if t != nil && u != nil {
|
||||
return t.Time.Equal(u.Time)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Unix returns the local time corresponding to the given Unix time
|
||||
|
|
|
|||
24
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time_test.go
generated
vendored
24
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time_test.go
generated
vendored
|
|
@ -171,3 +171,27 @@ func TestTimeProto(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTimeEqual(t *testing.T) {
|
||||
t1 := NewTime(time.Now())
|
||||
cases := []struct {
|
||||
name string
|
||||
x *Time
|
||||
y *Time
|
||||
result bool
|
||||
}{
|
||||
{"nil =? nil", nil, nil, true},
|
||||
{"!nil =? !nil", &t1, &t1, true},
|
||||
{"nil =? !nil", nil, &t1, false},
|
||||
{"!nil =? nil", &t1, nil, false},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
result := c.x.Equal(c.y)
|
||||
if result != c.result {
|
||||
t.Errorf("Failed equality test for '%v', '%v': expected %+v, got %+v", c.x, c.y, c.result, result)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
23
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types.go
generated
vendored
23
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types.go
generated
vendored
|
|
@ -177,15 +177,16 @@ type ObjectMeta struct {
|
|||
// 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 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.
|
||||
// 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.
|
||||
|
|
@ -445,6 +446,10 @@ type DeleteOptions struct {
|
|||
// Either this field or OrphanDependents may be set, but not both.
|
||||
// The default policy is decided by the existing finalizer set in the
|
||||
// metadata.finalizers and the resource-specific default policy.
|
||||
// Acceptable values are: 'Orphan' - orphan the dependents; 'Background' -
|
||||
// allow the garbage collector to delete the dependents in the background;
|
||||
// 'Foreground' - a cascading policy that deletes all dependents in the
|
||||
// foreground.
|
||||
// +optional
|
||||
PropagationPolicy *DeletionPropagation `json:"propagationPolicy,omitempty" protobuf:"varint,4,opt,name=propagationPolicy"`
|
||||
}
|
||||
|
|
|
|||
4
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types_swagger_doc_generated.go
generated
vendored
4
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types_swagger_doc_generated.go
generated
vendored
|
|
@ -90,7 +90,7 @@ var map_DeleteOptions = map[string]string{
|
|||
"gracePeriodSeconds": "The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.",
|
||||
"preconditions": "Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.",
|
||||
"orphanDependents": "Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the \"orphan\" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.",
|
||||
"propagationPolicy": "Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy.",
|
||||
"propagationPolicy": "Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground.",
|
||||
}
|
||||
|
||||
func (DeleteOptions) SwaggerDoc() map[string]string {
|
||||
|
|
@ -214,7 +214,7 @@ var map_ObjectMeta = map[string]string{
|
|||
"resourceVersion": "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.\n\nPopulated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency",
|
||||
"generation": "A sequence number representing a specific generation of the desired state. Populated by the system. Read-only.",
|
||||
"creationTimestamp": "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.\n\nPopulated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata",
|
||||
"deletionTimestamp": "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 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.\n\nPopulated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata",
|
||||
"deletionTimestamp": "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.\n\nPopulated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata",
|
||||
"deletionGracePeriodSeconds": "Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only.",
|
||||
"labels": "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. More info: http://kubernetes.io/docs/user-guide/labels",
|
||||
"annotations": "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. More info: http://kubernetes.io/docs/user-guide/annotations",
|
||||
|
|
|
|||
18
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/BUILD
generated
vendored
18
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/BUILD
generated
vendored
|
|
@ -8,22 +8,30 @@ load(
|
|||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["unstructured_test.go"],
|
||||
srcs = [
|
||||
"helpers_test.go",
|
||||
"unstructured_list_test.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
|
||||
library = ":go_default_library",
|
||||
deps = ["//vendor/github.com/stretchr/testify/assert:go_default_library"],
|
||||
deps = [
|
||||
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||
"//vendor/github.com/stretchr/testify/require:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"helpers.go",
|
||||
"unstructured.go",
|
||||
"unstructured_list.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion/unstructured:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
|
|
|
|||
453
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/helpers.go
generated
vendored
Normal file
453
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/helpers.go
generated
vendored
Normal file
|
|
@ -0,0 +1,453 @@
|
|||
/*
|
||||
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 unstructured
|
||||
|
||||
import (
|
||||
gojson "encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
)
|
||||
|
||||
// NestedFieldCopy returns a deep copy of the value of a nested field.
|
||||
// false is returned if the value is missing.
|
||||
// nil, true is returned for a nil field.
|
||||
func NestedFieldCopy(obj map[string]interface{}, fields ...string) (interface{}, bool) {
|
||||
val, ok := nestedFieldNoCopy(obj, fields...)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
return runtime.DeepCopyJSONValue(val), true
|
||||
}
|
||||
|
||||
func nestedFieldNoCopy(obj map[string]interface{}, fields ...string) (interface{}, bool) {
|
||||
var val interface{} = obj
|
||||
for _, field := range fields {
|
||||
if m, ok := val.(map[string]interface{}); ok {
|
||||
val, ok = m[field]
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
} else {
|
||||
// Expected map[string]interface{}, got something else
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
return val, true
|
||||
}
|
||||
|
||||
// NestedString returns the string value of a nested field.
|
||||
// Returns false if value is not found or is not a string.
|
||||
func NestedString(obj map[string]interface{}, fields ...string) (string, bool) {
|
||||
val, ok := nestedFieldNoCopy(obj, fields...)
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
s, ok := val.(string)
|
||||
return s, ok
|
||||
}
|
||||
|
||||
// NestedBool returns the bool value of a nested field.
|
||||
// Returns false if value is not found or is not a bool.
|
||||
func NestedBool(obj map[string]interface{}, fields ...string) (bool, bool) {
|
||||
val, ok := nestedFieldNoCopy(obj, fields...)
|
||||
if !ok {
|
||||
return false, false
|
||||
}
|
||||
b, ok := val.(bool)
|
||||
return b, ok
|
||||
}
|
||||
|
||||
// NestedFloat64 returns the bool value of a nested field.
|
||||
// Returns false if value is not found or is not a float64.
|
||||
func NestedFloat64(obj map[string]interface{}, fields ...string) (float64, bool) {
|
||||
val, ok := nestedFieldNoCopy(obj, fields...)
|
||||
if !ok {
|
||||
return 0, false
|
||||
}
|
||||
f, ok := val.(float64)
|
||||
return f, ok
|
||||
}
|
||||
|
||||
// NestedInt64 returns the int64 value of a nested field.
|
||||
// Returns false if value is not found or is not an int64.
|
||||
func NestedInt64(obj map[string]interface{}, fields ...string) (int64, bool) {
|
||||
val, ok := nestedFieldNoCopy(obj, fields...)
|
||||
if !ok {
|
||||
return 0, false
|
||||
}
|
||||
i, ok := val.(int64)
|
||||
return i, ok
|
||||
}
|
||||
|
||||
// NestedStringSlice returns a copy of []string value of a nested field.
|
||||
// Returns false if value is not found, is not a []interface{} or contains non-string items in the slice.
|
||||
func NestedStringSlice(obj map[string]interface{}, fields ...string) ([]string, bool) {
|
||||
val, ok := nestedFieldNoCopy(obj, fields...)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
if m, ok := val.([]interface{}); ok {
|
||||
strSlice := make([]string, 0, len(m))
|
||||
for _, v := range m {
|
||||
if str, ok := v.(string); ok {
|
||||
strSlice = append(strSlice, str)
|
||||
} else {
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
return strSlice, true
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// NestedSlice returns a deep copy of []interface{} value of a nested field.
|
||||
// Returns false if value is not found or is not a []interface{}.
|
||||
func NestedSlice(obj map[string]interface{}, fields ...string) ([]interface{}, bool) {
|
||||
val, ok := nestedFieldNoCopy(obj, fields...)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
if _, ok := val.([]interface{}); ok {
|
||||
return runtime.DeepCopyJSONValue(val).([]interface{}), true
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// NestedStringMap returns a copy of map[string]string value of a nested field.
|
||||
// Returns false if value is not found, is not a map[string]interface{} or contains non-string values in the map.
|
||||
func NestedStringMap(obj map[string]interface{}, fields ...string) (map[string]string, bool) {
|
||||
m, ok := nestedMapNoCopy(obj, fields...)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
strMap := make(map[string]string, len(m))
|
||||
for k, v := range m {
|
||||
if str, ok := v.(string); ok {
|
||||
strMap[k] = str
|
||||
} else {
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
return strMap, true
|
||||
}
|
||||
|
||||
// NestedMap returns a deep copy of map[string]interface{} value of a nested field.
|
||||
// Returns false if value is not found or is not a map[string]interface{}.
|
||||
func NestedMap(obj map[string]interface{}, fields ...string) (map[string]interface{}, bool) {
|
||||
m, ok := nestedMapNoCopy(obj, fields...)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
return runtime.DeepCopyJSON(m), true
|
||||
}
|
||||
|
||||
// nestedMapNoCopy returns a map[string]interface{} value of a nested field.
|
||||
// Returns false if value is not found or is not a map[string]interface{}.
|
||||
func nestedMapNoCopy(obj map[string]interface{}, fields ...string) (map[string]interface{}, bool) {
|
||||
val, ok := nestedFieldNoCopy(obj, fields...)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
m, ok := val.(map[string]interface{})
|
||||
return m, ok
|
||||
}
|
||||
|
||||
// SetNestedField sets the value of a nested field to a deep copy of the value provided.
|
||||
// Returns false if value cannot be set because one of the nesting levels is not a map[string]interface{}.
|
||||
func SetNestedField(obj map[string]interface{}, value interface{}, fields ...string) bool {
|
||||
return setNestedFieldNoCopy(obj, runtime.DeepCopyJSONValue(value), fields...)
|
||||
}
|
||||
|
||||
func setNestedFieldNoCopy(obj map[string]interface{}, value interface{}, fields ...string) bool {
|
||||
m := obj
|
||||
for _, field := range fields[:len(fields)-1] {
|
||||
if val, ok := m[field]; ok {
|
||||
if valMap, ok := val.(map[string]interface{}); ok {
|
||||
m = valMap
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
newVal := make(map[string]interface{})
|
||||
m[field] = newVal
|
||||
m = newVal
|
||||
}
|
||||
}
|
||||
m[fields[len(fields)-1]] = value
|
||||
return true
|
||||
}
|
||||
|
||||
// SetNestedStringSlice sets the string slice value of a nested field.
|
||||
// Returns false if value cannot be set because one of the nesting levels is not a map[string]interface{}.
|
||||
func SetNestedStringSlice(obj map[string]interface{}, value []string, fields ...string) bool {
|
||||
m := make([]interface{}, 0, len(value)) // convert []string into []interface{}
|
||||
for _, v := range value {
|
||||
m = append(m, v)
|
||||
}
|
||||
return setNestedFieldNoCopy(obj, m, fields...)
|
||||
}
|
||||
|
||||
// SetNestedSlice sets the slice value of a nested field.
|
||||
// Returns false if value cannot be set because one of the nesting levels is not a map[string]interface{}.
|
||||
func SetNestedSlice(obj map[string]interface{}, value []interface{}, fields ...string) bool {
|
||||
return SetNestedField(obj, value, fields...)
|
||||
}
|
||||
|
||||
// SetNestedStringMap sets the map[string]string value of a nested field.
|
||||
// Returns false if value cannot be set because one of the nesting levels is not a map[string]interface{}.
|
||||
func SetNestedStringMap(obj map[string]interface{}, value map[string]string, fields ...string) bool {
|
||||
m := make(map[string]interface{}, len(value)) // convert map[string]string into map[string]interface{}
|
||||
for k, v := range value {
|
||||
m[k] = v
|
||||
}
|
||||
return setNestedFieldNoCopy(obj, m, fields...)
|
||||
}
|
||||
|
||||
// SetNestedMap sets the map[string]interface{} value of a nested field.
|
||||
// Returns false if value cannot be set because one of the nesting levels is not a map[string]interface{}.
|
||||
func SetNestedMap(obj map[string]interface{}, value map[string]interface{}, fields ...string) bool {
|
||||
return SetNestedField(obj, value, fields...)
|
||||
}
|
||||
|
||||
// RemoveNestedField removes the nested field from the obj.
|
||||
func RemoveNestedField(obj map[string]interface{}, fields ...string) {
|
||||
m := obj
|
||||
for _, field := range fields[:len(fields)-1] {
|
||||
if x, ok := m[field].(map[string]interface{}); ok {
|
||||
m = x
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
delete(m, fields[len(fields)-1])
|
||||
}
|
||||
|
||||
func getNestedString(obj map[string]interface{}, fields ...string) string {
|
||||
val, ok := NestedString(obj, fields...)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
func extractOwnerReference(v map[string]interface{}) metav1.OwnerReference {
|
||||
// though this field is a *bool, but when decoded from JSON, it's
|
||||
// unmarshalled as bool.
|
||||
var controllerPtr *bool
|
||||
if controller, ok := NestedBool(v, "controller"); ok {
|
||||
controllerPtr = &controller
|
||||
}
|
||||
var blockOwnerDeletionPtr *bool
|
||||
if blockOwnerDeletion, ok := NestedBool(v, "blockOwnerDeletion"); ok {
|
||||
blockOwnerDeletionPtr = &blockOwnerDeletion
|
||||
}
|
||||
return metav1.OwnerReference{
|
||||
Kind: getNestedString(v, "kind"),
|
||||
Name: getNestedString(v, "name"),
|
||||
APIVersion: getNestedString(v, "apiVersion"),
|
||||
UID: types.UID(getNestedString(v, "uid")),
|
||||
Controller: controllerPtr,
|
||||
BlockOwnerDeletion: blockOwnerDeletionPtr,
|
||||
}
|
||||
}
|
||||
|
||||
// UnstructuredJSONScheme is capable of converting JSON data into the Unstructured
|
||||
// type, which can be used for generic access to objects without a predefined scheme.
|
||||
// TODO: move into serializer/json.
|
||||
var UnstructuredJSONScheme runtime.Codec = unstructuredJSONScheme{}
|
||||
|
||||
type unstructuredJSONScheme struct{}
|
||||
|
||||
func (s unstructuredJSONScheme) Decode(data []byte, _ *schema.GroupVersionKind, obj runtime.Object) (runtime.Object, *schema.GroupVersionKind, error) {
|
||||
var err error
|
||||
if obj != nil {
|
||||
err = s.decodeInto(data, obj)
|
||||
} else {
|
||||
obj, err = s.decode(data)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
gvk := obj.GetObjectKind().GroupVersionKind()
|
||||
if len(gvk.Kind) == 0 {
|
||||
return nil, &gvk, runtime.NewMissingKindErr(string(data))
|
||||
}
|
||||
|
||||
return obj, &gvk, nil
|
||||
}
|
||||
|
||||
func (unstructuredJSONScheme) Encode(obj runtime.Object, w io.Writer) error {
|
||||
switch t := obj.(type) {
|
||||
case *Unstructured:
|
||||
return json.NewEncoder(w).Encode(t.Object)
|
||||
case *UnstructuredList:
|
||||
items := make([]interface{}, 0, len(t.Items))
|
||||
for _, i := range t.Items {
|
||||
items = append(items, i.Object)
|
||||
}
|
||||
listObj := make(map[string]interface{}, len(t.Object)+1)
|
||||
for k, v := range t.Object { // Make a shallow copy
|
||||
listObj[k] = v
|
||||
}
|
||||
listObj["items"] = items
|
||||
return json.NewEncoder(w).Encode(listObj)
|
||||
case *runtime.Unknown:
|
||||
// TODO: Unstructured needs to deal with ContentType.
|
||||
_, err := w.Write(t.Raw)
|
||||
return err
|
||||
default:
|
||||
return json.NewEncoder(w).Encode(t)
|
||||
}
|
||||
}
|
||||
|
||||
func (s unstructuredJSONScheme) decode(data []byte) (runtime.Object, error) {
|
||||
type detector struct {
|
||||
Items gojson.RawMessage
|
||||
}
|
||||
var det detector
|
||||
if err := json.Unmarshal(data, &det); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if det.Items != nil {
|
||||
list := &UnstructuredList{}
|
||||
err := s.decodeToList(data, list)
|
||||
return list, err
|
||||
}
|
||||
|
||||
// No Items field, so it wasn't a list.
|
||||
unstruct := &Unstructured{}
|
||||
err := s.decodeToUnstructured(data, unstruct)
|
||||
return unstruct, err
|
||||
}
|
||||
|
||||
func (s unstructuredJSONScheme) decodeInto(data []byte, obj runtime.Object) error {
|
||||
switch x := obj.(type) {
|
||||
case *Unstructured:
|
||||
return s.decodeToUnstructured(data, x)
|
||||
case *UnstructuredList:
|
||||
return s.decodeToList(data, x)
|
||||
case *runtime.VersionedObjects:
|
||||
o, err := s.decode(data)
|
||||
if err == nil {
|
||||
x.Objects = []runtime.Object{o}
|
||||
}
|
||||
return err
|
||||
default:
|
||||
return json.Unmarshal(data, x)
|
||||
}
|
||||
}
|
||||
|
||||
func (unstructuredJSONScheme) decodeToUnstructured(data []byte, unstruct *Unstructured) error {
|
||||
m := make(map[string]interface{})
|
||||
if err := json.Unmarshal(data, &m); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
unstruct.Object = m
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s unstructuredJSONScheme) decodeToList(data []byte, list *UnstructuredList) error {
|
||||
type decodeList struct {
|
||||
Items []gojson.RawMessage
|
||||
}
|
||||
|
||||
var dList decodeList
|
||||
if err := json.Unmarshal(data, &dList); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(data, &list.Object); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// For typed lists, e.g., a PodList, API server doesn't set each item's
|
||||
// APIVersion and Kind. We need to set it.
|
||||
listAPIVersion := list.GetAPIVersion()
|
||||
listKind := list.GetKind()
|
||||
itemKind := strings.TrimSuffix(listKind, "List")
|
||||
|
||||
delete(list.Object, "items")
|
||||
list.Items = make([]Unstructured, 0, len(dList.Items))
|
||||
for _, i := range dList.Items {
|
||||
unstruct := &Unstructured{}
|
||||
if err := s.decodeToUnstructured([]byte(i), unstruct); err != nil {
|
||||
return err
|
||||
}
|
||||
// This is hacky. Set the item's Kind and APIVersion to those inferred
|
||||
// from the List.
|
||||
if len(unstruct.GetKind()) == 0 && len(unstruct.GetAPIVersion()) == 0 {
|
||||
unstruct.SetKind(itemKind)
|
||||
unstruct.SetAPIVersion(listAPIVersion)
|
||||
}
|
||||
list.Items = append(list.Items, *unstruct)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnstructuredObjectConverter is an ObjectConverter for use with
|
||||
// Unstructured objects. Since it has no schema or type information,
|
||||
// it will only succeed for no-op conversions. This is provided as a
|
||||
// sane implementation for APIs that require an object converter.
|
||||
type UnstructuredObjectConverter struct{}
|
||||
|
||||
func (UnstructuredObjectConverter) Convert(in, out, context interface{}) error {
|
||||
unstructIn, ok := in.(*Unstructured)
|
||||
if !ok {
|
||||
return fmt.Errorf("input type %T in not valid for unstructured conversion", in)
|
||||
}
|
||||
|
||||
unstructOut, ok := out.(*Unstructured)
|
||||
if !ok {
|
||||
return fmt.Errorf("output type %T in not valid for unstructured conversion", out)
|
||||
}
|
||||
|
||||
// maybe deep copy the map? It is documented in the
|
||||
// ObjectConverter interface that this function is not
|
||||
// guaranteed to not mutate the input. Or maybe set the input
|
||||
// object to nil.
|
||||
unstructOut.Object = unstructIn.Object
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnstructuredObjectConverter) ConvertToVersion(in runtime.Object, target runtime.GroupVersioner) (runtime.Object, error) {
|
||||
if kind := in.GetObjectKind().GroupVersionKind(); !kind.Empty() {
|
||||
gvk, ok := target.KindForGroupVersionKinds([]schema.GroupVersionKind{kind})
|
||||
if !ok {
|
||||
// TODO: should this be a typed error?
|
||||
return nil, fmt.Errorf("%v is unstructured and is not suitable for converting to %q", kind, target)
|
||||
}
|
||||
in.GetObjectKind().SetGroupVersionKind(gvk)
|
||||
}
|
||||
return in, nil
|
||||
}
|
||||
|
||||
func (UnstructuredObjectConverter) ConvertFieldLabel(version, kind, label, value string) (string, string, error) {
|
||||
return "", "", errors.New("unstructured cannot convert field labels")
|
||||
}
|
||||
|
|
@ -42,19 +42,19 @@ func TestCodecOfUnstructuredList(t *testing.T) {
|
|||
wg.Wait()
|
||||
}
|
||||
|
||||
func TestUnstructuredList(t *testing.T) {
|
||||
list := &UnstructuredList{
|
||||
Object: map[string]interface{}{"kind": "List", "apiVersion": "v1"},
|
||||
Items: []Unstructured{
|
||||
{Object: map[string]interface{}{"kind": "Pod", "apiVersion": "v1", "metadata": map[string]interface{}{"name": "test"}}},
|
||||
func TestRemoveNestedField(t *testing.T) {
|
||||
obj := map[string]interface{}{
|
||||
"x": map[string]interface{}{
|
||||
"y": 1,
|
||||
"a": "foo",
|
||||
},
|
||||
}
|
||||
content := list.UnstructuredContent()
|
||||
items := content["items"].([]interface{})
|
||||
if len(items) != 1 {
|
||||
t.Fatalf("unexpected items: %#v", items)
|
||||
}
|
||||
if getNestedField(items[0].(map[string]interface{}), "metadata", "name") != "test" {
|
||||
t.Fatalf("unexpected fields: %#v", items[0])
|
||||
}
|
||||
RemoveNestedField(obj, "x", "a")
|
||||
assert.Len(t, obj["x"], 1)
|
||||
RemoveNestedField(obj, "x", "y")
|
||||
assert.Empty(t, obj["x"])
|
||||
RemoveNestedField(obj, "x")
|
||||
assert.Empty(t, obj)
|
||||
RemoveNestedField(obj, "x") // Remove of a non-existent field
|
||||
assert.Empty(t, obj)
|
||||
}
|
||||
627
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go
generated
vendored
627
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go
generated
vendored
|
|
@ -18,20 +18,13 @@ package unstructured
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
gojson "encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/conversion/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
)
|
||||
|
||||
|
|
@ -54,39 +47,31 @@ type Unstructured struct {
|
|||
|
||||
var _ metav1.Object = &Unstructured{}
|
||||
var _ runtime.Unstructured = &Unstructured{}
|
||||
var _ runtime.Unstructured = &UnstructuredList{}
|
||||
|
||||
func (obj *Unstructured) GetObjectKind() schema.ObjectKind { return obj }
|
||||
func (obj *UnstructuredList) GetObjectKind() schema.ObjectKind { return obj }
|
||||
|
||||
func (obj *Unstructured) IsUnstructuredObject() {}
|
||||
func (obj *UnstructuredList) IsUnstructuredObject() {}
|
||||
func (obj *Unstructured) GetObjectKind() schema.ObjectKind { return obj }
|
||||
|
||||
func (obj *Unstructured) IsList() bool {
|
||||
if obj.Object != nil {
|
||||
_, ok := obj.Object["items"]
|
||||
return ok
|
||||
}
|
||||
return false
|
||||
}
|
||||
func (obj *UnstructuredList) IsList() bool { return true }
|
||||
|
||||
func (obj *Unstructured) EachListItem(fn func(runtime.Object) error) error {
|
||||
if obj.Object == nil {
|
||||
return fmt.Errorf("content is not a list")
|
||||
}
|
||||
field, ok := obj.Object["items"]
|
||||
if !ok {
|
||||
return fmt.Errorf("content is not a list")
|
||||
return false
|
||||
}
|
||||
_, ok = field.([]interface{})
|
||||
return ok
|
||||
}
|
||||
|
||||
func (obj *Unstructured) EachListItem(fn func(runtime.Object) error) error {
|
||||
field, ok := obj.Object["items"]
|
||||
if !ok {
|
||||
return errors.New("content is not a list")
|
||||
}
|
||||
items, ok := field.([]interface{})
|
||||
if !ok {
|
||||
return nil
|
||||
return fmt.Errorf("content is not a list: %T", field)
|
||||
}
|
||||
for _, item := range items {
|
||||
child, ok := item.(map[string]interface{})
|
||||
if !ok {
|
||||
return fmt.Errorf("items member is not an object")
|
||||
return fmt.Errorf("items member is not an object: %T", child)
|
||||
}
|
||||
if err := fn(&Unstructured{Object: child}); err != nil {
|
||||
return err
|
||||
|
|
@ -95,15 +80,6 @@ func (obj *Unstructured) EachListItem(fn func(runtime.Object) error) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (obj *UnstructuredList) EachListItem(fn func(runtime.Object) error) error {
|
||||
for i := range obj.Items {
|
||||
if err := fn(&obj.Items[i]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (obj *Unstructured) UnstructuredContent() map[string]interface{} {
|
||||
if obj.Object == nil {
|
||||
obj.Object = make(map[string]interface{})
|
||||
|
|
@ -111,23 +87,8 @@ func (obj *Unstructured) UnstructuredContent() map[string]interface{} {
|
|||
return obj.Object
|
||||
}
|
||||
|
||||
// UnstructuredContent returns a map contain an overlay of the Items field onto
|
||||
// the Object field. Items always overwrites overlay. Changing "items" in the
|
||||
// returned object will affect items in the underlying Items field, but changing
|
||||
// the "items" slice itself will have no effect.
|
||||
// TODO: expose SetUnstructuredContent on runtime.Unstructured that allows
|
||||
// items to be changed.
|
||||
func (obj *UnstructuredList) UnstructuredContent() map[string]interface{} {
|
||||
out := obj.Object
|
||||
if out == nil {
|
||||
out = make(map[string]interface{})
|
||||
}
|
||||
items := make([]interface{}, len(obj.Items))
|
||||
for i, item := range obj.Items {
|
||||
items[i] = item.Object
|
||||
}
|
||||
out["items"] = items
|
||||
return out
|
||||
func (obj *Unstructured) SetUnstructuredContent(content map[string]interface{}) {
|
||||
obj.Object = content
|
||||
}
|
||||
|
||||
// MarshalJSON ensures that the unstructured object produces proper
|
||||
|
|
@ -145,253 +106,67 @@ func (u *Unstructured) UnmarshalJSON(b []byte) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func deepCopyJSON(x interface{}) interface{} {
|
||||
switch x := x.(type) {
|
||||
case map[string]interface{}:
|
||||
clone := make(map[string]interface{}, len(x))
|
||||
for k, v := range x {
|
||||
clone[k] = deepCopyJSON(v)
|
||||
}
|
||||
return clone
|
||||
case []interface{}:
|
||||
clone := make([]interface{}, len(x))
|
||||
for i := range x {
|
||||
clone[i] = deepCopyJSON(x[i])
|
||||
}
|
||||
return clone
|
||||
default:
|
||||
// only non-pointer values (float64, int64, bool, string) are left. These can be copied by-value.
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
func (in *Unstructured) DeepCopy() *Unstructured {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Unstructured)
|
||||
*out = *in
|
||||
out.Object = deepCopyJSON(in.Object).(map[string]interface{})
|
||||
out.Object = runtime.DeepCopyJSON(in.Object)
|
||||
return out
|
||||
}
|
||||
|
||||
func (in *UnstructuredList) DeepCopy() *UnstructuredList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(UnstructuredList)
|
||||
*out = *in
|
||||
out.Object = deepCopyJSON(in.Object).(map[string]interface{})
|
||||
out.Items = make([]Unstructured, len(in.Items))
|
||||
for i := range in.Items {
|
||||
in.Items[i].DeepCopyInto(&out.Items[i])
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func getNestedField(obj map[string]interface{}, fields ...string) interface{} {
|
||||
var val interface{} = obj
|
||||
for _, field := range fields {
|
||||
if _, ok := val.(map[string]interface{}); !ok {
|
||||
return nil
|
||||
}
|
||||
val = val.(map[string]interface{})[field]
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
func getNestedString(obj map[string]interface{}, fields ...string) string {
|
||||
if str, ok := getNestedField(obj, fields...).(string); ok {
|
||||
return str
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func getNestedInt64(obj map[string]interface{}, fields ...string) int64 {
|
||||
if str, ok := getNestedField(obj, fields...).(int64); ok {
|
||||
return str
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func getNestedInt64Pointer(obj map[string]interface{}, fields ...string) *int64 {
|
||||
nested := getNestedField(obj, fields...)
|
||||
switch n := nested.(type) {
|
||||
case int64:
|
||||
return &n
|
||||
case *int64:
|
||||
return n
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func getNestedSlice(obj map[string]interface{}, fields ...string) []string {
|
||||
if m, ok := getNestedField(obj, fields...).([]interface{}); ok {
|
||||
strSlice := make([]string, 0, len(m))
|
||||
for _, v := range m {
|
||||
if str, ok := v.(string); ok {
|
||||
strSlice = append(strSlice, str)
|
||||
}
|
||||
}
|
||||
return strSlice
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getNestedMap(obj map[string]interface{}, fields ...string) map[string]string {
|
||||
if m, ok := getNestedField(obj, fields...).(map[string]interface{}); ok {
|
||||
strMap := make(map[string]string, len(m))
|
||||
for k, v := range m {
|
||||
if str, ok := v.(string); ok {
|
||||
strMap[k] = str
|
||||
}
|
||||
}
|
||||
return strMap
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setNestedField(obj map[string]interface{}, value interface{}, fields ...string) {
|
||||
m := obj
|
||||
if len(fields) > 1 {
|
||||
for _, field := range fields[0 : len(fields)-1] {
|
||||
if _, ok := m[field].(map[string]interface{}); !ok {
|
||||
m[field] = make(map[string]interface{})
|
||||
}
|
||||
m = m[field].(map[string]interface{})
|
||||
}
|
||||
}
|
||||
m[fields[len(fields)-1]] = value
|
||||
}
|
||||
|
||||
func setNestedSlice(obj map[string]interface{}, value []string, fields ...string) {
|
||||
m := make([]interface{}, 0, len(value))
|
||||
for _, v := range value {
|
||||
m = append(m, v)
|
||||
}
|
||||
setNestedField(obj, m, fields...)
|
||||
}
|
||||
|
||||
func setNestedMap(obj map[string]interface{}, value map[string]string, fields ...string) {
|
||||
m := make(map[string]interface{}, len(value))
|
||||
for k, v := range value {
|
||||
m[k] = v
|
||||
}
|
||||
setNestedField(obj, m, fields...)
|
||||
}
|
||||
|
||||
func (u *Unstructured) setNestedField(value interface{}, fields ...string) {
|
||||
if u.Object == nil {
|
||||
u.Object = make(map[string]interface{})
|
||||
}
|
||||
setNestedField(u.Object, value, fields...)
|
||||
SetNestedField(u.Object, value, fields...)
|
||||
}
|
||||
|
||||
func (u *Unstructured) setNestedSlice(value []string, fields ...string) {
|
||||
if u.Object == nil {
|
||||
u.Object = make(map[string]interface{})
|
||||
}
|
||||
setNestedSlice(u.Object, value, fields...)
|
||||
SetNestedStringSlice(u.Object, value, fields...)
|
||||
}
|
||||
|
||||
func (u *Unstructured) setNestedMap(value map[string]string, fields ...string) {
|
||||
if u.Object == nil {
|
||||
u.Object = make(map[string]interface{})
|
||||
}
|
||||
setNestedMap(u.Object, value, fields...)
|
||||
}
|
||||
|
||||
func extractOwnerReference(src interface{}) metav1.OwnerReference {
|
||||
v := src.(map[string]interface{})
|
||||
// though this field is a *bool, but when decoded from JSON, it's
|
||||
// unmarshalled as bool.
|
||||
var controllerPtr *bool
|
||||
controller, ok := (getNestedField(v, "controller")).(bool)
|
||||
if !ok {
|
||||
controllerPtr = nil
|
||||
} else {
|
||||
controllerCopy := controller
|
||||
controllerPtr = &controllerCopy
|
||||
}
|
||||
var blockOwnerDeletionPtr *bool
|
||||
blockOwnerDeletion, ok := (getNestedField(v, "blockOwnerDeletion")).(bool)
|
||||
if !ok {
|
||||
blockOwnerDeletionPtr = nil
|
||||
} else {
|
||||
blockOwnerDeletionCopy := blockOwnerDeletion
|
||||
blockOwnerDeletionPtr = &blockOwnerDeletionCopy
|
||||
}
|
||||
return metav1.OwnerReference{
|
||||
Kind: getNestedString(v, "kind"),
|
||||
Name: getNestedString(v, "name"),
|
||||
APIVersion: getNestedString(v, "apiVersion"),
|
||||
UID: (types.UID)(getNestedString(v, "uid")),
|
||||
Controller: controllerPtr,
|
||||
BlockOwnerDeletion: blockOwnerDeletionPtr,
|
||||
}
|
||||
}
|
||||
|
||||
func setOwnerReference(src metav1.OwnerReference) map[string]interface{} {
|
||||
ret := make(map[string]interface{})
|
||||
setNestedField(ret, src.Kind, "kind")
|
||||
setNestedField(ret, src.Name, "name")
|
||||
setNestedField(ret, src.APIVersion, "apiVersion")
|
||||
setNestedField(ret, string(src.UID), "uid")
|
||||
// json.Unmarshal() extracts boolean json fields as bool, not as *bool and hence extractOwnerReference()
|
||||
// expects bool or a missing field, not *bool. So if pointer is nil, fields are omitted from the ret object.
|
||||
// If pointer is non-nil, they are set to the referenced value.
|
||||
if src.Controller != nil {
|
||||
setNestedField(ret, *src.Controller, "controller")
|
||||
}
|
||||
if src.BlockOwnerDeletion != nil {
|
||||
setNestedField(ret, *src.BlockOwnerDeletion, "blockOwnerDeletion")
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func getOwnerReferences(object map[string]interface{}) ([]map[string]interface{}, error) {
|
||||
field := getNestedField(object, "metadata", "ownerReferences")
|
||||
if field == nil {
|
||||
return nil, fmt.Errorf("cannot find field metadata.ownerReferences in %v", object)
|
||||
}
|
||||
ownerReferences, ok := field.([]map[string]interface{})
|
||||
if ok {
|
||||
return ownerReferences, nil
|
||||
}
|
||||
// TODO: This is hacky...
|
||||
interfaces, ok := field.([]interface{})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("expect metadata.ownerReferences to be a slice in %#v", object)
|
||||
}
|
||||
ownerReferences = make([]map[string]interface{}, 0, len(interfaces))
|
||||
for i := 0; i < len(interfaces); i++ {
|
||||
r, ok := interfaces[i].(map[string]interface{})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("expect element metadata.ownerReferences to be a map[string]interface{} in %#v", object)
|
||||
}
|
||||
ownerReferences = append(ownerReferences, r)
|
||||
}
|
||||
return ownerReferences, nil
|
||||
SetNestedStringMap(u.Object, value, fields...)
|
||||
}
|
||||
|
||||
func (u *Unstructured) GetOwnerReferences() []metav1.OwnerReference {
|
||||
original, err := getOwnerReferences(u.Object)
|
||||
if err != nil {
|
||||
glog.V(6).Info(err)
|
||||
field, ok := nestedFieldNoCopy(u.Object, "metadata", "ownerReferences")
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
original, ok := field.([]interface{})
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
ret := make([]metav1.OwnerReference, 0, len(original))
|
||||
for i := 0; i < len(original); i++ {
|
||||
ret = append(ret, extractOwnerReference(original[i]))
|
||||
for _, obj := range original {
|
||||
o, ok := obj.(map[string]interface{})
|
||||
if !ok {
|
||||
// expected map[string]interface{}, got something else
|
||||
return nil
|
||||
}
|
||||
ret = append(ret, extractOwnerReference(o))
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (u *Unstructured) SetOwnerReferences(references []metav1.OwnerReference) {
|
||||
var newReferences = make([]map[string]interface{}, 0, len(references))
|
||||
for i := 0; i < len(references); i++ {
|
||||
newReferences = append(newReferences, setOwnerReference(references[i]))
|
||||
newReferences := make([]interface{}, 0, len(references))
|
||||
for _, reference := range references {
|
||||
out, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&reference)
|
||||
if err != nil {
|
||||
utilruntime.HandleError(fmt.Errorf("unable to convert Owner Reference: %v", err))
|
||||
continue
|
||||
}
|
||||
newReferences = append(newReferences, out)
|
||||
}
|
||||
u.setNestedField(newReferences, "metadata", "ownerReferences")
|
||||
}
|
||||
|
|
@ -453,7 +228,11 @@ func (u *Unstructured) SetResourceVersion(version string) {
|
|||
}
|
||||
|
||||
func (u *Unstructured) GetGeneration() int64 {
|
||||
return getNestedInt64(u.Object, "metadata", "generation")
|
||||
val, ok := NestedInt64(u.Object, "metadata", "generation")
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
func (u *Unstructured) SetGeneration(generation int64) {
|
||||
|
|
@ -484,6 +263,10 @@ func (u *Unstructured) GetCreationTimestamp() metav1.Time {
|
|||
|
||||
func (u *Unstructured) SetCreationTimestamp(timestamp metav1.Time) {
|
||||
ts, _ := timestamp.MarshalQueryParameter()
|
||||
if len(ts) == 0 || timestamp.Time.IsZero() {
|
||||
RemoveNestedField(u.Object, "metadata", "creationTimestamp")
|
||||
return
|
||||
}
|
||||
u.setNestedField(ts, "metadata", "creationTimestamp")
|
||||
}
|
||||
|
||||
|
|
@ -498,7 +281,7 @@ func (u *Unstructured) GetDeletionTimestamp() *metav1.Time {
|
|||
|
||||
func (u *Unstructured) SetDeletionTimestamp(timestamp *metav1.Time) {
|
||||
if timestamp == nil {
|
||||
u.setNestedField(nil, "metadata", "deletionTimestamp")
|
||||
RemoveNestedField(u.Object, "metadata", "deletionTimestamp")
|
||||
return
|
||||
}
|
||||
ts, _ := timestamp.MarshalQueryParameter()
|
||||
|
|
@ -506,15 +289,24 @@ func (u *Unstructured) SetDeletionTimestamp(timestamp *metav1.Time) {
|
|||
}
|
||||
|
||||
func (u *Unstructured) GetDeletionGracePeriodSeconds() *int64 {
|
||||
return getNestedInt64Pointer(u.Object, "metadata", "deletionGracePeriodSeconds")
|
||||
val, ok := NestedInt64(u.Object, "metadata", "deletionGracePeriodSeconds")
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return &val
|
||||
}
|
||||
|
||||
func (u *Unstructured) SetDeletionGracePeriodSeconds(deletionGracePeriodSeconds *int64) {
|
||||
u.setNestedField(deletionGracePeriodSeconds, "metadata", "deletionGracePeriodSeconds")
|
||||
if deletionGracePeriodSeconds == nil {
|
||||
RemoveNestedField(u.Object, "metadata", "deletionGracePeriodSeconds")
|
||||
return
|
||||
}
|
||||
u.setNestedField(*deletionGracePeriodSeconds, "metadata", "deletionGracePeriodSeconds")
|
||||
}
|
||||
|
||||
func (u *Unstructured) GetLabels() map[string]string {
|
||||
return getNestedMap(u.Object, "metadata", "labels")
|
||||
m, _ := NestedStringMap(u.Object, "metadata", "labels")
|
||||
return m
|
||||
}
|
||||
|
||||
func (u *Unstructured) SetLabels(labels map[string]string) {
|
||||
|
|
@ -522,7 +314,8 @@ func (u *Unstructured) SetLabels(labels map[string]string) {
|
|||
}
|
||||
|
||||
func (u *Unstructured) GetAnnotations() map[string]string {
|
||||
return getNestedMap(u.Object, "metadata", "annotations")
|
||||
m, _ := NestedStringMap(u.Object, "metadata", "annotations")
|
||||
return m
|
||||
}
|
||||
|
||||
func (u *Unstructured) SetAnnotations(annotations map[string]string) {
|
||||
|
|
@ -543,41 +336,34 @@ func (u *Unstructured) GroupVersionKind() schema.GroupVersionKind {
|
|||
return gvk
|
||||
}
|
||||
|
||||
var converter = unstructured.NewConverter(false)
|
||||
|
||||
func (u *Unstructured) GetInitializers() *metav1.Initializers {
|
||||
field := getNestedField(u.Object, "metadata", "initializers")
|
||||
if field == nil {
|
||||
return nil
|
||||
}
|
||||
obj, ok := field.(map[string]interface{})
|
||||
m, ok := nestedMapNoCopy(u.Object, "metadata", "initializers")
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
out := &metav1.Initializers{}
|
||||
if err := converter.FromUnstructured(obj, out); err != nil {
|
||||
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(m, out); err != nil {
|
||||
utilruntime.HandleError(fmt.Errorf("unable to retrieve initializers for object: %v", err))
|
||||
return nil
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (u *Unstructured) SetInitializers(initializers *metav1.Initializers) {
|
||||
if u.Object == nil {
|
||||
u.Object = make(map[string]interface{})
|
||||
}
|
||||
if initializers == nil {
|
||||
setNestedField(u.Object, nil, "metadata", "initializers")
|
||||
RemoveNestedField(u.Object, "metadata", "initializers")
|
||||
return
|
||||
}
|
||||
out, err := converter.ToUnstructured(initializers)
|
||||
out, err := runtime.DefaultUnstructuredConverter.ToUnstructured(initializers)
|
||||
if err != nil {
|
||||
utilruntime.HandleError(fmt.Errorf("unable to retrieve initializers for object: %v", err))
|
||||
}
|
||||
setNestedField(u.Object, out, "metadata", "initializers")
|
||||
u.setNestedField(out, "metadata", "initializers")
|
||||
}
|
||||
|
||||
func (u *Unstructured) GetFinalizers() []string {
|
||||
return getNestedSlice(u.Object, "metadata", "finalizers")
|
||||
val, _ := NestedStringSlice(u.Object, "metadata", "finalizers")
|
||||
return val
|
||||
}
|
||||
|
||||
func (u *Unstructured) SetFinalizers(finalizers []string) {
|
||||
|
|
@ -591,272 +377,3 @@ func (u *Unstructured) GetClusterName() string {
|
|||
func (u *Unstructured) SetClusterName(clusterName string) {
|
||||
u.setNestedField(clusterName, "metadata", "clusterName")
|
||||
}
|
||||
|
||||
// UnstructuredList allows lists that do not have Golang structs
|
||||
// registered to be manipulated generically. This can be used to deal
|
||||
// with the API lists from a plug-in.
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +k8s:deepcopy-gen=true
|
||||
type UnstructuredList struct {
|
||||
Object map[string]interface{}
|
||||
|
||||
// Items is a list of unstructured objects.
|
||||
Items []Unstructured `json:"items"`
|
||||
}
|
||||
|
||||
var _ metav1.ListInterface = &UnstructuredList{}
|
||||
|
||||
// MarshalJSON ensures that the unstructured list object produces proper
|
||||
// JSON when passed to Go's standard JSON library.
|
||||
func (u *UnstructuredList) MarshalJSON() ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
err := UnstructuredJSONScheme.Encode(u, &buf)
|
||||
return buf.Bytes(), err
|
||||
}
|
||||
|
||||
// UnmarshalJSON ensures that the unstructured list object properly
|
||||
// decodes JSON when passed to Go's standard JSON library.
|
||||
func (u *UnstructuredList) UnmarshalJSON(b []byte) error {
|
||||
_, _, err := UnstructuredJSONScheme.Decode(b, nil, u)
|
||||
return err
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) setNestedField(value interface{}, fields ...string) {
|
||||
if u.Object == nil {
|
||||
u.Object = make(map[string]interface{})
|
||||
}
|
||||
setNestedField(u.Object, value, fields...)
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) GetAPIVersion() string {
|
||||
return getNestedString(u.Object, "apiVersion")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) SetAPIVersion(version string) {
|
||||
u.setNestedField(version, "apiVersion")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) GetKind() string {
|
||||
return getNestedString(u.Object, "kind")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) SetKind(kind string) {
|
||||
u.setNestedField(kind, "kind")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) GetResourceVersion() string {
|
||||
return getNestedString(u.Object, "metadata", "resourceVersion")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) SetResourceVersion(version string) {
|
||||
u.setNestedField(version, "metadata", "resourceVersion")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) GetSelfLink() string {
|
||||
return getNestedString(u.Object, "metadata", "selfLink")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) SetSelfLink(selfLink string) {
|
||||
u.setNestedField(selfLink, "metadata", "selfLink")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) GetContinue() string {
|
||||
return getNestedString(u.Object, "metadata", "continue")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) SetContinue(c string) {
|
||||
u.setNestedField(c, "metadata", "continue")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) SetGroupVersionKind(gvk schema.GroupVersionKind) {
|
||||
u.SetAPIVersion(gvk.GroupVersion().String())
|
||||
u.SetKind(gvk.Kind)
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) GroupVersionKind() schema.GroupVersionKind {
|
||||
gv, err := schema.ParseGroupVersion(u.GetAPIVersion())
|
||||
if err != nil {
|
||||
return schema.GroupVersionKind{}
|
||||
}
|
||||
gvk := gv.WithKind(u.GetKind())
|
||||
return gvk
|
||||
}
|
||||
|
||||
// UnstructuredJSONScheme is capable of converting JSON data into the Unstructured
|
||||
// type, which can be used for generic access to objects without a predefined scheme.
|
||||
// TODO: move into serializer/json.
|
||||
var UnstructuredJSONScheme runtime.Codec = unstructuredJSONScheme{}
|
||||
|
||||
type unstructuredJSONScheme struct{}
|
||||
|
||||
func (s unstructuredJSONScheme) Decode(data []byte, _ *schema.GroupVersionKind, obj runtime.Object) (runtime.Object, *schema.GroupVersionKind, error) {
|
||||
var err error
|
||||
if obj != nil {
|
||||
err = s.decodeInto(data, obj)
|
||||
} else {
|
||||
obj, err = s.decode(data)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
gvk := obj.GetObjectKind().GroupVersionKind()
|
||||
if len(gvk.Kind) == 0 {
|
||||
return nil, &gvk, runtime.NewMissingKindErr(string(data))
|
||||
}
|
||||
|
||||
return obj, &gvk, nil
|
||||
}
|
||||
|
||||
func (unstructuredJSONScheme) Encode(obj runtime.Object, w io.Writer) error {
|
||||
switch t := obj.(type) {
|
||||
case *Unstructured:
|
||||
return json.NewEncoder(w).Encode(t.Object)
|
||||
case *UnstructuredList:
|
||||
items := make([]map[string]interface{}, 0, len(t.Items))
|
||||
for _, i := range t.Items {
|
||||
items = append(items, i.Object)
|
||||
}
|
||||
listObj := make(map[string]interface{}, len(t.Object)+1)
|
||||
for k, v := range t.Object { // Make a shallow copy
|
||||
listObj[k] = v
|
||||
}
|
||||
listObj["items"] = items
|
||||
return json.NewEncoder(w).Encode(listObj)
|
||||
case *runtime.Unknown:
|
||||
// TODO: Unstructured needs to deal with ContentType.
|
||||
_, err := w.Write(t.Raw)
|
||||
return err
|
||||
default:
|
||||
return json.NewEncoder(w).Encode(t)
|
||||
}
|
||||
}
|
||||
|
||||
func (s unstructuredJSONScheme) decode(data []byte) (runtime.Object, error) {
|
||||
type detector struct {
|
||||
Items gojson.RawMessage
|
||||
}
|
||||
var det detector
|
||||
if err := json.Unmarshal(data, &det); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if det.Items != nil {
|
||||
list := &UnstructuredList{}
|
||||
err := s.decodeToList(data, list)
|
||||
return list, err
|
||||
}
|
||||
|
||||
// No Items field, so it wasn't a list.
|
||||
unstruct := &Unstructured{}
|
||||
err := s.decodeToUnstructured(data, unstruct)
|
||||
return unstruct, err
|
||||
}
|
||||
|
||||
func (s unstructuredJSONScheme) decodeInto(data []byte, obj runtime.Object) error {
|
||||
switch x := obj.(type) {
|
||||
case *Unstructured:
|
||||
return s.decodeToUnstructured(data, x)
|
||||
case *UnstructuredList:
|
||||
return s.decodeToList(data, x)
|
||||
case *runtime.VersionedObjects:
|
||||
o, err := s.decode(data)
|
||||
if err == nil {
|
||||
x.Objects = []runtime.Object{o}
|
||||
}
|
||||
return err
|
||||
default:
|
||||
return json.Unmarshal(data, x)
|
||||
}
|
||||
}
|
||||
|
||||
func (unstructuredJSONScheme) decodeToUnstructured(data []byte, unstruct *Unstructured) error {
|
||||
m := make(map[string]interface{})
|
||||
if err := json.Unmarshal(data, &m); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
unstruct.Object = m
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s unstructuredJSONScheme) decodeToList(data []byte, list *UnstructuredList) error {
|
||||
type decodeList struct {
|
||||
Items []gojson.RawMessage
|
||||
}
|
||||
|
||||
var dList decodeList
|
||||
if err := json.Unmarshal(data, &dList); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(data, &list.Object); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// For typed lists, e.g., a PodList, API server doesn't set each item's
|
||||
// APIVersion and Kind. We need to set it.
|
||||
listAPIVersion := list.GetAPIVersion()
|
||||
listKind := list.GetKind()
|
||||
itemKind := strings.TrimSuffix(listKind, "List")
|
||||
|
||||
delete(list.Object, "items")
|
||||
list.Items = nil
|
||||
for _, i := range dList.Items {
|
||||
unstruct := &Unstructured{}
|
||||
if err := s.decodeToUnstructured([]byte(i), unstruct); err != nil {
|
||||
return err
|
||||
}
|
||||
// This is hacky. Set the item's Kind and APIVersion to those inferred
|
||||
// from the List.
|
||||
if len(unstruct.GetKind()) == 0 && len(unstruct.GetAPIVersion()) == 0 {
|
||||
unstruct.SetKind(itemKind)
|
||||
unstruct.SetAPIVersion(listAPIVersion)
|
||||
}
|
||||
list.Items = append(list.Items, *unstruct)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnstructuredObjectConverter is an ObjectConverter for use with
|
||||
// Unstructured objects. Since it has no schema or type information,
|
||||
// it will only succeed for no-op conversions. This is provided as a
|
||||
// sane implementation for APIs that require an object converter.
|
||||
type UnstructuredObjectConverter struct{}
|
||||
|
||||
func (UnstructuredObjectConverter) Convert(in, out, context interface{}) error {
|
||||
unstructIn, ok := in.(*Unstructured)
|
||||
if !ok {
|
||||
return fmt.Errorf("input type %T in not valid for unstructured conversion", in)
|
||||
}
|
||||
|
||||
unstructOut, ok := out.(*Unstructured)
|
||||
if !ok {
|
||||
return fmt.Errorf("output type %T in not valid for unstructured conversion", out)
|
||||
}
|
||||
|
||||
// maybe deep copy the map? It is documented in the
|
||||
// ObjectConverter interface that this function is not
|
||||
// guaranteeed to not mutate the input. Or maybe set the input
|
||||
// object to nil.
|
||||
unstructOut.Object = unstructIn.Object
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnstructuredObjectConverter) ConvertToVersion(in runtime.Object, target runtime.GroupVersioner) (runtime.Object, error) {
|
||||
if kind := in.GetObjectKind().GroupVersionKind(); !kind.Empty() {
|
||||
gvk, ok := target.KindForGroupVersionKinds([]schema.GroupVersionKind{kind})
|
||||
if !ok {
|
||||
// TODO: should this be a typed error?
|
||||
return nil, fmt.Errorf("%v is unstructured and is not suitable for converting to %q", kind, target)
|
||||
}
|
||||
in.GetObjectKind().SetGroupVersionKind(gvk)
|
||||
}
|
||||
return in, nil
|
||||
}
|
||||
|
||||
func (UnstructuredObjectConverter) ConvertFieldLabel(version, kind, label, value string) (string, string, error) {
|
||||
return "", "", errors.New("unstructured cannot convert field labels")
|
||||
}
|
||||
|
|
|
|||
189
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_list.go
generated
vendored
Normal file
189
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_list.go
generated
vendored
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
/*
|
||||
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 unstructured
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
var _ runtime.Unstructured = &UnstructuredList{}
|
||||
var _ metav1.ListInterface = &UnstructuredList{}
|
||||
|
||||
// UnstructuredList allows lists that do not have Golang structs
|
||||
// registered to be manipulated generically. This can be used to deal
|
||||
// with the API lists from a plug-in.
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +k8s:deepcopy-gen=true
|
||||
type UnstructuredList struct {
|
||||
Object map[string]interface{}
|
||||
|
||||
// Items is a list of unstructured objects.
|
||||
Items []Unstructured `json:"items"`
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) GetObjectKind() schema.ObjectKind { return u }
|
||||
|
||||
func (u *UnstructuredList) IsList() bool { return true }
|
||||
|
||||
func (u *UnstructuredList) EachListItem(fn func(runtime.Object) error) error {
|
||||
for i := range u.Items {
|
||||
if err := fn(&u.Items[i]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnstructuredContent returns a map contain an overlay of the Items field onto
|
||||
// the Object field. Items always overwrites overlay. Changing "items" in the
|
||||
// returned object will affect items in the underlying Items field, but changing
|
||||
// the "items" slice itself will have no effect.
|
||||
// TODO: expose SetUnstructuredContent on runtime.Unstructured that allows
|
||||
// items to be changed.
|
||||
func (u *UnstructuredList) UnstructuredContent() map[string]interface{} {
|
||||
out := u.Object
|
||||
if out == nil {
|
||||
out = make(map[string]interface{})
|
||||
}
|
||||
items := make([]interface{}, len(u.Items))
|
||||
for i, item := range u.Items {
|
||||
items[i] = item.Object
|
||||
}
|
||||
out["items"] = items
|
||||
return out
|
||||
}
|
||||
|
||||
// SetUnstructuredContent obeys the conventions of List and keeps Items and the items
|
||||
// array in sync. If items is not an array of objects in the incoming map, then any
|
||||
// mismatched item will be removed.
|
||||
func (obj *UnstructuredList) SetUnstructuredContent(content map[string]interface{}) {
|
||||
obj.Object = content
|
||||
if content == nil {
|
||||
obj.Items = nil
|
||||
return
|
||||
}
|
||||
items, ok := obj.Object["items"].([]interface{})
|
||||
if !ok || items == nil {
|
||||
items = []interface{}{}
|
||||
}
|
||||
unstructuredItems := make([]Unstructured, 0, len(items))
|
||||
newItems := make([]interface{}, 0, len(items))
|
||||
for _, item := range items {
|
||||
o, ok := item.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
unstructuredItems = append(unstructuredItems, Unstructured{Object: o})
|
||||
newItems = append(newItems, o)
|
||||
}
|
||||
obj.Items = unstructuredItems
|
||||
obj.Object["items"] = newItems
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) DeepCopy() *UnstructuredList {
|
||||
if u == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(UnstructuredList)
|
||||
*out = *u
|
||||
out.Object = runtime.DeepCopyJSON(u.Object)
|
||||
out.Items = make([]Unstructured, len(u.Items))
|
||||
for i := range u.Items {
|
||||
u.Items[i].DeepCopyInto(&out.Items[i])
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// MarshalJSON ensures that the unstructured list object produces proper
|
||||
// JSON when passed to Go's standard JSON library.
|
||||
func (u *UnstructuredList) MarshalJSON() ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
err := UnstructuredJSONScheme.Encode(u, &buf)
|
||||
return buf.Bytes(), err
|
||||
}
|
||||
|
||||
// UnmarshalJSON ensures that the unstructured list object properly
|
||||
// decodes JSON when passed to Go's standard JSON library.
|
||||
func (u *UnstructuredList) UnmarshalJSON(b []byte) error {
|
||||
_, _, err := UnstructuredJSONScheme.Decode(b, nil, u)
|
||||
return err
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) GetAPIVersion() string {
|
||||
return getNestedString(u.Object, "apiVersion")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) SetAPIVersion(version string) {
|
||||
u.setNestedField(version, "apiVersion")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) GetKind() string {
|
||||
return getNestedString(u.Object, "kind")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) SetKind(kind string) {
|
||||
u.setNestedField(kind, "kind")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) GetResourceVersion() string {
|
||||
return getNestedString(u.Object, "metadata", "resourceVersion")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) SetResourceVersion(version string) {
|
||||
u.setNestedField(version, "metadata", "resourceVersion")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) GetSelfLink() string {
|
||||
return getNestedString(u.Object, "metadata", "selfLink")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) SetSelfLink(selfLink string) {
|
||||
u.setNestedField(selfLink, "metadata", "selfLink")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) GetContinue() string {
|
||||
return getNestedString(u.Object, "metadata", "continue")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) SetContinue(c string) {
|
||||
u.setNestedField(c, "metadata", "continue")
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) SetGroupVersionKind(gvk schema.GroupVersionKind) {
|
||||
u.SetAPIVersion(gvk.GroupVersion().String())
|
||||
u.SetKind(gvk.Kind)
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) GroupVersionKind() schema.GroupVersionKind {
|
||||
gv, err := schema.ParseGroupVersion(u.GetAPIVersion())
|
||||
if err != nil {
|
||||
return schema.GroupVersionKind{}
|
||||
}
|
||||
gvk := gv.WithKind(u.GetKind())
|
||||
return gvk
|
||||
}
|
||||
|
||||
func (u *UnstructuredList) setNestedField(value interface{}, fields ...string) {
|
||||
if u.Object == nil {
|
||||
u.Object = make(map[string]interface{})
|
||||
}
|
||||
SetNestedField(u.Object, value, fields...)
|
||||
}
|
||||
85
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_list_test.go
generated
vendored
Normal file
85
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_list_test.go
generated
vendored
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
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 unstructured
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestUnstructuredList(t *testing.T) {
|
||||
list := &UnstructuredList{
|
||||
Object: map[string]interface{}{"kind": "List", "apiVersion": "v1"},
|
||||
Items: []Unstructured{
|
||||
{Object: map[string]interface{}{"kind": "Pod", "apiVersion": "v1", "metadata": map[string]interface{}{"name": "test"}}},
|
||||
},
|
||||
}
|
||||
content := list.UnstructuredContent()
|
||||
items := content["items"].([]interface{})
|
||||
require.Len(t, items, 1)
|
||||
val, ok := NestedFieldCopy(items[0].(map[string]interface{}), "metadata", "name")
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, "test", val)
|
||||
}
|
||||
|
||||
func TestNilDeletionTimestamp(t *testing.T) {
|
||||
var u Unstructured
|
||||
del := u.GetDeletionTimestamp()
|
||||
if del != nil {
|
||||
t.Errorf("unexpected non-nil deletion timestamp: %v", del)
|
||||
}
|
||||
u.SetDeletionTimestamp(u.GetDeletionTimestamp())
|
||||
del = u.GetDeletionTimestamp()
|
||||
if del != nil {
|
||||
t.Errorf("unexpected non-nil deletion timestamp: %v", del)
|
||||
}
|
||||
_, ok := u.Object["metadata"]
|
||||
assert.False(t, ok)
|
||||
|
||||
now := metav1.Now()
|
||||
u.SetDeletionTimestamp(&now)
|
||||
assert.Equal(t, now.Unix(), u.GetDeletionTimestamp().Unix())
|
||||
u.SetDeletionTimestamp(nil)
|
||||
metadata := u.Object["metadata"].(map[string]interface{})
|
||||
_, ok = metadata["deletionTimestamp"]
|
||||
assert.False(t, ok)
|
||||
}
|
||||
|
||||
func TestEmptyCreationTimestampIsOmitted(t *testing.T) {
|
||||
var u Unstructured
|
||||
now := metav1.Now()
|
||||
|
||||
// set an initial creationTimestamp and ensure the field exists
|
||||
u.SetCreationTimestamp(now)
|
||||
metadata := u.Object["metadata"].(map[string]interface{})
|
||||
creationTimestamp, exists := metadata["creationTimestamp"]
|
||||
if !exists {
|
||||
t.Fatalf("unexpected missing creationTimestamp")
|
||||
}
|
||||
|
||||
// set an empty timestamp and ensure the field no longer exists
|
||||
u.SetCreationTimestamp(metav1.Time{})
|
||||
metadata = u.Object["metadata"].(map[string]interface{})
|
||||
creationTimestamp, exists = metadata["creationTimestamp"]
|
||||
if exists {
|
||||
t.Errorf("unexpected creation timestamp field: %q", creationTimestamp)
|
||||
}
|
||||
}
|
||||
20
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/zz_generated.deepcopy.go
generated
vendored
20
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/zz_generated.deepcopy.go
generated
vendored
|
|
@ -1,7 +1,7 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
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.
|
||||
|
|
@ -21,27 +21,9 @@ limitations under the License.
|
|||
package unstructured
|
||||
|
||||
import (
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// GetGeneratedDeepCopyFuncs returns the generated funcs, since we aren't registering them.
|
||||
//
|
||||
// Deprecated: deepcopy registration will go away when static deepcopy is fully implemented.
|
||||
func GetGeneratedDeepCopyFuncs() []conversion.GeneratedDeepCopyFunc {
|
||||
return []conversion.GeneratedDeepCopyFunc{
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*Unstructured).DeepCopyInto(out.(*Unstructured))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&Unstructured{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*UnstructuredList).DeepCopyInto(out.(*UnstructuredList))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&UnstructuredList{})},
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Unstructured) DeepCopyInto(out *Unstructured) {
|
||||
clone := in.DeepCopy()
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/validation/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/validation/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["validation_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1/validation",
|
||||
library = ":go_default_library",
|
||||
deps = ["//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library"],
|
||||
)
|
||||
|
|
@ -16,6 +17,7 @@ go_test(
|
|||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["validation.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1/validation",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/validation:go_default_library",
|
||||
|
|
|
|||
156
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/zz_generated.deepcopy.go
generated
vendored
156
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/zz_generated.deepcopy.go
generated
vendored
|
|
@ -1,7 +1,7 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
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.
|
||||
|
|
@ -21,164 +21,10 @@ limitations under the License.
|
|||
package v1
|
||||
|
||||
import (
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// GetGeneratedDeepCopyFuncs returns the generated funcs, since we aren't registering them.
|
||||
//
|
||||
// Deprecated: deepcopy registration will go away when static deepcopy is fully implemented.
|
||||
func GetGeneratedDeepCopyFuncs() []conversion.GeneratedDeepCopyFunc {
|
||||
return []conversion.GeneratedDeepCopyFunc{
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*APIGroup).DeepCopyInto(out.(*APIGroup))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&APIGroup{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*APIGroupList).DeepCopyInto(out.(*APIGroupList))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&APIGroupList{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*APIResource).DeepCopyInto(out.(*APIResource))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&APIResource{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*APIResourceList).DeepCopyInto(out.(*APIResourceList))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&APIResourceList{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*APIVersions).DeepCopyInto(out.(*APIVersions))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&APIVersions{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*DeleteOptions).DeepCopyInto(out.(*DeleteOptions))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&DeleteOptions{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*Duration).DeepCopyInto(out.(*Duration))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&Duration{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*ExportOptions).DeepCopyInto(out.(*ExportOptions))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&ExportOptions{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*GetOptions).DeepCopyInto(out.(*GetOptions))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&GetOptions{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*GroupKind).DeepCopyInto(out.(*GroupKind))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&GroupKind{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*GroupResource).DeepCopyInto(out.(*GroupResource))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&GroupResource{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*GroupVersion).DeepCopyInto(out.(*GroupVersion))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&GroupVersion{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*GroupVersionForDiscovery).DeepCopyInto(out.(*GroupVersionForDiscovery))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&GroupVersionForDiscovery{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*GroupVersionKind).DeepCopyInto(out.(*GroupVersionKind))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&GroupVersionKind{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*GroupVersionResource).DeepCopyInto(out.(*GroupVersionResource))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&GroupVersionResource{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*Initializer).DeepCopyInto(out.(*Initializer))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&Initializer{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*Initializers).DeepCopyInto(out.(*Initializers))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&Initializers{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*InternalEvent).DeepCopyInto(out.(*InternalEvent))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&InternalEvent{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*LabelSelector).DeepCopyInto(out.(*LabelSelector))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&LabelSelector{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*LabelSelectorRequirement).DeepCopyInto(out.(*LabelSelectorRequirement))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&LabelSelectorRequirement{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*List).DeepCopyInto(out.(*List))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&List{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*ListMeta).DeepCopyInto(out.(*ListMeta))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&ListMeta{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*ListOptions).DeepCopyInto(out.(*ListOptions))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&ListOptions{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*MicroTime).DeepCopyInto(out.(*MicroTime))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&MicroTime{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*ObjectMeta).DeepCopyInto(out.(*ObjectMeta))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&ObjectMeta{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*OwnerReference).DeepCopyInto(out.(*OwnerReference))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&OwnerReference{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*Patch).DeepCopyInto(out.(*Patch))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&Patch{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*Preconditions).DeepCopyInto(out.(*Preconditions))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&Preconditions{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*RootPaths).DeepCopyInto(out.(*RootPaths))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&RootPaths{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*ServerAddressByClientCIDR).DeepCopyInto(out.(*ServerAddressByClientCIDR))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&ServerAddressByClientCIDR{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*Status).DeepCopyInto(out.(*Status))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&Status{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*StatusCause).DeepCopyInto(out.(*StatusCause))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&StatusCause{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*StatusDetails).DeepCopyInto(out.(*StatusDetails))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&StatusDetails{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*Time).DeepCopyInto(out.(*Time))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&Time{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*Timestamp).DeepCopyInto(out.(*Timestamp))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&Timestamp{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*WatchEvent).DeepCopyInto(out.(*WatchEvent))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&WatchEvent{})},
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *APIGroup) DeepCopyInto(out *APIGroup) {
|
||||
*out = *in
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/zz_generated.defaults.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/zz_generated.defaults.go
generated
vendored
|
|
@ -1,7 +1,7 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
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.
|
||||
|
|
|
|||
1
vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1/BUILD
generated
vendored
1
vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1/BUILD
generated
vendored
|
|
@ -18,6 +18,7 @@ go_library(
|
|||
"zz_generated.deepcopy.go",
|
||||
"zz_generated.defaults.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
|
||||
deps = [
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1/generated.pb.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1/generated.pb.go
generated
vendored
|
|
@ -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.
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1/generated.proto
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1/generated.proto
generated
vendored
|
|
@ -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.
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1/types.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1/types.go
generated
vendored
|
|
@ -98,7 +98,7 @@ type TableRowCondition struct {
|
|||
type RowConditionType string
|
||||
|
||||
// These are valid conditions of a row. This list is not exhaustive and new conditions may be
|
||||
// inculded by other resources.
|
||||
// included by other resources.
|
||||
const (
|
||||
// RowCompleted means the underlying resource has reached completion and may be given less
|
||||
// visual priority than other resources.
|
||||
|
|
|
|||
40
vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1/zz_generated.deepcopy.go
generated
vendored
40
vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1/zz_generated.deepcopy.go
generated
vendored
|
|
@ -1,7 +1,7 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
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.
|
||||
|
|
@ -21,47 +21,9 @@ limitations under the License.
|
|||
package v1alpha1
|
||||
|
||||
import (
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// GetGeneratedDeepCopyFuncs returns the generated funcs, since we aren't registering them.
|
||||
//
|
||||
// Deprecated: deepcopy registration will go away when static deepcopy is fully implemented.
|
||||
func GetGeneratedDeepCopyFuncs() []conversion.GeneratedDeepCopyFunc {
|
||||
return []conversion.GeneratedDeepCopyFunc{
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*PartialObjectMetadata).DeepCopyInto(out.(*PartialObjectMetadata))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&PartialObjectMetadata{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*PartialObjectMetadataList).DeepCopyInto(out.(*PartialObjectMetadataList))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&PartialObjectMetadataList{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*Table).DeepCopyInto(out.(*Table))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&Table{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*TableColumnDefinition).DeepCopyInto(out.(*TableColumnDefinition))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&TableColumnDefinition{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*TableOptions).DeepCopyInto(out.(*TableOptions))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&TableOptions{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*TableRow).DeepCopyInto(out.(*TableRow))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&TableRow{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*TableRowCondition).DeepCopyInto(out.(*TableRowCondition))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&TableRowCondition{})},
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *PartialObjectMetadata) DeepCopyInto(out *PartialObjectMetadata) {
|
||||
*out = *in
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1/zz_generated.defaults.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1/zz_generated.defaults.go
generated
vendored
|
|
@ -1,7 +1,7 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
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.
|
||||
|
|
|
|||
5
vendor/k8s.io/apimachinery/pkg/conversion/BUILD
generated
vendored
5
vendor/k8s.io/apimachinery/pkg/conversion/BUILD
generated
vendored
|
|
@ -10,9 +10,9 @@ go_test(
|
|||
name = "go_default_test",
|
||||
srcs = [
|
||||
"converter_test.go",
|
||||
"deep_copy_test.go",
|
||||
"helper_test.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/conversion",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
|
|
@ -24,12 +24,12 @@ go_test(
|
|||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"cloner.go",
|
||||
"converter.go",
|
||||
"deep_equal.go",
|
||||
"doc.go",
|
||||
"helper.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/conversion",
|
||||
deps = ["//vendor/k8s.io/apimachinery/third_party/forked/golang/reflect:go_default_library"],
|
||||
)
|
||||
|
||||
|
|
@ -45,7 +45,6 @@ filegroup(
|
|||
srcs = [
|
||||
":package-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/conversion/queryparams:all-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/conversion/unstructured:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
|
|
|||
249
vendor/k8s.io/apimachinery/pkg/conversion/cloner.go
generated
vendored
249
vendor/k8s.io/apimachinery/pkg/conversion/cloner.go
generated
vendored
|
|
@ -1,249 +0,0 @@
|
|||
/*
|
||||
Copyright 2014 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 conversion
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// Cloner knows how to copy one type to another.
|
||||
type Cloner struct {
|
||||
// Map from the type to a function which can do the deep copy.
|
||||
deepCopyFuncs map[reflect.Type]reflect.Value
|
||||
generatedDeepCopyFuncs map[reflect.Type]func(in interface{}, out interface{}, c *Cloner) error
|
||||
}
|
||||
|
||||
// NewCloner creates a new Cloner object.
|
||||
func NewCloner() *Cloner {
|
||||
c := &Cloner{
|
||||
deepCopyFuncs: map[reflect.Type]reflect.Value{},
|
||||
generatedDeepCopyFuncs: map[reflect.Type]func(in interface{}, out interface{}, c *Cloner) error{},
|
||||
}
|
||||
if err := c.RegisterDeepCopyFunc(byteSliceDeepCopy); err != nil {
|
||||
// If one of the deep-copy functions is malformed, detect it immediately.
|
||||
panic(err)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// Prevent recursing into every byte...
|
||||
func byteSliceDeepCopy(in *[]byte, out *[]byte, c *Cloner) error {
|
||||
if *in != nil {
|
||||
*out = make([]byte, len(*in))
|
||||
copy(*out, *in)
|
||||
} else {
|
||||
*out = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Verifies whether a deep-copy function has a correct signature.
|
||||
func verifyDeepCopyFunctionSignature(ft reflect.Type) error {
|
||||
if ft.Kind() != reflect.Func {
|
||||
return fmt.Errorf("expected func, got: %v", ft)
|
||||
}
|
||||
if ft.NumIn() != 3 {
|
||||
return fmt.Errorf("expected three 'in' params, got %v", ft)
|
||||
}
|
||||
if ft.NumOut() != 1 {
|
||||
return fmt.Errorf("expected one 'out' param, got %v", ft)
|
||||
}
|
||||
if ft.In(0).Kind() != reflect.Ptr {
|
||||
return fmt.Errorf("expected pointer arg for 'in' param 0, got: %v", ft)
|
||||
}
|
||||
if ft.In(1) != ft.In(0) {
|
||||
return fmt.Errorf("expected 'in' param 0 the same as param 1, got: %v", ft)
|
||||
}
|
||||
var forClonerType Cloner
|
||||
if expected := reflect.TypeOf(&forClonerType); ft.In(2) != expected {
|
||||
return fmt.Errorf("expected '%v' arg for 'in' param 2, got: '%v'", expected, ft.In(2))
|
||||
}
|
||||
var forErrorType error
|
||||
// This convolution is necessary, otherwise TypeOf picks up on the fact
|
||||
// that forErrorType is nil
|
||||
errorType := reflect.TypeOf(&forErrorType).Elem()
|
||||
if ft.Out(0) != errorType {
|
||||
return fmt.Errorf("expected error return, got: %v", ft)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterGeneratedDeepCopyFunc registers a copying func with the Cloner.
|
||||
// deepCopyFunc must take three parameters: a type input, a pointer to a
|
||||
// type output, and a pointer to Cloner. It should return an error.
|
||||
//
|
||||
// Example:
|
||||
// c.RegisterGeneratedDeepCopyFunc(
|
||||
// func(in Pod, out *Pod, c *Cloner) error {
|
||||
// // deep copy logic...
|
||||
// return nil
|
||||
// })
|
||||
func (c *Cloner) RegisterDeepCopyFunc(deepCopyFunc interface{}) error {
|
||||
fv := reflect.ValueOf(deepCopyFunc)
|
||||
ft := fv.Type()
|
||||
if err := verifyDeepCopyFunctionSignature(ft); err != nil {
|
||||
return err
|
||||
}
|
||||
c.deepCopyFuncs[ft.In(0)] = fv
|
||||
return nil
|
||||
}
|
||||
|
||||
// GeneratedDeepCopyFunc bundles an untyped generated deep-copy function of a type
|
||||
// with a reflection type object used as a key to lookup the deep-copy function.
|
||||
type GeneratedDeepCopyFunc struct {
|
||||
Fn func(in interface{}, out interface{}, c *Cloner) error
|
||||
InType reflect.Type
|
||||
}
|
||||
|
||||
// Similar to RegisterDeepCopyFunc, but registers deep copy function that were
|
||||
// automatically generated.
|
||||
func (c *Cloner) RegisterGeneratedDeepCopyFunc(fn GeneratedDeepCopyFunc) error {
|
||||
c.generatedDeepCopyFuncs[fn.InType] = fn.Fn
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopy will perform a deep copy of a given object.
|
||||
func (c *Cloner) DeepCopy(in interface{}) (interface{}, error) {
|
||||
// Can be invalid if we run DeepCopy(X) where X is a nil interface type.
|
||||
// For example, we get an invalid value when someone tries to deep-copy
|
||||
// a nil labels.Selector.
|
||||
// This does not occur if X is nil and is a pointer to a concrete type.
|
||||
if in == nil {
|
||||
return nil, nil
|
||||
}
|
||||
inValue := reflect.ValueOf(in)
|
||||
outValue, err := c.deepCopy(inValue)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return outValue.Interface(), nil
|
||||
}
|
||||
|
||||
func (c *Cloner) deepCopy(src reflect.Value) (reflect.Value, error) {
|
||||
inType := src.Type()
|
||||
|
||||
switch src.Kind() {
|
||||
case reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice:
|
||||
if src.IsNil() {
|
||||
return src, nil
|
||||
}
|
||||
}
|
||||
|
||||
if fv, ok := c.deepCopyFuncs[inType]; ok {
|
||||
return c.customDeepCopy(src, fv)
|
||||
}
|
||||
if fv, ok := c.generatedDeepCopyFuncs[inType]; ok {
|
||||
var outValue reflect.Value
|
||||
outValue = reflect.New(inType.Elem())
|
||||
err := fv(src.Interface(), outValue.Interface(), c)
|
||||
return outValue, err
|
||||
}
|
||||
return c.defaultDeepCopy(src)
|
||||
}
|
||||
|
||||
func (c *Cloner) customDeepCopy(src, fv reflect.Value) (reflect.Value, error) {
|
||||
outValue := reflect.New(src.Type().Elem())
|
||||
args := []reflect.Value{src, outValue, reflect.ValueOf(c)}
|
||||
result := fv.Call(args)[0].Interface()
|
||||
// This convolution is necessary because nil interfaces won't convert
|
||||
// to error.
|
||||
if result == nil {
|
||||
return outValue, nil
|
||||
}
|
||||
return outValue, result.(error)
|
||||
}
|
||||
|
||||
func (c *Cloner) defaultDeepCopy(src reflect.Value) (reflect.Value, error) {
|
||||
switch src.Kind() {
|
||||
case reflect.Chan, reflect.Func, reflect.UnsafePointer, reflect.Uintptr:
|
||||
return src, fmt.Errorf("cannot deep copy kind: %s", src.Kind())
|
||||
case reflect.Array:
|
||||
dst := reflect.New(src.Type())
|
||||
for i := 0; i < src.Len(); i++ {
|
||||
copyVal, err := c.deepCopy(src.Index(i))
|
||||
if err != nil {
|
||||
return src, err
|
||||
}
|
||||
dst.Elem().Index(i).Set(copyVal)
|
||||
}
|
||||
return dst.Elem(), nil
|
||||
case reflect.Interface:
|
||||
if src.IsNil() {
|
||||
return src, nil
|
||||
}
|
||||
return c.deepCopy(src.Elem())
|
||||
case reflect.Map:
|
||||
if src.IsNil() {
|
||||
return src, nil
|
||||
}
|
||||
dst := reflect.MakeMap(src.Type())
|
||||
for _, k := range src.MapKeys() {
|
||||
copyVal, err := c.deepCopy(src.MapIndex(k))
|
||||
if err != nil {
|
||||
return src, err
|
||||
}
|
||||
dst.SetMapIndex(k, copyVal)
|
||||
}
|
||||
return dst, nil
|
||||
case reflect.Ptr:
|
||||
if src.IsNil() {
|
||||
return src, nil
|
||||
}
|
||||
dst := reflect.New(src.Type().Elem())
|
||||
copyVal, err := c.deepCopy(src.Elem())
|
||||
if err != nil {
|
||||
return src, err
|
||||
}
|
||||
dst.Elem().Set(copyVal)
|
||||
return dst, nil
|
||||
case reflect.Slice:
|
||||
if src.IsNil() {
|
||||
return src, nil
|
||||
}
|
||||
dst := reflect.MakeSlice(src.Type(), 0, src.Len())
|
||||
for i := 0; i < src.Len(); i++ {
|
||||
copyVal, err := c.deepCopy(src.Index(i))
|
||||
if err != nil {
|
||||
return src, err
|
||||
}
|
||||
dst = reflect.Append(dst, copyVal)
|
||||
}
|
||||
return dst, nil
|
||||
case reflect.Struct:
|
||||
dst := reflect.New(src.Type())
|
||||
for i := 0; i < src.NumField(); i++ {
|
||||
if !dst.Elem().Field(i).CanSet() {
|
||||
// Can't set private fields. At this point, the
|
||||
// best we can do is a shallow copy. For
|
||||
// example, time.Time is a value type with
|
||||
// private members that can be shallow copied.
|
||||
return src, nil
|
||||
}
|
||||
copyVal, err := c.deepCopy(src.Field(i))
|
||||
if err != nil {
|
||||
return src, err
|
||||
}
|
||||
dst.Elem().Field(i).Set(copyVal)
|
||||
}
|
||||
return dst.Elem(), nil
|
||||
|
||||
default:
|
||||
// Value types like numbers, booleans, and strings.
|
||||
return src, nil
|
||||
}
|
||||
}
|
||||
161
vendor/k8s.io/apimachinery/pkg/conversion/deep_copy_test.go
generated
vendored
161
vendor/k8s.io/apimachinery/pkg/conversion/deep_copy_test.go
generated
vendored
|
|
@ -1,161 +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 conversion
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/google/gofuzz"
|
||||
)
|
||||
|
||||
func TestDeepCopy(t *testing.T) {
|
||||
semantic := EqualitiesOrDie()
|
||||
f := fuzz.New().NilChance(.5).NumElements(0, 100)
|
||||
table := []interface{}{
|
||||
map[string]string{},
|
||||
int(5),
|
||||
"hello world",
|
||||
struct {
|
||||
A, B, C struct {
|
||||
D map[string]int
|
||||
}
|
||||
X []int
|
||||
Y []byte
|
||||
}{},
|
||||
}
|
||||
for _, obj := range table {
|
||||
obj2, err := NewCloner().DeepCopy(obj)
|
||||
if err != nil {
|
||||
t.Errorf("Error: couldn't copy %#v", obj)
|
||||
continue
|
||||
}
|
||||
if e, a := obj, obj2; !semantic.DeepEqual(e, a) {
|
||||
t.Errorf("expected %#v\ngot %#v", e, a)
|
||||
}
|
||||
|
||||
obj3 := reflect.New(reflect.TypeOf(obj)).Interface()
|
||||
f.Fuzz(obj3)
|
||||
obj4, err := NewCloner().DeepCopy(obj3)
|
||||
if err != nil {
|
||||
t.Errorf("Error: couldn't copy %#v", obj)
|
||||
continue
|
||||
}
|
||||
if e, a := obj3, obj4; !semantic.DeepEqual(e, a) {
|
||||
t.Errorf("expected %#v\ngot %#v", e, a)
|
||||
}
|
||||
f.Fuzz(obj3)
|
||||
}
|
||||
}
|
||||
|
||||
func copyOrDie(t *testing.T, in interface{}) interface{} {
|
||||
out, err := NewCloner().DeepCopy(in)
|
||||
if err != nil {
|
||||
t.Fatalf("DeepCopy failed: %#q: %v", in, err)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func TestDeepCopySliceSeparate(t *testing.T) {
|
||||
x := []int{5}
|
||||
y := copyOrDie(t, x).([]int)
|
||||
x[0] = 3
|
||||
if y[0] == 3 {
|
||||
t.Errorf("deep copy wasn't deep: %#q %#q", x, y)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeepCopyArraySeparate(t *testing.T) {
|
||||
x := [1]int{5}
|
||||
y := copyOrDie(t, x).([1]int)
|
||||
x[0] = 3
|
||||
if y[0] == 3 {
|
||||
t.Errorf("deep copy wasn't deep: %#q %#q", x, y)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeepCopyMapSeparate(t *testing.T) {
|
||||
x := map[string]int{"foo": 5}
|
||||
y := copyOrDie(t, x).(map[string]int)
|
||||
x["foo"] = 3
|
||||
if y["foo"] == 3 {
|
||||
t.Errorf("deep copy wasn't deep: %#q %#q", x, y)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeepCopyPointerSeparate(t *testing.T) {
|
||||
z := 5
|
||||
x := &z
|
||||
y := copyOrDie(t, x).(*int)
|
||||
*x = 3
|
||||
if *y == 3 {
|
||||
t.Errorf("deep copy wasn't deep: %#q %#q", x, y)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeepCopyStruct(t *testing.T) {
|
||||
type Foo struct {
|
||||
A int
|
||||
}
|
||||
type Bar struct {
|
||||
Foo
|
||||
F *Foo
|
||||
}
|
||||
a := &Bar{Foo{1}, &Foo{2}}
|
||||
b := copyOrDie(t, a).(*Bar)
|
||||
a.A = 3
|
||||
a.F.A = 4
|
||||
|
||||
if b.A != 1 || b.F.A != 2 {
|
||||
t.Errorf("deep copy wasn't deep: %#v, %#v", a, b)
|
||||
}
|
||||
}
|
||||
|
||||
var result interface{}
|
||||
|
||||
func BenchmarkDeepCopy(b *testing.B) {
|
||||
table := []interface{}{
|
||||
map[string]string{},
|
||||
int(5),
|
||||
"hello world",
|
||||
struct {
|
||||
A, B, C struct {
|
||||
D map[string]int
|
||||
}
|
||||
X []int
|
||||
Y []byte
|
||||
}{},
|
||||
}
|
||||
|
||||
f := fuzz.New().RandSource(rand.NewSource(1)).NilChance(.5).NumElements(0, 100)
|
||||
for i := range table {
|
||||
out := table[i]
|
||||
obj := reflect.New(reflect.TypeOf(out)).Interface()
|
||||
f.Fuzz(obj)
|
||||
table[i] = obj
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
var r interface{}
|
||||
for i := 0; i < b.N; i++ {
|
||||
for j := range table {
|
||||
r, _ = NewCloner().DeepCopy(table[j])
|
||||
}
|
||||
}
|
||||
result = r
|
||||
}
|
||||
2
vendor/k8s.io/apimachinery/pkg/conversion/queryparams/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/conversion/queryparams/BUILD
generated
vendored
|
|
@ -12,11 +12,13 @@ go_library(
|
|||
"convert.go",
|
||||
"doc.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/conversion/queryparams",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["convert_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/conversion/queryparams_test",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion/queryparams:go_default_library",
|
||||
|
|
|
|||
9
vendor/k8s.io/apimachinery/pkg/conversion/queryparams/convert.go
generated
vendored
9
vendor/k8s.io/apimachinery/pkg/conversion/queryparams/convert.go
generated
vendored
|
|
@ -90,7 +90,14 @@ func customMarshalValue(value reflect.Value) (reflect.Value, bool) {
|
|||
|
||||
marshaler, ok := value.Interface().(Marshaler)
|
||||
if !ok {
|
||||
return reflect.Value{}, false
|
||||
if !isPointerKind(value.Kind()) && value.CanAddr() {
|
||||
marshaler, ok = value.Addr().Interface().(Marshaler)
|
||||
if !ok {
|
||||
return reflect.Value{}, false
|
||||
}
|
||||
} else {
|
||||
return reflect.Value{}, false
|
||||
}
|
||||
}
|
||||
|
||||
// Don't invoke functions on nil pointers
|
||||
|
|
|
|||
41
vendor/k8s.io/apimachinery/pkg/conversion/queryparams/convert_test.go
generated
vendored
41
vendor/k8s.io/apimachinery/pkg/conversion/queryparams/convert_test.go
generated
vendored
|
|
@ -66,12 +66,13 @@ func (obj *baz) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKin
|
|||
// childStructs tests some of the types we serialize to query params for log API calls
|
||||
// notably, the nested time struct
|
||||
type childStructs struct {
|
||||
Container string `json:"container,omitempty"`
|
||||
Follow bool `json:"follow,omitempty"`
|
||||
Previous bool `json:"previous,omitempty"`
|
||||
SinceSeconds *int64 `json:"sinceSeconds,omitempty"`
|
||||
SinceTime *metav1.Time `json:"sinceTime,omitempty"`
|
||||
EmptyTime *metav1.Time `json:"emptyTime"`
|
||||
Container string `json:"container,omitempty"`
|
||||
Follow bool `json:"follow,omitempty"`
|
||||
Previous bool `json:"previous,omitempty"`
|
||||
SinceSeconds *int64 `json:"sinceSeconds,omitempty"`
|
||||
SinceTime *metav1.Time `json:"sinceTime,omitempty"`
|
||||
EmptyTime *metav1.Time `json:"emptyTime"`
|
||||
NonPointerTime metav1.Time `json:"nonPointerTime"`
|
||||
}
|
||||
|
||||
func (obj *childStructs) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind }
|
||||
|
|
@ -177,24 +178,26 @@ func TestConvert(t *testing.T) {
|
|||
},
|
||||
{
|
||||
input: &childStructs{
|
||||
Container: "mycontainer",
|
||||
Follow: true,
|
||||
Previous: true,
|
||||
SinceSeconds: &sinceSeconds,
|
||||
SinceTime: &sinceTime, // test a custom marshaller
|
||||
EmptyTime: nil, // test a nil custom marshaller without omitempty
|
||||
Container: "mycontainer",
|
||||
Follow: true,
|
||||
Previous: true,
|
||||
SinceSeconds: &sinceSeconds,
|
||||
SinceTime: &sinceTime, // test a custom marshaller
|
||||
EmptyTime: nil, // test a nil custom marshaller without omitempty
|
||||
NonPointerTime: sinceTime,
|
||||
},
|
||||
expected: url.Values{"container": {"mycontainer"}, "follow": {"true"}, "previous": {"true"}, "sinceSeconds": {"123"}, "sinceTime": {"2000-01-01T12:34:56Z"}, "emptyTime": {""}},
|
||||
expected: url.Values{"container": {"mycontainer"}, "follow": {"true"}, "previous": {"true"}, "sinceSeconds": {"123"}, "sinceTime": {"2000-01-01T12:34:56Z"}, "emptyTime": {""}, "nonPointerTime": {"2000-01-01T12:34:56Z"}},
|
||||
},
|
||||
{
|
||||
input: &childStructs{
|
||||
Container: "mycontainer",
|
||||
Follow: true,
|
||||
Previous: true,
|
||||
SinceSeconds: &sinceSeconds,
|
||||
SinceTime: nil, // test a nil custom marshaller with omitempty
|
||||
Container: "mycontainer",
|
||||
Follow: true,
|
||||
Previous: true,
|
||||
SinceSeconds: &sinceSeconds,
|
||||
SinceTime: nil, // test a nil custom marshaller with omitempty
|
||||
NonPointerTime: sinceTime,
|
||||
},
|
||||
expected: url.Values{"container": {"mycontainer"}, "follow": {"true"}, "previous": {"true"}, "sinceSeconds": {"123"}, "emptyTime": {""}},
|
||||
expected: url.Values{"container": {"mycontainer"}, "follow": {"true"}, "previous": {"true"}, "sinceSeconds": {"123"}, "emptyTime": {""}, "nonPointerTime": {"2000-01-01T12:34:56Z"}},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
37
vendor/k8s.io/apimachinery/pkg/conversion/unstructured/BUILD
generated
vendored
37
vendor/k8s.io/apimachinery/pkg/conversion/unstructured/BUILD
generated
vendored
|
|
@ -1,37 +0,0 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"converter.go",
|
||||
"doc.go",
|
||||
],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/json:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/conversion/unstructured/testing:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
2
vendor/k8s.io/apimachinery/pkg/fields/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/fields/BUILD
generated
vendored
|
|
@ -12,6 +12,7 @@ go_test(
|
|||
"fields_test.go",
|
||||
"selector_test.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/fields",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ go_library(
|
|||
"requirements.go",
|
||||
"selector.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/fields",
|
||||
deps = ["//vendor/k8s.io/apimachinery/pkg/selection:go_default_library"],
|
||||
)
|
||||
|
||||
|
|
|
|||
3
vendor/k8s.io/apimachinery/pkg/labels/BUILD
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/labels/BUILD
generated
vendored
|
|
@ -12,6 +12,7 @@ go_test(
|
|||
"labels_test.go",
|
||||
"selector_test.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/labels",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/selection:go_default_library",
|
||||
|
|
@ -27,9 +28,9 @@ go_library(
|
|||
"selector.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/labels",
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/selection:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/validation:go_default_library",
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/labels/selector.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/labels/selector.go
generated
vendored
|
|
@ -550,7 +550,7 @@ func (p *Parser) lookahead(context ParserContext) (Token, string) {
|
|||
return tok, lit
|
||||
}
|
||||
|
||||
// consume returns current token and string. Increments the the position
|
||||
// consume returns current token and string. Increments the position
|
||||
func (p *Parser) consume(context ParserContext) (Token, string) {
|
||||
p.position++
|
||||
tok, lit := p.scannedItems[p.position-1].tok, p.scannedItems[p.position-1].literal
|
||||
|
|
|
|||
19
vendor/k8s.io/apimachinery/pkg/labels/zz_generated.deepcopy.go
generated
vendored
19
vendor/k8s.io/apimachinery/pkg/labels/zz_generated.deepcopy.go
generated
vendored
|
|
@ -1,7 +1,7 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
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.
|
||||
|
|
@ -20,23 +20,6 @@ limitations under the License.
|
|||
|
||||
package labels
|
||||
|
||||
import (
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// GetGeneratedDeepCopyFuncs returns the generated funcs, since we aren't registering them.
|
||||
//
|
||||
// Deprecated: deepcopy registration will go away when static deepcopy is fully implemented.
|
||||
func GetGeneratedDeepCopyFuncs() []conversion.GeneratedDeepCopyFunc {
|
||||
return []conversion.GeneratedDeepCopyFunc{
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*Requirement).DeepCopyInto(out.(*Requirement))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&Requirement{})},
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Requirement) DeepCopyInto(out *Requirement) {
|
||||
*out = *in
|
||||
|
|
|
|||
12
vendor/k8s.io/apimachinery/pkg/runtime/BUILD
generated
vendored
12
vendor/k8s.io/apimachinery/pkg/runtime/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["swagger_doc_generator_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
|
|
@ -18,6 +19,7 @@ go_library(
|
|||
"codec.go",
|
||||
"codec_check.go",
|
||||
"conversion.go",
|
||||
"converter.go",
|
||||
"doc.go",
|
||||
"embedded.go",
|
||||
"error.go",
|
||||
|
|
@ -33,12 +35,16 @@ go_library(
|
|||
"types_proto.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime",
|
||||
deps = [
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion/queryparams:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/json:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -46,20 +52,26 @@ go_test(
|
|||
name = "go_default_xtest",
|
||||
srcs = [
|
||||
"conversion_test.go",
|
||||
"converter_test.go",
|
||||
"embedded_test.go",
|
||||
"extension_test.go",
|
||||
"scheme_test.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime_test",
|
||||
deps = [
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||
"//vendor/github.com/stretchr/testify/require:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/testing:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/json:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
|||
16
vendor/k8s.io/apimachinery/pkg/runtime/codec.go
generated
vendored
16
vendor/k8s.io/apimachinery/pkg/runtime/codec.go
generated
vendored
|
|
@ -139,6 +139,7 @@ func NewParameterCodec(scheme *Scheme) ParameterCodec {
|
|||
typer: scheme,
|
||||
convertor: scheme,
|
||||
creator: scheme,
|
||||
defaulter: scheme,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -147,6 +148,7 @@ type parameterCodec struct {
|
|||
typer ObjectTyper
|
||||
convertor ObjectConvertor
|
||||
creator ObjectCreater
|
||||
defaulter ObjectDefaulter
|
||||
}
|
||||
|
||||
var _ ParameterCodec = ¶meterCodec{}
|
||||
|
|
@ -163,9 +165,17 @@ func (c *parameterCodec) DecodeParameters(parameters url.Values, from schema.Gro
|
|||
}
|
||||
for i := range targetGVKs {
|
||||
if targetGVKs[i].GroupVersion() == from {
|
||||
return c.convertor.Convert(¶meters, into, nil)
|
||||
if err := c.convertor.Convert(¶meters, into, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
// in the case where we going into the same object we're receiving, default on the outbound object
|
||||
if c.defaulter != nil {
|
||||
c.defaulter.Default(into)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
input, err := c.creator.New(from.WithKind(targetGVKs[0].Kind))
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -173,6 +183,10 @@ func (c *parameterCodec) DecodeParameters(parameters url.Values, from schema.Gro
|
|||
if err := c.convertor.Convert(¶meters, input, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
// if we have defaulter, default the input before converting to output
|
||||
if c.defaulter != nil {
|
||||
c.defaulter.Default(input)
|
||||
}
|
||||
return c.convertor.Convert(input, into, nil)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package unstructured
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
@ -27,18 +27,18 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
"k8s.io/apimachinery/pkg/util/diff"
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
// Converter is an interface for converting between interface{}
|
||||
// UnstructuredConverter is an interface for converting between interface{}
|
||||
// and map[string]interface representation.
|
||||
type Converter interface {
|
||||
type UnstructuredConverter interface {
|
||||
ToUnstructured(obj interface{}) (map[string]interface{}, error)
|
||||
FromUnstructured(u map[string]interface{}, obj interface{}) error
|
||||
}
|
||||
|
|
@ -77,7 +77,16 @@ var (
|
|||
float64Type = reflect.TypeOf(float64(0))
|
||||
boolType = reflect.TypeOf(bool(false))
|
||||
fieldCache = newFieldsCache()
|
||||
DefaultConverter = NewConverter(parseBool(os.Getenv("KUBE_PATCH_CONVERSION_DETECTOR")))
|
||||
|
||||
// DefaultUnstructuredConverter performs unstructured to Go typed object conversions.
|
||||
DefaultUnstructuredConverter = &unstructuredConverter{
|
||||
mismatchDetection: parseBool(os.Getenv("KUBE_PATCH_CONVERSION_DETECTOR")),
|
||||
comparison: conversion.EqualitiesOrDie(
|
||||
func(a, b time.Time) bool {
|
||||
return a.UTC() == b.UTC()
|
||||
},
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
func parseBool(key string) bool {
|
||||
|
|
@ -91,22 +100,30 @@ func parseBool(key string) bool {
|
|||
return value
|
||||
}
|
||||
|
||||
// ConverterImpl knows how to convert between interface{} and
|
||||
// unstructuredConverter knows how to convert between interface{} and
|
||||
// Unstructured in both ways.
|
||||
type converterImpl struct {
|
||||
type unstructuredConverter struct {
|
||||
// If true, we will be additionally running conversion via json
|
||||
// to ensure that the result is true.
|
||||
// This is supposed to be set only in tests.
|
||||
mismatchDetection bool
|
||||
// comparison is the default test logic used to compare
|
||||
comparison conversion.Equalities
|
||||
}
|
||||
|
||||
func NewConverter(mismatchDetection bool) Converter {
|
||||
return &converterImpl{
|
||||
mismatchDetection: mismatchDetection,
|
||||
// NewTestUnstructuredConverter creates an UnstructuredConverter that accepts JSON typed maps and translates them
|
||||
// to Go types via reflection. It performs mismatch detection automatically and is intended for use by external
|
||||
// test tools. Use DefaultUnstructuredConverter if you do not explicitly need mismatch detection.
|
||||
func NewTestUnstructuredConverter(comparison conversion.Equalities) UnstructuredConverter {
|
||||
return &unstructuredConverter{
|
||||
mismatchDetection: true,
|
||||
comparison: comparison,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *converterImpl) FromUnstructured(u map[string]interface{}, obj interface{}) error {
|
||||
// FromUnstructured converts an object from map[string]interface{} representation into a concrete type.
|
||||
// It uses encoding/json/Unmarshaler if object implements it or reflection if not.
|
||||
func (c *unstructuredConverter) FromUnstructured(u map[string]interface{}, obj interface{}) error {
|
||||
t := reflect.TypeOf(obj)
|
||||
value := reflect.ValueOf(obj)
|
||||
if t.Kind() != reflect.Ptr || value.IsNil() {
|
||||
|
|
@ -119,8 +136,8 @@ func (c *converterImpl) FromUnstructured(u map[string]interface{}, obj interface
|
|||
if (err != nil) != (newErr != nil) {
|
||||
glog.Fatalf("FromUnstructured unexpected error for %v: error: %v", u, err)
|
||||
}
|
||||
if err == nil && !apiequality.Semantic.DeepEqual(obj, newObj) {
|
||||
glog.Fatalf("FromUnstructured mismatch for %#v, diff: %v", obj, diff.ObjectReflectDiff(obj, newObj))
|
||||
if err == nil && !c.comparison.DeepEqual(obj, newObj) {
|
||||
glog.Fatalf("FromUnstructured mismatch\nobj1: %#v\nobj2: %#v", obj, newObj)
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
|
@ -388,28 +405,66 @@ func interfaceFromUnstructured(sv, dv reflect.Value) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *converterImpl) ToUnstructured(obj interface{}) (map[string]interface{}, error) {
|
||||
t := reflect.TypeOf(obj)
|
||||
value := reflect.ValueOf(obj)
|
||||
if t.Kind() != reflect.Ptr || value.IsNil() {
|
||||
return nil, fmt.Errorf("ToUnstructured requires a non-nil pointer to an object, got %v", t)
|
||||
}
|
||||
u := &map[string]interface{}{}
|
||||
err := toUnstructured(value.Elem(), reflect.ValueOf(u).Elem())
|
||||
if c.mismatchDetection {
|
||||
newUnstr := &map[string]interface{}{}
|
||||
newErr := toUnstructuredViaJSON(obj, newUnstr)
|
||||
if (err != nil) != (newErr != nil) {
|
||||
glog.Fatalf("ToUnstructured unexpected error for %v: error: %v", obj, err)
|
||||
// ToUnstructured converts an object into map[string]interface{} representation.
|
||||
// It uses encoding/json/Marshaler if object implements it or reflection if not.
|
||||
func (c *unstructuredConverter) ToUnstructured(obj interface{}) (map[string]interface{}, error) {
|
||||
var u map[string]interface{}
|
||||
var err error
|
||||
if unstr, ok := obj.(Unstructured); ok {
|
||||
// UnstructuredContent() mutates the object so we need to make a copy first
|
||||
u = unstr.DeepCopyObject().(Unstructured).UnstructuredContent()
|
||||
} else {
|
||||
t := reflect.TypeOf(obj)
|
||||
value := reflect.ValueOf(obj)
|
||||
if t.Kind() != reflect.Ptr || value.IsNil() {
|
||||
return nil, fmt.Errorf("ToUnstructured requires a non-nil pointer to an object, got %v", t)
|
||||
}
|
||||
if err == nil && !apiequality.Semantic.DeepEqual(u, newUnstr) {
|
||||
glog.Fatalf("ToUnstructured mismatch for %#v, diff: %v", u, diff.ObjectReflectDiff(u, newUnstr))
|
||||
u = map[string]interface{}{}
|
||||
err = toUnstructured(value.Elem(), reflect.ValueOf(&u).Elem())
|
||||
}
|
||||
if c.mismatchDetection {
|
||||
newUnstr := map[string]interface{}{}
|
||||
newErr := toUnstructuredViaJSON(obj, &newUnstr)
|
||||
if (err != nil) != (newErr != nil) {
|
||||
glog.Fatalf("ToUnstructured unexpected error for %v: error: %v; newErr: %v", obj, err, newErr)
|
||||
}
|
||||
if err == nil && !c.comparison.DeepEqual(u, newUnstr) {
|
||||
glog.Fatalf("ToUnstructured mismatch\nobj1: %#v\nobj2: %#v", u, newUnstr)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return *u, nil
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// DeepCopyJSON deep copies the passed value, assuming it is a valid JSON representation i.e. only contains
|
||||
// types produced by json.Unmarshal().
|
||||
func DeepCopyJSON(x map[string]interface{}) map[string]interface{} {
|
||||
return DeepCopyJSONValue(x).(map[string]interface{})
|
||||
}
|
||||
|
||||
// DeepCopyJSONValue deep copies the passed value, assuming it is a valid JSON representation i.e. only contains
|
||||
// types produced by json.Unmarshal().
|
||||
func DeepCopyJSONValue(x interface{}) interface{} {
|
||||
switch x := x.(type) {
|
||||
case map[string]interface{}:
|
||||
clone := make(map[string]interface{}, len(x))
|
||||
for k, v := range x {
|
||||
clone[k] = DeepCopyJSONValue(v)
|
||||
}
|
||||
return clone
|
||||
case []interface{}:
|
||||
clone := make([]interface{}, len(x))
|
||||
for i, v := range x {
|
||||
clone[i] = DeepCopyJSONValue(v)
|
||||
}
|
||||
return clone
|
||||
case string, int64, bool, float64, nil, encodingjson.Number:
|
||||
return x
|
||||
default:
|
||||
panic(fmt.Errorf("cannot deep copy %T", x))
|
||||
}
|
||||
}
|
||||
|
||||
func toUnstructuredViaJSON(obj interface{}, u *map[string]interface{}) error {
|
||||
597
vendor/k8s.io/apimachinery/pkg/runtime/converter_test.go
generated
vendored
Normal file
597
vendor/k8s.io/apimachinery/pkg/runtime/converter_test.go
generated
vendored
Normal file
|
|
@ -0,0 +1,597 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
// These tests are in a separate package to break cyclic dependency in tests.
|
||||
// Unstructured type depends on unstructured converter package but we want to test how the converter handles
|
||||
// the Unstructured type so we need to import both.
|
||||
|
||||
package runtime_test
|
||||
|
||||
import (
|
||||
encodingjson "encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/diff"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var simpleEquality = conversion.EqualitiesOrDie(
|
||||
func(a, b time.Time) bool {
|
||||
return a.UTC() == b.UTC()
|
||||
},
|
||||
)
|
||||
|
||||
// Definte a number of test types.
|
||||
type A struct {
|
||||
A int `json:"aa,omitempty"`
|
||||
B string `json:"ab,omitempty"`
|
||||
C bool `json:"ac,omitempty"`
|
||||
}
|
||||
|
||||
type B struct {
|
||||
A A `json:"ba"`
|
||||
B string `json:"bb"`
|
||||
C map[string]string `json:"bc"`
|
||||
D []string `json:"bd"`
|
||||
}
|
||||
|
||||
type C struct {
|
||||
A []A `json:"ca"`
|
||||
B `json:",inline"`
|
||||
C string `json:"cc"`
|
||||
D *int64 `json:"cd"`
|
||||
E map[string]int `json:"ce"`
|
||||
F []bool `json:"cf"`
|
||||
G []int `json:"cg"`
|
||||
H float32 `json:"ch"`
|
||||
I []interface{} `json:"ci"`
|
||||
}
|
||||
|
||||
type D struct {
|
||||
A []interface{} `json:"da"`
|
||||
}
|
||||
|
||||
type E struct {
|
||||
A interface{} `json:"ea"`
|
||||
}
|
||||
|
||||
type F struct {
|
||||
A string `json:"fa"`
|
||||
B map[string]string `json:"fb"`
|
||||
C []A `json:"fc"`
|
||||
D int `json:"fd"`
|
||||
E float32 `json:"fe"`
|
||||
F []string `json:"ff"`
|
||||
G []int `json:"fg"`
|
||||
H []bool `json:"fh"`
|
||||
I []float32 `json:"fi"`
|
||||
}
|
||||
|
||||
type G struct {
|
||||
CustomValue1 CustomValue `json:"customValue1"`
|
||||
CustomValue2 *CustomValue `json:"customValue2"`
|
||||
CustomPointer1 CustomPointer `json:"customPointer1"`
|
||||
CustomPointer2 *CustomPointer `json:"customPointer2"`
|
||||
}
|
||||
|
||||
type CustomValue struct {
|
||||
data []byte
|
||||
}
|
||||
|
||||
// MarshalJSON has a value receiver on this type.
|
||||
func (c CustomValue) MarshalJSON() ([]byte, error) {
|
||||
return c.data, nil
|
||||
}
|
||||
|
||||
type CustomPointer struct {
|
||||
data []byte
|
||||
}
|
||||
|
||||
// MarshalJSON has a pointer receiver on this type.
|
||||
func (c *CustomPointer) MarshalJSON() ([]byte, error) {
|
||||
return c.data, nil
|
||||
}
|
||||
|
||||
func doRoundTrip(t *testing.T, item interface{}) {
|
||||
data, err := json.Marshal(item)
|
||||
if err != nil {
|
||||
t.Errorf("Error when marshaling object: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
unstr := make(map[string]interface{})
|
||||
err = json.Unmarshal(data, &unstr)
|
||||
if err != nil {
|
||||
t.Errorf("Error when unmarshaling to unstructured: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
data, err = json.Marshal(unstr)
|
||||
if err != nil {
|
||||
t.Errorf("Error when marshaling unstructured: %v", err)
|
||||
return
|
||||
}
|
||||
unmarshalledObj := reflect.New(reflect.TypeOf(item).Elem()).Interface()
|
||||
err = json.Unmarshal(data, unmarshalledObj)
|
||||
if err != nil {
|
||||
t.Errorf("Error when unmarshaling to object: %v", err)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(item, unmarshalledObj) {
|
||||
t.Errorf("Object changed during JSON operations, diff: %v", diff.ObjectReflectDiff(item, unmarshalledObj))
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: should be using mismatch detection but fails due to another error
|
||||
newUnstr, err := runtime.DefaultUnstructuredConverter.ToUnstructured(item)
|
||||
if err != nil {
|
||||
t.Errorf("ToUnstructured failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
newObj := reflect.New(reflect.TypeOf(item).Elem()).Interface()
|
||||
err = runtime.NewTestUnstructuredConverter(simpleEquality).FromUnstructured(newUnstr, newObj)
|
||||
if err != nil {
|
||||
t.Errorf("FromUnstructured failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(item, newObj) {
|
||||
t.Errorf("Object changed, diff: %v", diff.ObjectReflectDiff(item, newObj))
|
||||
}
|
||||
}
|
||||
|
||||
func TestRoundTrip(t *testing.T) {
|
||||
intVal := int64(42)
|
||||
testCases := []struct {
|
||||
obj interface{}
|
||||
}{
|
||||
{
|
||||
obj: &unstructured.UnstructuredList{
|
||||
Object: map[string]interface{}{
|
||||
"kind": "List",
|
||||
},
|
||||
// Not testing a list with nil Items because items is a non-optional field and hence
|
||||
// is always marshaled into an empty array which is not equal to nil when unmarshalled and will fail.
|
||||
// That is expected.
|
||||
Items: []unstructured.Unstructured{},
|
||||
},
|
||||
},
|
||||
{
|
||||
obj: &unstructured.UnstructuredList{
|
||||
Object: map[string]interface{}{
|
||||
"kind": "List",
|
||||
},
|
||||
Items: []unstructured.Unstructured{
|
||||
{
|
||||
Object: map[string]interface{}{
|
||||
"kind": "Pod",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
obj: &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"kind": "Pod",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
obj: &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "Foo",
|
||||
"metadata": map[string]interface{}{
|
||||
"name": "foo1",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
// This (among others) tests nil map, slice and pointer.
|
||||
obj: &C{
|
||||
C: "ccc",
|
||||
},
|
||||
},
|
||||
{
|
||||
// This (among others) tests empty map and slice.
|
||||
obj: &C{
|
||||
A: []A{},
|
||||
C: "ccc",
|
||||
E: map[string]int{},
|
||||
I: []interface{}{},
|
||||
},
|
||||
},
|
||||
{
|
||||
obj: &C{
|
||||
A: []A{
|
||||
{
|
||||
A: 1,
|
||||
B: "11",
|
||||
C: true,
|
||||
},
|
||||
{
|
||||
A: 2,
|
||||
B: "22",
|
||||
C: false,
|
||||
},
|
||||
},
|
||||
B: B{
|
||||
A: A{
|
||||
A: 3,
|
||||
B: "33",
|
||||
},
|
||||
B: "bbb",
|
||||
C: map[string]string{
|
||||
"k1": "v1",
|
||||
"k2": "v2",
|
||||
},
|
||||
D: []string{"s1", "s2"},
|
||||
},
|
||||
C: "ccc",
|
||||
D: &intVal,
|
||||
E: map[string]int{
|
||||
"k1": 1,
|
||||
"k2": 2,
|
||||
},
|
||||
F: []bool{true, false, false},
|
||||
G: []int{1, 2, 5},
|
||||
H: 3.3,
|
||||
I: []interface{}{nil, nil, nil},
|
||||
},
|
||||
},
|
||||
{
|
||||
// Test slice of interface{} with empty slices.
|
||||
obj: &D{
|
||||
A: []interface{}{[]interface{}{}, []interface{}{}},
|
||||
},
|
||||
},
|
||||
{
|
||||
// Test slice of interface{} with different values.
|
||||
obj: &D{
|
||||
A: []interface{}{3.0, "3.0", nil},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i := range testCases {
|
||||
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
||||
doRoundTrip(t, testCases[i].obj)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Verifies that:
|
||||
// 1) serialized json -> object
|
||||
// 2) serialized json -> map[string]interface{} -> object
|
||||
// produces the same object.
|
||||
func doUnrecognized(t *testing.T, jsonData string, item interface{}, expectedErr error) {
|
||||
unmarshalledObj := reflect.New(reflect.TypeOf(item).Elem()).Interface()
|
||||
err := json.Unmarshal([]byte(jsonData), unmarshalledObj)
|
||||
if (err != nil) != (expectedErr != nil) {
|
||||
t.Errorf("Unexpected error when unmarshaling to object: %v, expected: %v", err, expectedErr)
|
||||
return
|
||||
}
|
||||
|
||||
unstr := make(map[string]interface{})
|
||||
err = json.Unmarshal([]byte(jsonData), &unstr)
|
||||
if err != nil {
|
||||
t.Errorf("Error when unmarshaling to unstructured: %v", err)
|
||||
return
|
||||
}
|
||||
newObj := reflect.New(reflect.TypeOf(item).Elem()).Interface()
|
||||
err = runtime.NewTestUnstructuredConverter(simpleEquality).FromUnstructured(unstr, newObj)
|
||||
if (err != nil) != (expectedErr != nil) {
|
||||
t.Errorf("Unexpected error in FromUnstructured: %v, expected: %v", err, expectedErr)
|
||||
}
|
||||
|
||||
if expectedErr == nil && !reflect.DeepEqual(unmarshalledObj, newObj) {
|
||||
t.Errorf("Object changed, diff: %v", diff.ObjectReflectDiff(unmarshalledObj, newObj))
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnrecognized(t *testing.T) {
|
||||
testCases := []struct {
|
||||
data string
|
||||
obj interface{}
|
||||
err error
|
||||
}{
|
||||
{
|
||||
data: "{\"da\":[3.0,\"3.0\",null]}",
|
||||
obj: &D{},
|
||||
},
|
||||
{
|
||||
data: "{\"ea\":[3.0,\"3.0\",null]}",
|
||||
obj: &E{},
|
||||
},
|
||||
{
|
||||
data: "{\"ea\":[null,null,null]}",
|
||||
obj: &E{},
|
||||
},
|
||||
{
|
||||
data: "{\"ea\":[[],[null]]}",
|
||||
obj: &E{},
|
||||
},
|
||||
{
|
||||
data: "{\"ea\":{\"a\":[],\"b\":null}}",
|
||||
obj: &E{},
|
||||
},
|
||||
{
|
||||
data: "{\"fa\":\"fa\",\"fb\":{\"a\":\"a\"}}",
|
||||
obj: &F{},
|
||||
},
|
||||
{
|
||||
data: "{\"fa\":\"fa\",\"fb\":{\"a\":null}}",
|
||||
obj: &F{},
|
||||
},
|
||||
{
|
||||
data: "{\"fc\":[null]}",
|
||||
obj: &F{},
|
||||
},
|
||||
{
|
||||
data: "{\"fc\":[{\"aa\":123,\"ab\":\"bbb\"}]}",
|
||||
obj: &F{},
|
||||
},
|
||||
{
|
||||
// Only unknown fields
|
||||
data: "{\"fx\":[{\"aa\":123,\"ab\":\"bbb\"}],\"fz\":123}",
|
||||
obj: &F{},
|
||||
},
|
||||
{
|
||||
data: "{\"fc\":[{\"aa\":\"aaa\",\"ab\":\"bbb\"}]}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal string into Go value of type int"),
|
||||
},
|
||||
{
|
||||
data: "{\"fd\":123,\"fe\":3.5}",
|
||||
obj: &F{},
|
||||
},
|
||||
{
|
||||
data: "{\"ff\":[\"abc\"],\"fg\":[123],\"fh\":[true,false]}",
|
||||
obj: &F{},
|
||||
},
|
||||
{
|
||||
// Invalid string data
|
||||
data: "{\"fa\":123}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal number into Go value of type string"),
|
||||
},
|
||||
{
|
||||
// Invalid string data
|
||||
data: "{\"fa\":13.5}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal number into Go value of type string"),
|
||||
},
|
||||
{
|
||||
// Invalid string data
|
||||
data: "{\"fa\":true}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal bool into Go value of type string"),
|
||||
},
|
||||
{
|
||||
// Invalid []string data
|
||||
data: "{\"ff\":123}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal number into Go value of type []string"),
|
||||
},
|
||||
{
|
||||
// Invalid []string data
|
||||
data: "{\"ff\":3.5}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal number into Go value of type []string"),
|
||||
},
|
||||
{
|
||||
// Invalid []string data
|
||||
data: "{\"ff\":[123,345]}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal number into Go value of type string"),
|
||||
},
|
||||
{
|
||||
// Invalid []int data
|
||||
data: "{\"fg\":123}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal number into Go value of type []int"),
|
||||
},
|
||||
{
|
||||
// Invalid []int data
|
||||
data: "{\"fg\":\"abc\"}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal string into Go value of type []int"),
|
||||
},
|
||||
{
|
||||
// Invalid []int data
|
||||
data: "{\"fg\":[\"abc\"]}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal string into Go value of type int"),
|
||||
},
|
||||
{
|
||||
// Invalid []int data
|
||||
data: "{\"fg\":[3.5]}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal number 3.5 into Go value of type int"),
|
||||
},
|
||||
{
|
||||
// Invalid []int data
|
||||
data: "{\"fg\":[true,false]}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal number 3.5 into Go value of type int"),
|
||||
},
|
||||
{
|
||||
// Invalid []bool data
|
||||
data: "{\"fh\":123}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal number into Go value of type []bool"),
|
||||
},
|
||||
{
|
||||
// Invalid []bool data
|
||||
data: "{\"fh\":\"abc\"}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal string into Go value of type []bool"),
|
||||
},
|
||||
{
|
||||
// Invalid []bool data
|
||||
data: "{\"fh\":[\"abc\"]}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal string into Go value of type bool"),
|
||||
},
|
||||
{
|
||||
// Invalid []bool data
|
||||
data: "{\"fh\":[3.5]}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal number into Go value of type bool"),
|
||||
},
|
||||
{
|
||||
// Invalid []bool data
|
||||
data: "{\"fh\":[123]}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal number into Go value of type bool"),
|
||||
},
|
||||
{
|
||||
// Invalid []float data
|
||||
data: "{\"fi\":123}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal number into Go value of type []float32"),
|
||||
},
|
||||
{
|
||||
// Invalid []float data
|
||||
data: "{\"fi\":\"abc\"}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal string into Go value of type []float32"),
|
||||
},
|
||||
{
|
||||
// Invalid []float data
|
||||
data: "{\"fi\":[\"abc\"]}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal string into Go value of type float32"),
|
||||
},
|
||||
{
|
||||
// Invalid []float data
|
||||
data: "{\"fi\":[true]}",
|
||||
obj: &F{},
|
||||
err: fmt.Errorf("json: cannot unmarshal bool into Go value of type float32"),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.data, func(t *testing.T) {
|
||||
doUnrecognized(t, tc.data, tc.obj, tc.err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeepCopyJSON(t *testing.T) {
|
||||
src := map[string]interface{}{
|
||||
"a": nil,
|
||||
"b": int64(123),
|
||||
"c": map[string]interface{}{
|
||||
"a": "b",
|
||||
},
|
||||
"d": []interface{}{
|
||||
int64(1), int64(2),
|
||||
},
|
||||
"e": "estr",
|
||||
"f": true,
|
||||
"g": encodingjson.Number("123"),
|
||||
}
|
||||
deepCopy := runtime.DeepCopyJSON(src)
|
||||
assert.Equal(t, src, deepCopy)
|
||||
}
|
||||
|
||||
func TestFloatIntConversion(t *testing.T) {
|
||||
unstr := map[string]interface{}{"fd": float64(3)}
|
||||
|
||||
var obj F
|
||||
if err := runtime.NewTestUnstructuredConverter(simpleEquality).FromUnstructured(unstr, &obj); err != nil {
|
||||
t.Errorf("Unexpected error in FromUnstructured: %v", err)
|
||||
}
|
||||
|
||||
data, err := json.Marshal(unstr)
|
||||
if err != nil {
|
||||
t.Fatalf("Error when marshaling unstructured: %v", err)
|
||||
}
|
||||
var unmarshalled F
|
||||
if err := json.Unmarshal(data, &unmarshalled); err != nil {
|
||||
t.Fatalf("Error when unmarshaling to object: %v", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(obj, unmarshalled) {
|
||||
t.Errorf("Incorrect conversion, diff: %v", diff.ObjectReflectDiff(obj, unmarshalled))
|
||||
}
|
||||
}
|
||||
|
||||
func TestCustomToUnstructured(t *testing.T) {
|
||||
testcases := []struct {
|
||||
Data string
|
||||
Expected interface{}
|
||||
}{
|
||||
{Data: `null`, Expected: nil},
|
||||
{Data: `true`, Expected: true},
|
||||
{Data: `false`, Expected: false},
|
||||
{Data: `[]`, Expected: []interface{}{}},
|
||||
{Data: `[1]`, Expected: []interface{}{int64(1)}},
|
||||
{Data: `{}`, Expected: map[string]interface{}{}},
|
||||
{Data: `{"a":1}`, Expected: map[string]interface{}{"a": int64(1)}},
|
||||
{Data: `0`, Expected: int64(0)},
|
||||
{Data: `0.0`, Expected: float64(0)},
|
||||
}
|
||||
|
||||
for _, tc := range testcases {
|
||||
tc := tc
|
||||
t.Run(tc.Data, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
result, err := runtime.NewTestUnstructuredConverter(simpleEquality).ToUnstructured(&G{
|
||||
CustomValue1: CustomValue{data: []byte(tc.Data)},
|
||||
CustomValue2: &CustomValue{data: []byte(tc.Data)},
|
||||
CustomPointer1: CustomPointer{data: []byte(tc.Data)},
|
||||
CustomPointer2: &CustomPointer{data: []byte(tc.Data)},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
for field, fieldResult := range result {
|
||||
assert.Equal(t, tc.Expected, fieldResult, field)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCustomToUnstructuredTopLevel(t *testing.T) {
|
||||
// Only objects are supported at the top level
|
||||
topLevelCases := []interface{}{
|
||||
&CustomValue{data: []byte(`{"a":1}`)},
|
||||
&CustomPointer{data: []byte(`{"a":1}`)},
|
||||
}
|
||||
expected := map[string]interface{}{"a": int64(1)}
|
||||
for i, obj := range topLevelCases {
|
||||
obj := obj
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
result, err := runtime.NewTestUnstructuredConverter(simpleEquality).ToUnstructured(obj)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
4
vendor/k8s.io/apimachinery/pkg/runtime/error.go
generated
vendored
4
vendor/k8s.io/apimachinery/pkg/runtime/error.go
generated
vendored
|
|
@ -94,8 +94,6 @@ type missingVersionErr struct {
|
|||
data string
|
||||
}
|
||||
|
||||
// IsMissingVersion returns true if the error indicates that the provided object
|
||||
// is missing a 'Version' field.
|
||||
func NewMissingVersionErr(data string) error {
|
||||
return &missingVersionErr{data}
|
||||
}
|
||||
|
|
@ -104,6 +102,8 @@ func (k *missingVersionErr) Error() string {
|
|||
return fmt.Sprintf("Object 'apiVersion' is missing in '%s'", k.data)
|
||||
}
|
||||
|
||||
// IsMissingVersion returns true if the error indicates that the provided object
|
||||
// is missing a 'Version' field.
|
||||
func IsMissingVersion(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/runtime/generated.pb.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/runtime/generated.pb.go
generated
vendored
|
|
@ -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.
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/runtime/generated.proto
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/runtime/generated.proto
generated
vendored
|
|
@ -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.
|
||||
|
|
|
|||
13
vendor/k8s.io/apimachinery/pkg/runtime/interfaces.go
generated
vendored
13
vendor/k8s.io/apimachinery/pkg/runtime/interfaces.go
generated
vendored
|
|
@ -203,13 +203,6 @@ type ObjectCreater interface {
|
|||
New(kind schema.GroupVersionKind) (out Object, err error)
|
||||
}
|
||||
|
||||
// ObjectCopier duplicates an object.
|
||||
type ObjectCopier interface {
|
||||
// Copy returns an exact copy of the provided Object, or an error if the
|
||||
// copy could not be completed.
|
||||
Copy(Object) (Object, error)
|
||||
}
|
||||
|
||||
// ResourceVersioner provides methods for setting and retrieving
|
||||
// the resource version from an API object.
|
||||
type ResourceVersioner interface {
|
||||
|
|
@ -240,13 +233,13 @@ type Object interface {
|
|||
// Unstructured objects store values as map[string]interface{}, with only values that can be serialized
|
||||
// to JSON allowed.
|
||||
type Unstructured interface {
|
||||
// IsUnstructuredObject is a marker interface to allow objects that can be serialized but not introspected
|
||||
// to bypass conversion.
|
||||
IsUnstructuredObject()
|
||||
Object
|
||||
// UnstructuredContent returns a non-nil, mutable map of the contents of this object. Values may be
|
||||
// []interface{}, map[string]interface{}, or any primitive type. Contents are typically serialized to
|
||||
// and from JSON.
|
||||
UnstructuredContent() map[string]interface{}
|
||||
// SetUnstructuredContent updates the object content to match the provided map.
|
||||
SetUnstructuredContent(map[string]interface{})
|
||||
// IsList returns true if this type is a list or matches the list convention - has an array called "items".
|
||||
IsList() bool
|
||||
// EachListItem should pass a single item out of the list as an Object to the provided function. Any
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/runtime/schema/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/runtime/schema/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["group_version_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/schema",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
|
|
@ -19,6 +20,7 @@ go_library(
|
|||
"group_version.go",
|
||||
"interfaces.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/schema",
|
||||
deps = ["//vendor/github.com/gogo/protobuf/proto:go_default_library"],
|
||||
)
|
||||
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.pb.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.pb.go
generated
vendored
|
|
@ -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.
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.proto
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.proto
generated
vendored
|
|
@ -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.
|
||||
|
|
|
|||
206
vendor/k8s.io/apimachinery/pkg/runtime/scheme.go
generated
vendored
206
vendor/k8s.io/apimachinery/pkg/runtime/scheme.go
generated
vendored
|
|
@ -68,10 +68,6 @@ type Scheme struct {
|
|||
// converter stores all registered conversion functions. It also has
|
||||
// default coverting behavior.
|
||||
converter *conversion.Converter
|
||||
|
||||
// cloner stores all registered copy functions. It also has default
|
||||
// deep copy behavior.
|
||||
cloner *conversion.Cloner
|
||||
}
|
||||
|
||||
// Function to convert a field selector to internal representation.
|
||||
|
|
@ -80,11 +76,10 @@ type FieldLabelConversionFunc func(label, value string) (internalLabel, internal
|
|||
// NewScheme creates a new Scheme. This scheme is pluggable by default.
|
||||
func NewScheme() *Scheme {
|
||||
s := &Scheme{
|
||||
gvkToType: map[schema.GroupVersionKind]reflect.Type{},
|
||||
typeToGVK: map[reflect.Type][]schema.GroupVersionKind{},
|
||||
unversionedTypes: map[reflect.Type]schema.GroupVersionKind{},
|
||||
unversionedKinds: map[string]reflect.Type{},
|
||||
cloner: conversion.NewCloner(),
|
||||
gvkToType: map[schema.GroupVersionKind]reflect.Type{},
|
||||
typeToGVK: map[reflect.Type][]schema.GroupVersionKind{},
|
||||
unversionedTypes: map[reflect.Type]schema.GroupVersionKind{},
|
||||
unversionedKinds: map[string]reflect.Type{},
|
||||
fieldLabelConversionFuncs: map[string]map[string]FieldLabelConversionFunc{},
|
||||
defaulterFuncs: map[reflect.Type]func(interface{}){},
|
||||
}
|
||||
|
|
@ -222,19 +217,22 @@ func (s *Scheme) AllKnownTypes() map[schema.GroupVersionKind]reflect.Type {
|
|||
return s.gvkToType
|
||||
}
|
||||
|
||||
// ObjectKind returns the group,version,kind of the go object and true if this object
|
||||
// is considered unversioned, or an error if it's not a pointer or is unregistered.
|
||||
func (s *Scheme) ObjectKind(obj Object) (schema.GroupVersionKind, bool, error) {
|
||||
gvks, unversionedType, err := s.ObjectKinds(obj)
|
||||
if err != nil {
|
||||
return schema.GroupVersionKind{}, false, err
|
||||
}
|
||||
return gvks[0], unversionedType, nil
|
||||
}
|
||||
|
||||
// ObjectKinds returns all possible group,version,kind of the go object, true if the
|
||||
// object is considered unversioned, or an error if it's not a pointer or is unregistered.
|
||||
func (s *Scheme) ObjectKinds(obj Object) ([]schema.GroupVersionKind, bool, error) {
|
||||
// Unstructured objects are always considered to have their declared GVK
|
||||
if _, ok := obj.(Unstructured); ok {
|
||||
// we require that the GVK be populated in order to recognize the object
|
||||
gvk := obj.GetObjectKind().GroupVersionKind()
|
||||
if len(gvk.Kind) == 0 {
|
||||
return nil, false, NewMissingKindErr("unstructured object has no kind")
|
||||
}
|
||||
if len(gvk.Version) == 0 {
|
||||
return nil, false, NewMissingVersionErr("unstructured object has no version")
|
||||
}
|
||||
return []schema.GroupVersionKind{gvk}, false, nil
|
||||
}
|
||||
|
||||
v, err := conversion.EnforcePtr(obj)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
|
|
@ -343,7 +341,7 @@ func (s *Scheme) AddConversionFuncs(conversionFuncs ...interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Similar to AddConversionFuncs, but registers conversion functions that were
|
||||
// AddGeneratedConversionFuncs registers conversion functions that were
|
||||
// automatically generated.
|
||||
func (s *Scheme) AddGeneratedConversionFuncs(conversionFuncs ...interface{}) error {
|
||||
for _, f := range conversionFuncs {
|
||||
|
|
@ -354,29 +352,6 @@ func (s *Scheme) AddGeneratedConversionFuncs(conversionFuncs ...interface{}) err
|
|||
return nil
|
||||
}
|
||||
|
||||
// AddDeepCopyFuncs adds a function to the list of deep-copy functions.
|
||||
// For the expected format of deep-copy function, see the comment for
|
||||
// Copier.RegisterDeepCopyFunction.
|
||||
func (s *Scheme) AddDeepCopyFuncs(deepCopyFuncs ...interface{}) error {
|
||||
for _, f := range deepCopyFuncs {
|
||||
if err := s.cloner.RegisterDeepCopyFunc(f); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Similar to AddDeepCopyFuncs, but registers deep-copy functions that were
|
||||
// automatically generated.
|
||||
func (s *Scheme) AddGeneratedDeepCopyFuncs(deepCopyFuncs ...conversion.GeneratedDeepCopyFunc) error {
|
||||
for _, fn := range deepCopyFuncs {
|
||||
if err := s.cloner.RegisterGeneratedDeepCopyFunc(fn); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddFieldLabelConversionFunc adds a conversion function to convert field selectors
|
||||
// of the given kind from the given version to internal version representation.
|
||||
func (s *Scheme) AddFieldLabelConversionFunc(version, kind string, conversionFunc FieldLabelConversionFunc) error {
|
||||
|
|
@ -420,28 +395,72 @@ func (s *Scheme) Default(src Object) {
|
|||
}
|
||||
}
|
||||
|
||||
// Copy does a deep copy of an API object.
|
||||
func (s *Scheme) Copy(src Object) (Object, error) {
|
||||
dst, err := s.DeepCopy(src)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dst.(Object), nil
|
||||
}
|
||||
|
||||
// Performs a deep copy of the given object.
|
||||
func (s *Scheme) DeepCopy(src interface{}) (interface{}, error) {
|
||||
return s.cloner.DeepCopy(src)
|
||||
}
|
||||
|
||||
// Convert will attempt to convert in into out. Both must be pointers. For easy
|
||||
// testing of conversion functions. Returns an error if the conversion isn't
|
||||
// possible. You can call this with types that haven't been registered (for example,
|
||||
// a to test conversion of types that are nested within registered types). The
|
||||
// context interface is passed to the convertor.
|
||||
// TODO: identify whether context should be hidden, or behind a formal context/scope
|
||||
// interface
|
||||
// context interface is passed to the convertor. Convert also supports Unstructured
|
||||
// types and will convert them intelligently.
|
||||
func (s *Scheme) Convert(in, out interface{}, context interface{}) error {
|
||||
unstructuredIn, okIn := in.(Unstructured)
|
||||
unstructuredOut, okOut := out.(Unstructured)
|
||||
switch {
|
||||
case okIn && okOut:
|
||||
// converting unstructured input to an unstructured output is a straight copy - unstructured
|
||||
// is a "smart holder" and the contents are passed by reference between the two objects
|
||||
unstructuredOut.SetUnstructuredContent(unstructuredIn.UnstructuredContent())
|
||||
return nil
|
||||
|
||||
case okOut:
|
||||
// if the output is an unstructured object, use the standard Go type to unstructured
|
||||
// conversion. The object must not be internal.
|
||||
obj, ok := in.(Object)
|
||||
if !ok {
|
||||
return fmt.Errorf("unable to convert object type %T to Unstructured, must be a runtime.Object", in)
|
||||
}
|
||||
gvks, unversioned, err := s.ObjectKinds(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gvk := gvks[0]
|
||||
|
||||
// if no conversion is necessary, convert immediately
|
||||
if unversioned || gvk.Version != APIVersionInternal {
|
||||
content, err := DefaultUnstructuredConverter.ToUnstructured(in)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
unstructuredOut.SetUnstructuredContent(content)
|
||||
return nil
|
||||
}
|
||||
|
||||
// attempt to convert the object to an external version first.
|
||||
target, ok := context.(GroupVersioner)
|
||||
if !ok {
|
||||
return fmt.Errorf("unable to convert the internal object type %T to Unstructured without providing a preferred version to convert to", in)
|
||||
}
|
||||
// Convert is implicitly unsafe, so we don't need to perform a safe conversion
|
||||
versioned, err := s.UnsafeConvertToVersion(obj, target)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
content, err := DefaultUnstructuredConverter.ToUnstructured(versioned)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
unstructuredOut.SetUnstructuredContent(content)
|
||||
return nil
|
||||
|
||||
case okIn:
|
||||
// converting an unstructured object to any type is modeled by first converting
|
||||
// the input to a versioned type, then running standard conversions
|
||||
typed, err := s.unstructuredToTyped(unstructuredIn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
in = typed
|
||||
}
|
||||
|
||||
flags, meta := s.generateConvertMeta(in)
|
||||
meta.Context = context
|
||||
if flags == 0 {
|
||||
|
|
@ -450,8 +469,8 @@ func (s *Scheme) Convert(in, out interface{}, context interface{}) error {
|
|||
return s.converter.Convert(in, out, flags, meta)
|
||||
}
|
||||
|
||||
// Converts the given field label and value for an kind field selector from
|
||||
// versioned representation to an unversioned one.
|
||||
// ConvertFieldLabel alters the given field label and value for an kind field selector from
|
||||
// versioned representation to an unversioned one or returns an error.
|
||||
func (s *Scheme) ConvertFieldLabel(version, kind, label, value string) (string, string, error) {
|
||||
if s.fieldLabelConversionFuncs[version] == nil {
|
||||
return DefaultMetaV1FieldSelectorConversion(label, value)
|
||||
|
|
@ -481,15 +500,30 @@ func (s *Scheme) UnsafeConvertToVersion(in Object, target GroupVersioner) (Objec
|
|||
|
||||
// convertToVersion handles conversion with an optional copy.
|
||||
func (s *Scheme) convertToVersion(copy bool, in Object, target GroupVersioner) (Object, error) {
|
||||
// determine the incoming kinds with as few allocations as possible.
|
||||
t := reflect.TypeOf(in)
|
||||
if t.Kind() != reflect.Ptr {
|
||||
return nil, fmt.Errorf("only pointer types may be converted: %v", t)
|
||||
}
|
||||
t = t.Elem()
|
||||
if t.Kind() != reflect.Struct {
|
||||
return nil, fmt.Errorf("only pointers to struct types may be converted: %v", t)
|
||||
var t reflect.Type
|
||||
|
||||
if u, ok := in.(Unstructured); ok {
|
||||
typed, err := s.unstructuredToTyped(u)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
in = typed
|
||||
// unstructuredToTyped returns an Object, which must be a pointer to a struct.
|
||||
t = reflect.TypeOf(in).Elem()
|
||||
|
||||
} else {
|
||||
// determine the incoming kinds with as few allocations as possible.
|
||||
t = reflect.TypeOf(in)
|
||||
if t.Kind() != reflect.Ptr {
|
||||
return nil, fmt.Errorf("only pointer types may be converted: %v", t)
|
||||
}
|
||||
t = t.Elem()
|
||||
if t.Kind() != reflect.Struct {
|
||||
return nil, fmt.Errorf("only pointers to struct types may be converted: %v", t)
|
||||
}
|
||||
}
|
||||
|
||||
kinds, ok := s.typeToGVK[t]
|
||||
if !ok || len(kinds) == 0 {
|
||||
return nil, NewNotRegisteredErrForType(t)
|
||||
|
|
@ -501,27 +535,26 @@ func (s *Scheme) convertToVersion(copy bool, in Object, target GroupVersioner) (
|
|||
// 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([]schema.GroupVersionKind{unversionedKind}); ok {
|
||||
return copyAndSetTargetKind(copy, s, in, gvk)
|
||||
return copyAndSetTargetKind(copy, in, gvk)
|
||||
}
|
||||
return copyAndSetTargetKind(copy, s, in, unversionedKind)
|
||||
return copyAndSetTargetKind(copy, in, unversionedKind)
|
||||
}
|
||||
|
||||
return nil, NewNotRegisteredErrForTarget(t, target)
|
||||
}
|
||||
|
||||
// target wants to use the existing type, set kind and return (no conversion necessary)
|
||||
for _, kind := range kinds {
|
||||
if gvk == kind {
|
||||
return copyAndSetTargetKind(copy, s, in, gvk)
|
||||
return copyAndSetTargetKind(copy, in, gvk)
|
||||
}
|
||||
}
|
||||
|
||||
// type is unversioned, no conversion necessary
|
||||
if unversionedKind, ok := s.unversionedTypes[t]; ok {
|
||||
if gvk, ok := target.KindForGroupVersionKinds([]schema.GroupVersionKind{unversionedKind}); ok {
|
||||
return copyAndSetTargetKind(copy, s, in, gvk)
|
||||
return copyAndSetTargetKind(copy, in, gvk)
|
||||
}
|
||||
return copyAndSetTargetKind(copy, s, in, unversionedKind)
|
||||
return copyAndSetTargetKind(copy, in, unversionedKind)
|
||||
}
|
||||
|
||||
out, err := s.New(gvk)
|
||||
|
|
@ -543,13 +576,32 @@ func (s *Scheme) convertToVersion(copy bool, in Object, target GroupVersioner) (
|
|||
return out, nil
|
||||
}
|
||||
|
||||
// unstructuredToTyped attempts to transform an unstructured object to a typed
|
||||
// object if possible. It will return an error if conversion is not possible, or the versioned
|
||||
// Go form of the object. Note that this conversion will lose fields.
|
||||
func (s *Scheme) unstructuredToTyped(in Unstructured) (Object, error) {
|
||||
// the type must be something we recognize
|
||||
gvks, _, err := s.ObjectKinds(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
typed, err := s.New(gvks[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := DefaultUnstructuredConverter.FromUnstructured(in.UnstructuredContent(), typed); err != nil {
|
||||
return nil, fmt.Errorf("unable to convert unstructured object to %v: %v", gvks[0], err)
|
||||
}
|
||||
return typed, nil
|
||||
}
|
||||
|
||||
// generateConvertMeta constructs the meta value we pass to Convert.
|
||||
func (s *Scheme) generateConvertMeta(in interface{}) (conversion.FieldMatchingFlags, *conversion.Meta) {
|
||||
return s.converter.DefaultMeta(reflect.TypeOf(in))
|
||||
}
|
||||
|
||||
// copyAndSetTargetKind performs a conditional copy before returning the object, or an error if copy was not successful.
|
||||
func copyAndSetTargetKind(copy bool, copier ObjectCopier, obj Object, kind schema.GroupVersionKind) (Object, error) {
|
||||
func copyAndSetTargetKind(copy bool, obj Object, kind schema.GroupVersionKind) (Object, error) {
|
||||
if copy {
|
||||
obj = obj.DeepCopyObject()
|
||||
}
|
||||
|
|
|
|||
214
vendor/k8s.io/apimachinery/pkg/runtime/scheme_test.go
generated
vendored
214
vendor/k8s.io/apimachinery/pkg/runtime/scheme_test.go
generated
vendored
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package runtime_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -126,14 +127,84 @@ func TestScheme(t *testing.T) {
|
|||
t.Errorf("Expected %v, got %v", e, a)
|
||||
}
|
||||
|
||||
// Test convert internal to unstructured
|
||||
unstructuredObj := &runtimetesting.Unstructured{}
|
||||
err = scheme.Convert(simple, unstructuredObj, nil)
|
||||
if err == nil || !strings.Contains(err.Error(), "to Unstructured without providing a preferred version to convert to") {
|
||||
t.Fatalf("Unexpected non-error: %v", err)
|
||||
}
|
||||
err = scheme.Convert(simple, unstructuredObj, schema.GroupVersion{Group: "test.group", Version: "testExternal"})
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
if e, a := simple.TestString, unstructuredObj.Object["testString"].(string); e != a {
|
||||
t.Errorf("Expected %v, got %v", e, a)
|
||||
}
|
||||
if e := unstructuredObj.GetObjectKind().GroupVersionKind(); !reflect.DeepEqual(e, schema.GroupVersionKind{Group: "test.group", Version: "testExternal", Kind: "Simple"}) {
|
||||
t.Errorf("Unexpected object kind: %#v", e)
|
||||
}
|
||||
if gvks, unversioned, err := scheme.ObjectKinds(unstructuredObj); err != nil || !reflect.DeepEqual(gvks[0], schema.GroupVersionKind{Group: "test.group", Version: "testExternal", Kind: "Simple"}) || unversioned {
|
||||
t.Errorf("Scheme did not recognize unversioned: %v, %#v %t", err, gvks, unversioned)
|
||||
}
|
||||
|
||||
// Test convert external to unstructured
|
||||
unstructuredObj = &runtimetesting.Unstructured{}
|
||||
err = scheme.Convert(external, unstructuredObj, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
if e, a := simple.TestString, unstructuredObj.Object["testString"].(string); e != a {
|
||||
t.Errorf("Expected %v, got %v", e, a)
|
||||
}
|
||||
if e := unstructuredObj.GetObjectKind().GroupVersionKind(); !reflect.DeepEqual(e, schema.GroupVersionKind{Group: "test.group", Version: "testExternal", Kind: "Simple"}) {
|
||||
t.Errorf("Unexpected object kind: %#v", e)
|
||||
}
|
||||
|
||||
// Test convert unstructured to unstructured
|
||||
uIn := &runtimetesting.Unstructured{Object: map[string]interface{}{
|
||||
"test": []interface{}{"other", "test"},
|
||||
}}
|
||||
uOut := &runtimetesting.Unstructured{}
|
||||
err = scheme.Convert(uIn, uOut, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(uIn.Object, uOut.Object) {
|
||||
t.Errorf("Unexpected object contents: %#v", uOut.Object)
|
||||
}
|
||||
|
||||
// Test convert unstructured to structured
|
||||
externalOut := &runtimetesting.ExternalSimple{}
|
||||
err = scheme.Convert(unstructuredObj, externalOut, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(external, externalOut) {
|
||||
t.Errorf("Unexpected object contents: %#v", externalOut)
|
||||
}
|
||||
|
||||
// Encode and Convert should each have caused an increment.
|
||||
if e, a := 2, internalToExternalCalls; e != a {
|
||||
if e, a := 3, internalToExternalCalls; e != a {
|
||||
t.Errorf("Expected %v, got %v", e, a)
|
||||
}
|
||||
// DecodeInto and Decode should each have caused an increment because of a conversion
|
||||
if e, a := 2, externalToInternalCalls; e != a {
|
||||
t.Errorf("Expected %v, got %v", e, a)
|
||||
}
|
||||
|
||||
// Verify that unstructured types must have V and K set
|
||||
emptyObj := &runtimetesting.Unstructured{Object: make(map[string]interface{})}
|
||||
if _, _, err := scheme.ObjectKinds(emptyObj); !runtime.IsMissingKind(err) {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
emptyObj.SetGroupVersionKind(schema.GroupVersionKind{Kind: "Test"})
|
||||
if _, _, err := scheme.ObjectKinds(emptyObj); !runtime.IsMissingVersion(err) {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
emptyObj.SetGroupVersionKind(schema.GroupVersionKind{Kind: "Test", Version: "v1"})
|
||||
if _, _, err := scheme.ObjectKinds(emptyObj); err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBadJSONRejection(t *testing.T) {
|
||||
|
|
@ -367,6 +438,7 @@ func GetTestScheme() *runtime.Scheme {
|
|||
internalGV := schema.GroupVersion{Version: "__internal"}
|
||||
externalGV := schema.GroupVersion{Version: "v1"}
|
||||
alternateExternalGV := schema.GroupVersion{Group: "custom", Version: "v1"}
|
||||
alternateInternalGV := schema.GroupVersion{Group: "custom", Version: "__internal"}
|
||||
differentExternalGV := schema.GroupVersion{Group: "other", Version: "v2"}
|
||||
|
||||
s := runtime.NewScheme()
|
||||
|
|
@ -380,10 +452,15 @@ func GetTestScheme() *runtime.Scheme {
|
|||
s.AddKnownTypeWithName(internalGV.WithKind("TestType3"), &runtimetesting.TestType1{})
|
||||
s.AddKnownTypeWithName(externalGV.WithKind("TestType3"), &runtimetesting.ExternalTestType1{})
|
||||
s.AddKnownTypeWithName(externalGV.WithKind("TestType4"), &runtimetesting.ExternalTestType1{})
|
||||
s.AddKnownTypeWithName(alternateInternalGV.WithKind("TestType3"), &runtimetesting.TestType1{})
|
||||
s.AddKnownTypeWithName(alternateExternalGV.WithKind("TestType3"), &runtimetesting.ExternalTestType1{})
|
||||
s.AddKnownTypeWithName(alternateExternalGV.WithKind("TestType5"), &runtimetesting.ExternalTestType1{})
|
||||
s.AddKnownTypeWithName(differentExternalGV.WithKind("TestType1"), &runtimetesting.ExternalTestType1{})
|
||||
s.AddUnversionedTypes(externalGV, &runtimetesting.UnversionedType{})
|
||||
|
||||
s.AddConversionFuncs(func(in *runtimetesting.TestType1, out *runtimetesting.ExternalTestType1, s conversion.Scope) {
|
||||
out.A = in.A
|
||||
})
|
||||
return s
|
||||
}
|
||||
|
||||
|
|
@ -540,6 +617,28 @@ func TestConvertToVersion(t *testing.T) {
|
|||
gv: schema.GroupVersion{Version: "__internal"},
|
||||
out: &runtimetesting.TestType1{A: "test"},
|
||||
},
|
||||
// converts from unstructured to internal
|
||||
{
|
||||
scheme: GetTestScheme(),
|
||||
in: &runtimetesting.Unstructured{Object: map[string]interface{}{
|
||||
"apiVersion": "custom/v1",
|
||||
"kind": "TestType3",
|
||||
"A": "test",
|
||||
}},
|
||||
gv: schema.GroupVersion{Version: "__internal"},
|
||||
out: &runtimetesting.TestType1{A: "test"},
|
||||
},
|
||||
// converts from unstructured to external
|
||||
{
|
||||
scheme: GetTestScheme(),
|
||||
in: &runtimetesting.Unstructured{Object: map[string]interface{}{
|
||||
"apiVersion": "custom/v1",
|
||||
"kind": "TestType3",
|
||||
"A": "test",
|
||||
}},
|
||||
gv: schema.GroupVersion{Group: "custom", Version: "v1"},
|
||||
out: &runtimetesting.ExternalTestType1{MyWeirdCustomEmbeddedVersionKindField: runtimetesting.MyWeirdCustomEmbeddedVersionKindField{APIVersion: "custom/v1", ObjectKind: "TestType3"}, A: "test"},
|
||||
},
|
||||
// prefers the best match
|
||||
{
|
||||
scheme: GetTestScheme(),
|
||||
|
|
@ -711,51 +810,88 @@ func TestConvertToVersion(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for i, test := range testCases {
|
||||
original := test.in.DeepCopyObject()
|
||||
out, err := test.scheme.ConvertToVersion(test.in, test.gv)
|
||||
switch {
|
||||
case test.errFn != nil:
|
||||
if !test.errFn(err) {
|
||||
t.Errorf("%d: unexpected error: %v", i, err)
|
||||
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
||||
original := test.in.DeepCopyObject()
|
||||
out, err := test.scheme.ConvertToVersion(test.in, test.gv)
|
||||
switch {
|
||||
case test.errFn != nil:
|
||||
if !test.errFn(err) {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
return
|
||||
case err != nil:
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if out == test.in {
|
||||
t.Fatalf("ConvertToVersion should always copy out: %#v", out)
|
||||
}
|
||||
continue
|
||||
case err != nil:
|
||||
t.Errorf("%d: unexpected error: %v", i, err)
|
||||
continue
|
||||
}
|
||||
if out == test.in {
|
||||
t.Errorf("%d: ConvertToVersion should always copy out: %#v", i, out)
|
||||
continue
|
||||
}
|
||||
|
||||
if test.same {
|
||||
if !reflect.DeepEqual(original, test.in) {
|
||||
t.Errorf("%d: unexpected mutation of input: %s", i, diff.ObjectReflectDiff(original, test.in))
|
||||
continue
|
||||
if test.same {
|
||||
if !reflect.DeepEqual(original, test.in) {
|
||||
t.Fatalf("unexpected mutation of input: %s", diff.ObjectReflectDiff(original, test.in))
|
||||
}
|
||||
if !reflect.DeepEqual(out, test.out) {
|
||||
t.Fatalf("unexpected out: %s", diff.ObjectReflectDiff(out, test.out))
|
||||
}
|
||||
unsafe, err := test.scheme.UnsafeConvertToVersion(test.in, test.gv)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(unsafe, test.out) {
|
||||
t.Fatalf("unexpected unsafe: %s", diff.ObjectReflectDiff(unsafe, test.out))
|
||||
}
|
||||
if unsafe != test.in {
|
||||
t.Fatalf("UnsafeConvertToVersion should return same object: %#v", unsafe)
|
||||
}
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(out, test.out) {
|
||||
t.Errorf("%d: unexpected out: %s", i, diff.ObjectReflectDiff(out, test.out))
|
||||
continue
|
||||
t.Fatalf("unexpected out: %s", diff.ObjectReflectDiff(out, test.out))
|
||||
}
|
||||
unsafe, err := test.scheme.UnsafeConvertToVersion(test.in, test.gv)
|
||||
if err != nil {
|
||||
t.Errorf("%d: unexpected error: %v", i, err)
|
||||
continue
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvert(t *testing.T) {
|
||||
testCases := []struct {
|
||||
scheme *runtime.Scheme
|
||||
in runtime.Object
|
||||
into runtime.Object
|
||||
gv runtime.GroupVersioner
|
||||
out runtime.Object
|
||||
errFn func(error) bool
|
||||
}{
|
||||
// converts from internal to unstructured, given a target version
|
||||
{
|
||||
scheme: GetTestScheme(),
|
||||
in: &runtimetesting.TestType1{A: "test"},
|
||||
into: &runtimetesting.Unstructured{},
|
||||
out: &runtimetesting.Unstructured{Object: map[string]interface{}{
|
||||
"myVersionKey": "custom/v1",
|
||||
"myKindKey": "TestType3",
|
||||
"A": "test",
|
||||
}},
|
||||
gv: schema.GroupVersion{Group: "custom", Version: "v1"},
|
||||
},
|
||||
}
|
||||
for i, test := range testCases {
|
||||
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
||||
err := test.scheme.Convert(test.in, test.into, test.gv)
|
||||
switch {
|
||||
case test.errFn != nil:
|
||||
if !test.errFn(err) {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
return
|
||||
case err != nil:
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(unsafe, test.out) {
|
||||
t.Errorf("%d: unexpected unsafe: %s", i, diff.ObjectReflectDiff(unsafe, test.out))
|
||||
continue
|
||||
|
||||
if !reflect.DeepEqual(test.into, test.out) {
|
||||
t.Fatalf("unexpected out: %s", diff.ObjectReflectDiff(test.into, test.out))
|
||||
}
|
||||
if unsafe != test.in {
|
||||
t.Errorf("%d: UnsafeConvertToVersion should return same object: %#v", i, unsafe)
|
||||
continue
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !reflect.DeepEqual(out, test.out) {
|
||||
t.Errorf("%d: unexpected out: %s", i, diff.ObjectReflectDiff(out, test.out))
|
||||
continue
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/runtime/serializer/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/runtime/serializer/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["codec_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/github.com/ghodss/yaml:go_default_library",
|
||||
|
|
@ -30,6 +31,7 @@ go_library(
|
|||
"negotiated_codec.go",
|
||||
"protobuf_extension.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
|
|
|
|||
3
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/BUILD
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["meta_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/json",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
|
|
@ -18,6 +19,7 @@ go_library(
|
|||
"json.go",
|
||||
"meta.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/json",
|
||||
deps = [
|
||||
"//vendor/github.com/ghodss/yaml:go_default_library",
|
||||
"//vendor/github.com/json-iterator/go:go_default_library",
|
||||
|
|
@ -32,6 +34,7 @@ go_library(
|
|||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["json_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/json_test",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
|
|
|
|||
3
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go
generated
vendored
|
|
@ -150,9 +150,10 @@ func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, i
|
|||
}
|
||||
|
||||
if into != nil {
|
||||
_, isUnstructured := into.(runtime.Unstructured)
|
||||
types, _, err := s.typer.ObjectKinds(into)
|
||||
switch {
|
||||
case runtime.IsNotRegisteredError(err):
|
||||
case runtime.IsNotRegisteredError(err), isUnstructured:
|
||||
if err := jsoniter.ConfigFastest.Unmarshal(data, into); err != nil {
|
||||
return nil, actual, err
|
||||
}
|
||||
|
|
|
|||
1
vendor/k8s.io/apimachinery/pkg/runtime/serializer/protobuf/BUILD
generated
vendored
1
vendor/k8s.io/apimachinery/pkg/runtime/serializer/protobuf/BUILD
generated
vendored
|
|
@ -11,6 +11,7 @@ go_library(
|
|||
"doc.go",
|
||||
"protobuf.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
|
||||
deps = [
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
|
|
|
|||
1
vendor/k8s.io/apimachinery/pkg/runtime/serializer/recognizer/BUILD
generated
vendored
1
vendor/k8s.io/apimachinery/pkg/runtime/serializer/recognizer/BUILD
generated
vendored
|
|
@ -8,6 +8,7 @@ load(
|
|||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["recognizer.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/runtime/serializer/streaming/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/runtime/serializer/streaming/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["streaming_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
|
|
@ -20,6 +21,7 @@ go_test(
|
|||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["streaming.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
|
|
|
|||
3
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/BUILD
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["versioning_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
|
|
@ -20,10 +21,10 @@ go_test(
|
|||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["versioning.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
|||
22
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/versioning.go
generated
vendored
22
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/versioning.go
generated
vendored
|
|
@ -21,7 +21,6 @@ import (
|
|||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
)
|
||||
|
||||
// NewCodecForScheme is a convenience method for callers that are using a scheme.
|
||||
|
|
@ -33,7 +32,7 @@ func NewCodecForScheme(
|
|||
encodeVersion runtime.GroupVersioner,
|
||||
decodeVersion runtime.GroupVersioner,
|
||||
) runtime.Codec {
|
||||
return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, scheme, nil, encodeVersion, decodeVersion)
|
||||
return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, nil, encodeVersion, decodeVersion)
|
||||
}
|
||||
|
||||
// NewDefaultingCodecForScheme is a convenience method for callers that are using a scheme.
|
||||
|
|
@ -45,7 +44,7 @@ func NewDefaultingCodecForScheme(
|
|||
encodeVersion runtime.GroupVersioner,
|
||||
decodeVersion runtime.GroupVersioner,
|
||||
) runtime.Codec {
|
||||
return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, scheme, scheme, encodeVersion, decodeVersion)
|
||||
return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, scheme, encodeVersion, decodeVersion)
|
||||
}
|
||||
|
||||
// NewCodec takes objects in their internal versions and converts them to external versions before
|
||||
|
|
@ -56,7 +55,6 @@ func NewCodec(
|
|||
decoder runtime.Decoder,
|
||||
convertor runtime.ObjectConvertor,
|
||||
creater runtime.ObjectCreater,
|
||||
copier runtime.ObjectCopier,
|
||||
typer runtime.ObjectTyper,
|
||||
defaulter runtime.ObjectDefaulter,
|
||||
encodeVersion runtime.GroupVersioner,
|
||||
|
|
@ -67,7 +65,6 @@ func NewCodec(
|
|||
decoder: decoder,
|
||||
convertor: convertor,
|
||||
creater: creater,
|
||||
copier: copier,
|
||||
typer: typer,
|
||||
defaulter: defaulter,
|
||||
|
||||
|
|
@ -82,7 +79,6 @@ type codec struct {
|
|||
decoder runtime.Decoder
|
||||
convertor runtime.ObjectConvertor
|
||||
creater runtime.ObjectCreater
|
||||
copier runtime.ObjectCopier
|
||||
typer runtime.ObjectTyper
|
||||
defaulter runtime.ObjectDefaulter
|
||||
|
||||
|
|
@ -123,12 +119,7 @@ func (c *codec) Decode(data []byte, defaultGVK *schema.GroupVersionKind, into ru
|
|||
if c.defaulter != nil {
|
||||
// create a copy to ensure defaulting is not applied to the original versioned objects
|
||||
if isVersioned {
|
||||
copied, err := c.copier.Copy(obj)
|
||||
if err != nil {
|
||||
utilruntime.HandleError(err)
|
||||
copied = obj
|
||||
}
|
||||
versioned.Objects = []runtime.Object{copied}
|
||||
versioned.Objects = []runtime.Object{obj.DeepCopyObject()}
|
||||
}
|
||||
c.defaulter.Default(obj)
|
||||
} else {
|
||||
|
|
@ -151,12 +142,7 @@ func (c *codec) Decode(data []byte, defaultGVK *schema.GroupVersionKind, into ru
|
|||
// Convert if needed.
|
||||
if isVersioned {
|
||||
// create a copy, because ConvertToVersion does not guarantee non-mutation of objects
|
||||
copied, err := c.copier.Copy(obj)
|
||||
if err != nil {
|
||||
utilruntime.HandleError(err)
|
||||
copied = obj
|
||||
}
|
||||
versioned.Objects = []runtime.Object{copied}
|
||||
versioned.Objects = []runtime.Object{obj.DeepCopyObject()}
|
||||
}
|
||||
|
||||
// perform defaulting if requested
|
||||
|
|
|
|||
46
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/versioning_test.go
generated
vendored
46
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/versioning_test.go
generated
vendored
|
|
@ -38,11 +38,8 @@ func (d *testDecodable) GetObjectKind() schema.ObjectKind { retur
|
|||
func (d *testDecodable) SetGroupVersionKind(gvk schema.GroupVersionKind) { d.gvk = gvk }
|
||||
func (d *testDecodable) GroupVersionKind() schema.GroupVersionKind { return d.gvk }
|
||||
func (d *testDecodable) DeepCopyObject() runtime.Object {
|
||||
if d == nil {
|
||||
return nil
|
||||
}
|
||||
clone := *d
|
||||
return &clone
|
||||
// no real deepcopy because these tests check for pointer equality
|
||||
return d
|
||||
}
|
||||
|
||||
type testNestedDecodable struct {
|
||||
|
|
@ -58,11 +55,8 @@ func (d *testNestedDecodable) GetObjectKind() schema.ObjectKind {
|
|||
func (d *testNestedDecodable) SetGroupVersionKind(gvk schema.GroupVersionKind) { d.gvk = gvk }
|
||||
func (d *testNestedDecodable) GroupVersionKind() schema.GroupVersionKind { return d.gvk }
|
||||
func (d *testNestedDecodable) DeepCopyObject() runtime.Object {
|
||||
if d == nil {
|
||||
return nil
|
||||
}
|
||||
clone := *d
|
||||
return &clone
|
||||
// no real deepcopy because these tests check for pointer equality
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *testNestedDecodable) EncodeNestedObjects(e runtime.Encoder) error {
|
||||
|
|
@ -78,7 +72,7 @@ func (d *testNestedDecodable) DecodeNestedObjects(_ runtime.Decoder) error {
|
|||
func TestNestedDecode(t *testing.T) {
|
||||
n := &testNestedDecodable{nestedErr: fmt.Errorf("unable to decode")}
|
||||
decoder := &mockSerializer{obj: n}
|
||||
codec := NewCodec(nil, decoder, nil, nil, nil, nil, nil, nil, nil)
|
||||
codec := NewCodec(nil, decoder, nil, nil, nil, nil, nil, nil)
|
||||
if _, _, err := codec.Decode([]byte(`{}`), nil, n); err != n.nestedErr {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
|
@ -94,7 +88,7 @@ func TestNestedEncode(t *testing.T) {
|
|||
codec := NewCodec(
|
||||
encoder, nil,
|
||||
&checkConvertor{obj: n2, groupVersion: schema.GroupVersion{Group: "other"}},
|
||||
nil, nil,
|
||||
nil,
|
||||
&mockTyper{gvks: []schema.GroupVersionKind{{Kind: "test"}}},
|
||||
nil,
|
||||
schema.GroupVersion{Group: "other"}, nil,
|
||||
|
|
@ -118,7 +112,6 @@ func TestDecode(t *testing.T) {
|
|||
serializer runtime.Serializer
|
||||
convertor runtime.ObjectConvertor
|
||||
creater runtime.ObjectCreater
|
||||
copier runtime.ObjectCopier
|
||||
typer runtime.ObjectTyper
|
||||
defaulter runtime.ObjectDefaulter
|
||||
yaml bool
|
||||
|
|
@ -191,17 +184,6 @@ func TestDecode(t *testing.T) {
|
|||
into: &runtime.VersionedObjects{Objects: []runtime.Object{}},
|
||||
|
||||
serializer: &mockSerializer{actual: gvk1, obj: decodable1},
|
||||
copier: &checkCopy{in: decodable1, obj: decodable1},
|
||||
convertor: &checkConvertor{in: decodable1, obj: decodable2, groupVersion: schema.GroupVersion{Group: "other", Version: "__internal"}},
|
||||
expectedGVK: gvk1,
|
||||
expectedObject: &runtime.VersionedObjects{Objects: []runtime.Object{decodable1, decodable2}},
|
||||
decodes: schema.GroupVersion{Group: "other", Version: "__internal"},
|
||||
},
|
||||
{
|
||||
into: &runtime.VersionedObjects{Objects: []runtime.Object{}},
|
||||
|
||||
serializer: &mockSerializer{actual: gvk1, obj: decodable1},
|
||||
copier: &checkCopy{in: decodable1, obj: nil, err: fmt.Errorf("error on copy")},
|
||||
convertor: &checkConvertor{in: decodable1, obj: decodable2, groupVersion: schema.GroupVersion{Group: "other", Version: "__internal"}},
|
||||
expectedGVK: gvk1,
|
||||
expectedObject: &runtime.VersionedObjects{Objects: []runtime.Object{decodable1, decodable2}},
|
||||
|
|
@ -223,7 +205,6 @@ func TestDecode(t *testing.T) {
|
|||
|
||||
serializer: &mockSerializer{actual: gvk1, obj: decodable1},
|
||||
convertor: &checkConvertor{in: decodable1, obj: decodable1, groupVersion: schema.GroupVersions{{Group: "other", Version: "blah"}}},
|
||||
copier: &checkCopy{in: decodable1, obj: decodable1, err: nil},
|
||||
expectedGVK: gvk1,
|
||||
expectedObject: &runtime.VersionedObjects{Objects: []runtime.Object{decodable1}},
|
||||
},
|
||||
|
|
@ -243,7 +224,6 @@ func TestDecode(t *testing.T) {
|
|||
|
||||
serializer: &mockSerializer{actual: gvk1, obj: decodable1},
|
||||
convertor: &checkConvertor{in: decodable1, obj: decodable1, groupVersion: schema.GroupVersions{{Group: "something", Version: "else"}}},
|
||||
copier: &checkCopy{in: decodable1, obj: decodable1, err: nil},
|
||||
expectedGVK: gvk1,
|
||||
expectedObject: &runtime.VersionedObjects{Objects: []runtime.Object{decodable1}},
|
||||
},
|
||||
|
|
@ -251,7 +231,7 @@ func TestDecode(t *testing.T) {
|
|||
|
||||
for i, test := range testCases {
|
||||
t.Logf("%d", i)
|
||||
s := NewCodec(test.serializer, test.serializer, test.convertor, test.creater, test.copier, test.typer, test.defaulter, test.encodes, test.decodes)
|
||||
s := NewCodec(test.serializer, test.serializer, test.convertor, test.creater, test.typer, test.defaulter, test.encodes, test.decodes)
|
||||
obj, gvk, err := s.Decode([]byte(`{}`), test.defaultGVK, test.into)
|
||||
|
||||
if !reflect.DeepEqual(test.expectedGVK, gvk) {
|
||||
|
|
@ -295,18 +275,6 @@ func TestDecode(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
type checkCopy struct {
|
||||
in, obj runtime.Object
|
||||
err error
|
||||
}
|
||||
|
||||
func (c *checkCopy) Copy(obj runtime.Object) (runtime.Object, error) {
|
||||
if c.in != nil && c.in != obj {
|
||||
return nil, fmt.Errorf("unexpected input to copy: %#v", obj)
|
||||
}
|
||||
return c.obj, c.err
|
||||
}
|
||||
|
||||
type checkConvertor struct {
|
||||
err error
|
||||
in, obj runtime.Object
|
||||
|
|
|
|||
27
vendor/k8s.io/apimachinery/pkg/runtime/zz_generated.deepcopy.go
generated
vendored
27
vendor/k8s.io/apimachinery/pkg/runtime/zz_generated.deepcopy.go
generated
vendored
|
|
@ -1,7 +1,7 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
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.
|
||||
|
|
@ -20,31 +20,6 @@ limitations under the License.
|
|||
|
||||
package runtime
|
||||
|
||||
import (
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// GetGeneratedDeepCopyFuncs returns the generated funcs, since we aren't registering them.
|
||||
//
|
||||
// Deprecated: deepcopy registration will go away when static deepcopy is fully implemented.
|
||||
func GetGeneratedDeepCopyFuncs() []conversion.GeneratedDeepCopyFunc {
|
||||
return []conversion.GeneratedDeepCopyFunc{
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*RawExtension).DeepCopyInto(out.(*RawExtension))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&RawExtension{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*Unknown).DeepCopyInto(out.(*Unknown))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&Unknown{})},
|
||||
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*VersionedObjects).DeepCopyInto(out.(*VersionedObjects))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&VersionedObjects{})},
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RawExtension) DeepCopyInto(out *RawExtension) {
|
||||
*out = *in
|
||||
|
|
|
|||
1
vendor/k8s.io/apimachinery/pkg/selection/BUILD
generated
vendored
1
vendor/k8s.io/apimachinery/pkg/selection/BUILD
generated
vendored
|
|
@ -8,6 +8,7 @@ load(
|
|||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["operator.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/selection",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
|
|
|
|||
1
vendor/k8s.io/apimachinery/pkg/types/BUILD
generated
vendored
1
vendor/k8s.io/apimachinery/pkg/types/BUILD
generated
vendored
|
|
@ -14,6 +14,7 @@ go_library(
|
|||
"patch.go",
|
||||
"uid.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/types",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/util/cache/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/util/cache/BUILD
generated
vendored
|
|
@ -12,6 +12,7 @@ go_test(
|
|||
"cache_test.go",
|
||||
"lruexpirecache_test.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/cache",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/github.com/golang/groupcache/lru:go_default_library",
|
||||
|
|
@ -25,6 +26,7 @@ go_library(
|
|||
"cache.go",
|
||||
"lruexpirecache.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/cache",
|
||||
deps = ["//vendor/github.com/hashicorp/golang-lru:go_default_library"],
|
||||
)
|
||||
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/util/clock/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/util/clock/BUILD
generated
vendored
|
|
@ -9,12 +9,14 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["clock_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/clock",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["clock.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/clock",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/util/diff/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/util/diff/BUILD
generated
vendored
|
|
@ -9,12 +9,14 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["diff_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/diff",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["diff.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/diff",
|
||||
deps = [
|
||||
"//vendor/github.com/davecgh/go-spew/spew:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
||||
|
|
|
|||
11
vendor/k8s.io/apimachinery/pkg/util/diff/diff.go
generated
vendored
11
vendor/k8s.io/apimachinery/pkg/util/diff/diff.go
generated
vendored
|
|
@ -142,10 +142,6 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {
|
|||
}
|
||||
if sub := objectReflectDiff(path.Child(a.Type().Field(i).Name), a.Field(i), b.Field(i)); len(sub) > 0 {
|
||||
changes = append(changes, sub...)
|
||||
} else {
|
||||
if !reflect.DeepEqual(a.Field(i).Interface(), b.Field(i).Interface()) {
|
||||
changes = append(changes, diff{path: path, a: a.Field(i).Interface(), b: b.Field(i).Interface()})
|
||||
}
|
||||
}
|
||||
}
|
||||
return changes
|
||||
|
|
@ -178,21 +174,18 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
var diffs []diff
|
||||
for i := 0; i < l; i++ {
|
||||
if !reflect.DeepEqual(a.Index(i), b.Index(i)) {
|
||||
return objectReflectDiff(path.Index(i), a.Index(i), b.Index(i))
|
||||
diffs = append(diffs, objectReflectDiff(path.Index(i), a.Index(i), b.Index(i))...)
|
||||
}
|
||||
}
|
||||
var diffs []diff
|
||||
for i := l; i < lA; i++ {
|
||||
diffs = append(diffs, diff{path: path.Index(i), a: a.Index(i), b: nil})
|
||||
}
|
||||
for i := l; i < lB; i++ {
|
||||
diffs = append(diffs, diff{path: path.Index(i), a: nil, b: b.Index(i)})
|
||||
}
|
||||
if len(diffs) == 0 {
|
||||
diffs = append(diffs, diff{path: path, a: a, b: b})
|
||||
}
|
||||
return diffs
|
||||
case reflect.Map:
|
||||
if reflect.DeepEqual(a.Interface(), b.Interface()) {
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/util/errors/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/util/errors/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["errors_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/errors",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
|
|
@ -18,6 +19,7 @@ go_library(
|
|||
"doc.go",
|
||||
"errors.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/errors",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/util/framer/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/util/framer/BUILD
generated
vendored
|
|
@ -9,12 +9,14 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["framer_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/framer",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["framer.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/framer",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/util/httpstream/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/util/httpstream/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["httpstream_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/httpstream",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
|
|
@ -18,6 +19,7 @@ go_library(
|
|||
"doc.go",
|
||||
"httpstream.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/httpstream",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/util/httpstream/spdy/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/util/httpstream/spdy/BUILD
generated
vendored
|
|
@ -13,6 +13,7 @@ go_test(
|
|||
"roundtripper_test.go",
|
||||
"upgrade_test.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/httpstream/spdy",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//vendor/github.com/elazarl/goproxy:go_default_library",
|
||||
|
|
@ -27,6 +28,7 @@ go_library(
|
|||
"roundtripper.go",
|
||||
"upgrade.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/httpstream/spdy",
|
||||
deps = [
|
||||
"//vendor/github.com/docker/spdystream:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper.go
generated
vendored
|
|
@ -110,7 +110,7 @@ func (s *SpdyRoundTripper) Dial(req *http.Request) (net.Conn, error) {
|
|||
func (s *SpdyRoundTripper) dial(req *http.Request) (net.Conn, error) {
|
||||
proxier := s.proxier
|
||||
if proxier == nil {
|
||||
proxier = http.ProxyFromEnvironment
|
||||
proxier = utilnet.NewProxierWithNoProxyCIDR(http.ProxyFromEnvironment)
|
||||
}
|
||||
proxyURL, err := proxier(req)
|
||||
if err != nil {
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/util/intstr/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/util/intstr/BUILD
generated
vendored
|
|
@ -9,6 +9,7 @@ load(
|
|||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["intstr_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/intstr",
|
||||
library = ":go_default_library",
|
||||
deps = ["//vendor/github.com/ghodss/yaml:go_default_library"],
|
||||
)
|
||||
|
|
@ -19,6 +20,7 @@ go_library(
|
|||
"generated.pb.go",
|
||||
"intstr.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/intstr",
|
||||
deps = [
|
||||
"//vendor/github.com/go-openapi/spec:go_default_library",
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
|
|
|
|||
2
vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go
generated
vendored
|
|
@ -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.
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue