mirror of
https://github.com/coredns/coredns.git
synced 2026-01-22 16:32:55 -05:00
Update k8s client-go to v8.0.0 (#1922)
k8s' client-go has been updated to v8.0.0 (1.11). This fix updates client-go dependency so that it is in sync. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
47
vendor/k8s.io/apimachinery/pkg/api/errors/BUILD
generated
vendored
47
vendor/k8s.io/apimachinery/pkg/api/errors/BUILD
generated
vendored
@@ -1,47 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["errors_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1: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/util/validation/field:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"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",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
72
vendor/k8s.io/apimachinery/pkg/api/meta/BUILD
generated
vendored
72
vendor/k8s.io/apimachinery/pkg/api/meta/BUILD
generated
vendored
@@ -1,72 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"meta_test.go",
|
||||
"multirestmapper_test.go",
|
||||
"priority_test.go",
|
||||
"restmapper_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1: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/util/diff:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"errors.go",
|
||||
"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",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1: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/types:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets: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/api/meta/table:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
21
vendor/k8s.io/apimachinery/pkg/api/meta/interfaces.go
generated
vendored
21
vendor/k8s.io/apimachinery/pkg/api/meta/interfaces.go
generated
vendored
@@ -23,12 +23,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
)
|
||||
|
||||
// VersionInterfaces contains the interfaces one should use for dealing with types of a particular version.
|
||||
type VersionInterfaces struct {
|
||||
runtime.ObjectConvertor
|
||||
MetadataAccessor
|
||||
}
|
||||
|
||||
type ListMetaAccessor interface {
|
||||
GetListMeta() List
|
||||
}
|
||||
@@ -92,28 +86,19 @@ const (
|
||||
type RESTScope interface {
|
||||
// Name of the scope
|
||||
Name() RESTScopeName
|
||||
// ParamName is the optional name of the parameter that should be inserted in the resource url
|
||||
// If empty, no param will be inserted
|
||||
ParamName() string
|
||||
// ArgumentName is the optional name that should be used for the variable holding the value.
|
||||
ArgumentName() string
|
||||
// ParamDescription is the optional description to use to document the parameter in api documentation
|
||||
ParamDescription() string
|
||||
}
|
||||
|
||||
// RESTMapping contains the information needed to deal with objects of a specific
|
||||
// resource and kind in a RESTful manner.
|
||||
type RESTMapping struct {
|
||||
// Resource is a string representing the name of this resource as a REST client would see it
|
||||
Resource string
|
||||
// Resource is the GroupVersionResource (location) for this endpoint
|
||||
Resource schema.GroupVersionResource
|
||||
|
||||
// GroupVersionKind is the GroupVersionKind (data format) to submit to this endpoint
|
||||
GroupVersionKind schema.GroupVersionKind
|
||||
|
||||
// Scope contains the information needed to deal with REST Resources that are in a resource hierarchy
|
||||
Scope RESTScope
|
||||
|
||||
runtime.ObjectConvertor
|
||||
MetadataAccessor
|
||||
}
|
||||
|
||||
// RESTMapper allows clients to map resources to kind, and map kind and version
|
||||
|
||||
25
vendor/k8s.io/apimachinery/pkg/api/meta/lazy.go
generated
vendored
25
vendor/k8s.io/apimachinery/pkg/api/meta/lazy.go
generated
vendored
@@ -19,27 +19,25 @@ 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)
|
||||
loader func() (RESTMapper, 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) {
|
||||
func NewLazyRESTMapperLoader(fn func() (RESTMapper, error)) RESTMapper {
|
||||
obj := &lazyObject{loader: fn}
|
||||
return obj, obj
|
||||
return obj
|
||||
}
|
||||
|
||||
// init lazily loads the mapper and typer, returning an error if initialization has failed.
|
||||
@@ -49,13 +47,12 @@ func (o *lazyObject) init() error {
|
||||
if o.loaded {
|
||||
return o.err
|
||||
}
|
||||
o.mapper, o.typer, o.err = o.loader()
|
||||
o.mapper, 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 {
|
||||
@@ -105,17 +102,3 @@ func (o *lazyObject) ResourceSingularizer(resource string) (singular string, 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)
|
||||
}
|
||||
|
||||
3
vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
generated
vendored
@@ -38,7 +38,6 @@ var errNotCommon = fmt.Errorf("object does not implement the common interface fo
|
||||
|
||||
// CommonAccessor returns a Common interface for the provided object or an error if the object does
|
||||
// not provide List.
|
||||
// TODO: return bool instead of error
|
||||
func CommonAccessor(obj interface{}) (metav1.Common, error) {
|
||||
switch t := obj.(type) {
|
||||
case List:
|
||||
@@ -71,7 +70,6 @@ func CommonAccessor(obj interface{}) (metav1.Common, error) {
|
||||
// not provide List.
|
||||
// IMPORTANT: Objects are NOT a superset of lists. Do not use this check to determine whether an
|
||||
// object *is* a List.
|
||||
// TODO: return bool instead of error
|
||||
func ListAccessor(obj interface{}) (List, error) {
|
||||
switch t := obj.(type) {
|
||||
case List:
|
||||
@@ -101,7 +99,6 @@ var errNotObject = fmt.Errorf("object does not implement the Object interfaces")
|
||||
// obj must be a pointer to an API type. An error is returned if the minimum
|
||||
// required fields are missing. Fields that are not required return the default
|
||||
// value and are a no-op if set.
|
||||
// TODO: return bool instead of error
|
||||
func Accessor(obj interface{}) (metav1.Object, error) {
|
||||
switch t := obj.(type) {
|
||||
case metav1.Object:
|
||||
|
||||
30
vendor/k8s.io/apimachinery/pkg/api/meta/priority.go
generated
vendored
30
vendor/k8s.io/apimachinery/pkg/api/meta/priority.go
generated
vendored
@@ -54,12 +54,12 @@ func (m PriorityRESTMapper) String() string {
|
||||
|
||||
// ResourceFor finds all resources, then passes them through the ResourcePriority patterns to find a single matching hit.
|
||||
func (m PriorityRESTMapper) ResourceFor(partiallySpecifiedResource schema.GroupVersionResource) (schema.GroupVersionResource, error) {
|
||||
originalGVRs, err := m.Delegate.ResourcesFor(partiallySpecifiedResource)
|
||||
if err != nil {
|
||||
return schema.GroupVersionResource{}, err
|
||||
originalGVRs, originalErr := m.Delegate.ResourcesFor(partiallySpecifiedResource)
|
||||
if originalErr != nil && len(originalGVRs) == 0 {
|
||||
return schema.GroupVersionResource{}, originalErr
|
||||
}
|
||||
if len(originalGVRs) == 1 {
|
||||
return originalGVRs[0], nil
|
||||
return originalGVRs[0], originalErr
|
||||
}
|
||||
|
||||
remainingGVRs := append([]schema.GroupVersionResource{}, originalGVRs...)
|
||||
@@ -77,7 +77,7 @@ func (m PriorityRESTMapper) ResourceFor(partiallySpecifiedResource schema.GroupV
|
||||
continue
|
||||
case 1:
|
||||
// one match, return
|
||||
return matchedGVRs[0], nil
|
||||
return matchedGVRs[0], originalErr
|
||||
default:
|
||||
// more than one match, use the matched hits as the list moving to the next pattern.
|
||||
// this way you can have a series of selection criteria
|
||||
@@ -90,12 +90,12 @@ func (m PriorityRESTMapper) ResourceFor(partiallySpecifiedResource schema.GroupV
|
||||
|
||||
// KindFor finds all kinds, then passes them through the KindPriority patterns to find a single matching hit.
|
||||
func (m PriorityRESTMapper) KindFor(partiallySpecifiedResource schema.GroupVersionResource) (schema.GroupVersionKind, error) {
|
||||
originalGVKs, err := m.Delegate.KindsFor(partiallySpecifiedResource)
|
||||
if err != nil {
|
||||
return schema.GroupVersionKind{}, err
|
||||
originalGVKs, originalErr := m.Delegate.KindsFor(partiallySpecifiedResource)
|
||||
if originalErr != nil && len(originalGVKs) == 0 {
|
||||
return schema.GroupVersionKind{}, originalErr
|
||||
}
|
||||
if len(originalGVKs) == 1 {
|
||||
return originalGVKs[0], nil
|
||||
return originalGVKs[0], originalErr
|
||||
}
|
||||
|
||||
remainingGVKs := append([]schema.GroupVersionKind{}, originalGVKs...)
|
||||
@@ -113,7 +113,7 @@ func (m PriorityRESTMapper) KindFor(partiallySpecifiedResource schema.GroupVersi
|
||||
continue
|
||||
case 1:
|
||||
// one match, return
|
||||
return matchedGVKs[0], nil
|
||||
return matchedGVKs[0], originalErr
|
||||
default:
|
||||
// more than one match, use the matched hits as the list moving to the next pattern.
|
||||
// this way you can have a series of selection criteria
|
||||
@@ -153,9 +153,9 @@ func kindMatches(pattern schema.GroupVersionKind, kind schema.GroupVersionKind)
|
||||
}
|
||||
|
||||
func (m PriorityRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (mapping *RESTMapping, err error) {
|
||||
mappings, err := m.Delegate.RESTMappings(gk, versions...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
mappings, originalErr := m.Delegate.RESTMappings(gk, versions...)
|
||||
if originalErr != nil && len(mappings) == 0 {
|
||||
return nil, originalErr
|
||||
}
|
||||
|
||||
// any versions the user provides take priority
|
||||
@@ -187,7 +187,7 @@ func (m PriorityRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string)
|
||||
continue
|
||||
case 1:
|
||||
// one match, return
|
||||
return matching[0], nil
|
||||
return matching[0], originalErr
|
||||
default:
|
||||
// more than one match, use the matched hits as the list moving to the next pattern.
|
||||
// this way you can have a series of selection criteria
|
||||
@@ -195,7 +195,7 @@ func (m PriorityRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string)
|
||||
}
|
||||
}
|
||||
if len(remaining) == 1 {
|
||||
return remaining[0], nil
|
||||
return remaining[0], originalErr
|
||||
}
|
||||
|
||||
var kinds []schema.GroupVersionKind
|
||||
|
||||
63
vendor/k8s.io/apimachinery/pkg/api/meta/priority_test.go
generated
vendored
63
vendor/k8s.io/apimachinery/pkg/api/meta/priority_test.go
generated
vendored
@@ -34,6 +34,30 @@ func TestPriorityRESTMapperResourceForErrorHandling(t *testing.T) {
|
||||
result schema.GroupVersionResource
|
||||
err string
|
||||
}{
|
||||
{
|
||||
name: "error",
|
||||
delegate: fixedRESTMapper{err: errors.New("delegateError")},
|
||||
err: "delegateError",
|
||||
},
|
||||
{
|
||||
name: "single hit + error",
|
||||
delegate: fixedRESTMapper{resourcesFor: []schema.GroupVersionResource{{Resource: "single-hit"}}, err: errors.New("delegateError")},
|
||||
result: schema.GroupVersionResource{Resource: "single-hit"},
|
||||
err: "delegateError",
|
||||
},
|
||||
{
|
||||
name: "group selection + error",
|
||||
delegate: fixedRESTMapper{resourcesFor: []schema.GroupVersionResource{
|
||||
{Group: "one", Version: "a", Resource: "first"},
|
||||
{Group: "two", Version: "b", Resource: "second"},
|
||||
}, err: errors.New("delegateError")},
|
||||
resourcePatterns: []schema.GroupVersionResource{
|
||||
{Group: "one", Version: AnyVersion, Resource: AnyResource},
|
||||
},
|
||||
result: schema.GroupVersionResource{Group: "one", Version: "a", Resource: "first"},
|
||||
err: "delegateError",
|
||||
},
|
||||
|
||||
{
|
||||
name: "single hit",
|
||||
delegate: fixedRESTMapper{resourcesFor: []schema.GroupVersionResource{{Resource: "single-hit"}}},
|
||||
@@ -106,6 +130,10 @@ func TestPriorityRESTMapperResourceForErrorHandling(t *testing.T) {
|
||||
if len(tc.err) == 0 && actualErr == nil {
|
||||
continue
|
||||
}
|
||||
if len(tc.err) == 0 && actualErr != nil {
|
||||
t.Errorf("%s: unexpected err: %v", tc.name, actualErr)
|
||||
continue
|
||||
}
|
||||
if len(tc.err) > 0 && actualErr == nil {
|
||||
t.Errorf("%s: missing expected err: %v", tc.name, tc.err)
|
||||
continue
|
||||
@@ -125,6 +153,30 @@ func TestPriorityRESTMapperKindForErrorHandling(t *testing.T) {
|
||||
result schema.GroupVersionKind
|
||||
err string
|
||||
}{
|
||||
{
|
||||
name: "error",
|
||||
delegate: fixedRESTMapper{err: errors.New("delegateErr")},
|
||||
err: "delegateErr",
|
||||
},
|
||||
{
|
||||
name: "single hit + error",
|
||||
delegate: fixedRESTMapper{kindsFor: []schema.GroupVersionKind{{Kind: "single-hit"}}, err: errors.New("delegateErr")},
|
||||
result: schema.GroupVersionKind{Kind: "single-hit"},
|
||||
err: "delegateErr",
|
||||
},
|
||||
{
|
||||
name: "group selection + error",
|
||||
delegate: fixedRESTMapper{kindsFor: []schema.GroupVersionKind{
|
||||
{Group: "one", Version: "a", Kind: "first"},
|
||||
{Group: "two", Version: "b", Kind: "second"},
|
||||
}, err: errors.New("delegateErr")},
|
||||
kindPatterns: []schema.GroupVersionKind{
|
||||
{Group: "one", Version: AnyVersion, Kind: AnyKind},
|
||||
},
|
||||
result: schema.GroupVersionKind{Group: "one", Version: "a", Kind: "first"},
|
||||
err: "delegateErr",
|
||||
},
|
||||
|
||||
{
|
||||
name: "single hit",
|
||||
delegate: fixedRESTMapper{kindsFor: []schema.GroupVersionKind{{Kind: "single-hit"}}},
|
||||
@@ -197,6 +249,10 @@ func TestPriorityRESTMapperKindForErrorHandling(t *testing.T) {
|
||||
if len(tc.err) == 0 && actualErr == nil {
|
||||
continue
|
||||
}
|
||||
if len(tc.err) == 0 && actualErr != nil {
|
||||
t.Errorf("%s: unexpected err: %v", tc.name, actualErr)
|
||||
continue
|
||||
}
|
||||
if len(tc.err) > 0 && actualErr == nil {
|
||||
t.Errorf("%s: missing expected err: %v", tc.name, tc.err)
|
||||
continue
|
||||
@@ -248,6 +304,13 @@ func TestPriorityRESTMapperRESTMapping(t *testing.T) {
|
||||
input: schema.GroupKind{Kind: "Foo"},
|
||||
err: errors.New("fail on this"),
|
||||
},
|
||||
{
|
||||
name: "result + error",
|
||||
mapper: PriorityRESTMapper{Delegate: fixedRESTMapper{mappings: []*RESTMapping{mapping1}, err: errors.New("fail on this")}},
|
||||
input: schema.GroupKind{Kind: "Foo"},
|
||||
result: mapping1,
|
||||
err: errors.New("fail on this"),
|
||||
},
|
||||
{
|
||||
name: "return error for ambiguous",
|
||||
mapper: PriorityRESTMapper{
|
||||
|
||||
38
vendor/k8s.io/apimachinery/pkg/api/meta/restmapper.go
generated
vendored
38
vendor/k8s.io/apimachinery/pkg/api/meta/restmapper.go
generated
vendored
@@ -28,30 +28,15 @@ import (
|
||||
|
||||
// Implements RESTScope interface
|
||||
type restScope struct {
|
||||
name RESTScopeName
|
||||
paramName string
|
||||
argumentName string
|
||||
paramDescription string
|
||||
name RESTScopeName
|
||||
}
|
||||
|
||||
func (r *restScope) Name() RESTScopeName {
|
||||
return r.name
|
||||
}
|
||||
func (r *restScope) ParamName() string {
|
||||
return r.paramName
|
||||
}
|
||||
func (r *restScope) ArgumentName() string {
|
||||
return r.argumentName
|
||||
}
|
||||
func (r *restScope) ParamDescription() string {
|
||||
return r.paramDescription
|
||||
}
|
||||
|
||||
var RESTScopeNamespace = &restScope{
|
||||
name: RESTScopeNameNamespace,
|
||||
paramName: "namespaces",
|
||||
argumentName: "namespace",
|
||||
paramDescription: "object name and auth scope, such as for teams and projects",
|
||||
name: RESTScopeNameNamespace,
|
||||
}
|
||||
|
||||
var RESTScopeRoot = &restScope{
|
||||
@@ -77,8 +62,6 @@ type DefaultRESTMapper struct {
|
||||
kindToScope map[schema.GroupVersionKind]RESTScope
|
||||
singularToPlural map[schema.GroupVersionResource]schema.GroupVersionResource
|
||||
pluralToSingular map[schema.GroupVersionResource]schema.GroupVersionResource
|
||||
|
||||
interfacesFunc VersionInterfacesFunc
|
||||
}
|
||||
|
||||
func (m *DefaultRESTMapper) String() string {
|
||||
@@ -87,16 +70,12 @@ func (m *DefaultRESTMapper) String() string {
|
||||
|
||||
var _ RESTMapper = &DefaultRESTMapper{}
|
||||
|
||||
// VersionInterfacesFunc returns the appropriate typer, and metadata accessor for a
|
||||
// given api version, or an error if no such api version exists.
|
||||
type VersionInterfacesFunc func(version schema.GroupVersion) (*VersionInterfaces, error)
|
||||
|
||||
// NewDefaultRESTMapper initializes a mapping between Kind and APIVersion
|
||||
// to a resource name and back based on the objects in a runtime.Scheme
|
||||
// and the Kubernetes API conventions. Takes a group name, a priority list of the versions
|
||||
// to search when an object has no default version (set empty to return an error),
|
||||
// and a function that retrieves the correct metadata for a given version.
|
||||
func NewDefaultRESTMapper(defaultGroupVersions []schema.GroupVersion, f VersionInterfacesFunc) *DefaultRESTMapper {
|
||||
func NewDefaultRESTMapper(defaultGroupVersions []schema.GroupVersion) *DefaultRESTMapper {
|
||||
resourceToKind := make(map[schema.GroupVersionResource]schema.GroupVersionKind)
|
||||
kindToPluralResource := make(map[schema.GroupVersionKind]schema.GroupVersionResource)
|
||||
kindToScope := make(map[schema.GroupVersionKind]RESTScope)
|
||||
@@ -111,7 +90,6 @@ func NewDefaultRESTMapper(defaultGroupVersions []schema.GroupVersion, f VersionI
|
||||
defaultGroupVersions: defaultGroupVersions,
|
||||
singularToPlural: singularToPlural,
|
||||
pluralToSingular: pluralToSingular,
|
||||
interfacesFunc: f,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,18 +504,10 @@ func (m *DefaultRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string
|
||||
return nil, fmt.Errorf("the provided version %q and kind %q cannot be mapped to a supported scope", gvk.GroupVersion(), gvk.Kind)
|
||||
}
|
||||
|
||||
interfaces, err := m.interfacesFunc(gvk.GroupVersion())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("the provided version %q has no relevant versions: %v", gvk.GroupVersion().String(), err)
|
||||
}
|
||||
|
||||
mappings = append(mappings, &RESTMapping{
|
||||
Resource: res.Resource,
|
||||
Resource: res,
|
||||
GroupVersionKind: gvk,
|
||||
Scope: scope,
|
||||
|
||||
ObjectConvertor: interfaces.ObjectConvertor,
|
||||
MetadataAccessor: interfaces.MetadataAccessor,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
95
vendor/k8s.io/apimachinery/pkg/api/meta/restmapper_test.go
generated
vendored
95
vendor/k8s.io/apimachinery/pkg/api/meta/restmapper_test.go
generated
vendored
@@ -17,42 +17,13 @@ limitations under the License.
|
||||
package meta
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
type fakeConvertor struct{}
|
||||
|
||||
func (fakeConvertor) Convert(in, out, context interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fakeConvertor) ConvertToVersion(in runtime.Object, _ runtime.GroupVersioner) (runtime.Object, error) {
|
||||
return in, nil
|
||||
}
|
||||
|
||||
func (fakeConvertor) ConvertFieldLabel(version, kind, label, value string) (string, string, error) {
|
||||
return label, value, nil
|
||||
}
|
||||
|
||||
var validAccessor = resourceAccessor{}
|
||||
var validConvertor = fakeConvertor{}
|
||||
|
||||
func fakeInterfaces(version schema.GroupVersion) (*VersionInterfaces, error) {
|
||||
return &VersionInterfaces{ObjectConvertor: validConvertor, MetadataAccessor: validAccessor}, nil
|
||||
}
|
||||
|
||||
var unmatchedErr = errors.New("no version")
|
||||
|
||||
func unmatchedVersionInterfaces(version schema.GroupVersion) (*VersionInterfaces, error) {
|
||||
return nil, unmatchedErr
|
||||
}
|
||||
|
||||
func TestRESTMapperVersionAndKindForResource(t *testing.T) {
|
||||
testGroup := "test.group"
|
||||
testVersion := "test"
|
||||
@@ -71,7 +42,7 @@ func TestRESTMapperVersionAndKindForResource(t *testing.T) {
|
||||
{Resource: schema.GroupVersionResource{Resource: "internalobjects"}, ExpectedGVK: testGroupVersion.WithKind("InternalObject")},
|
||||
}
|
||||
for i, testCase := range testCases {
|
||||
mapper := NewDefaultRESTMapper([]schema.GroupVersion{testGroupVersion}, fakeInterfaces)
|
||||
mapper := NewDefaultRESTMapper([]schema.GroupVersion{testGroupVersion})
|
||||
if len(testCase.ExpectedGVK.Kind) != 0 {
|
||||
mapper.Add(testCase.ExpectedGVK, RESTScopeNamespace)
|
||||
}
|
||||
@@ -104,7 +75,7 @@ func TestRESTMapperGroupForResource(t *testing.T) {
|
||||
{Resource: schema.GroupVersionResource{Resource: "myobje"}, Err: true, GroupVersionKind: schema.GroupVersionKind{Group: "testapi", Version: "test", Kind: "MyObject"}},
|
||||
}
|
||||
for i, testCase := range testCases {
|
||||
mapper := NewDefaultRESTMapper([]schema.GroupVersion{testCase.GroupVersionKind.GroupVersion()}, fakeInterfaces)
|
||||
mapper := NewDefaultRESTMapper([]schema.GroupVersion{testCase.GroupVersionKind.GroupVersion()})
|
||||
mapper.Add(testCase.GroupVersionKind, RESTScopeNamespace)
|
||||
|
||||
actualGVK, err := mapper.KindFor(testCase.Resource)
|
||||
@@ -249,7 +220,7 @@ func TestRESTMapperKindsFor(t *testing.T) {
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
tcName := testCase.Name
|
||||
mapper := NewDefaultRESTMapper(testCase.PreferredOrder, fakeInterfaces)
|
||||
mapper := NewDefaultRESTMapper(testCase.PreferredOrder)
|
||||
for _, kind := range testCase.KindsToRegister {
|
||||
mapper.Add(kind, RESTScopeNamespace)
|
||||
}
|
||||
@@ -426,7 +397,7 @@ func TestRESTMapperResourcesFor(t *testing.T) {
|
||||
tcName := testCase.Name
|
||||
|
||||
for _, partialResource := range []schema.GroupVersionResource{testCase.PluralPartialResourceToRequest, testCase.SingularPartialResourceToRequest} {
|
||||
mapper := NewDefaultRESTMapper(testCase.PreferredOrder, fakeInterfaces)
|
||||
mapper := NewDefaultRESTMapper(testCase.PreferredOrder)
|
||||
for _, kind := range testCase.KindsToRegister {
|
||||
mapper.Add(kind, RESTScopeNamespace)
|
||||
}
|
||||
@@ -511,7 +482,7 @@ func TestRESTMapperResourceSingularizer(t *testing.T) {
|
||||
{Kind: "lowercases", Plural: "lowercaseses", Singular: "lowercases"},
|
||||
}
|
||||
for i, testCase := range testCases {
|
||||
mapper := NewDefaultRESTMapper([]schema.GroupVersion{testGroupVersion}, fakeInterfaces)
|
||||
mapper := NewDefaultRESTMapper([]schema.GroupVersion{testGroupVersion})
|
||||
// create singular/plural mapping
|
||||
mapper.Add(testGroupVersion.WithKind(testCase.Kind), RESTScopeNamespace)
|
||||
|
||||
@@ -535,7 +506,7 @@ func TestRESTMapperRESTMapping(t *testing.T) {
|
||||
APIGroupVersions []schema.GroupVersion
|
||||
DefaultVersions []schema.GroupVersion
|
||||
|
||||
Resource string
|
||||
Resource schema.GroupVersionResource
|
||||
ExpectedGroupVersion *schema.GroupVersion
|
||||
Err bool
|
||||
}{
|
||||
@@ -544,19 +515,19 @@ func TestRESTMapperRESTMapping(t *testing.T) {
|
||||
|
||||
{DefaultVersions: []schema.GroupVersion{testGroupVersion}, Kind: "Unknown", Err: true},
|
||||
|
||||
{DefaultVersions: []schema.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []schema.GroupVersion{{Group: testGroup, Version: "test"}}, Resource: "internalobjects"},
|
||||
{DefaultVersions: []schema.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []schema.GroupVersion{{Group: testGroup, Version: "test"}}, Resource: "internalobjects"},
|
||||
{DefaultVersions: []schema.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []schema.GroupVersion{{Group: testGroup, Version: "test"}}, Resource: testGroupVersion.WithResource("internalobjects")},
|
||||
{DefaultVersions: []schema.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []schema.GroupVersion{{Group: testGroup, Version: "test"}}, Resource: testGroupVersion.WithResource("internalobjects")},
|
||||
|
||||
{DefaultVersions: []schema.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []schema.GroupVersion{{Group: testGroup, Version: "test"}}, Resource: "internalobjects"},
|
||||
{DefaultVersions: []schema.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []schema.GroupVersion{{Group: testGroup, Version: "test"}}, Resource: testGroupVersion.WithResource("internalobjects")},
|
||||
|
||||
{DefaultVersions: []schema.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []schema.GroupVersion{}, Resource: "internalobjects", ExpectedGroupVersion: &schema.GroupVersion{Group: testGroup, Version: "test"}},
|
||||
{DefaultVersions: []schema.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []schema.GroupVersion{}, Resource: internalGroupVersion.WithResource("internalobjects"), ExpectedGroupVersion: &schema.GroupVersion{Group: testGroup, Version: "test"}},
|
||||
|
||||
{DefaultVersions: []schema.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []schema.GroupVersion{{Group: testGroup, Version: "test"}}, Resource: "internalobjects"},
|
||||
{DefaultVersions: []schema.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []schema.GroupVersion{{Group: testGroup, Version: "test"}}, Resource: testGroupVersion.WithResource("internalobjects")},
|
||||
|
||||
// TODO: add test for a resource that exists in one version but not another
|
||||
}
|
||||
for i, testCase := range testCases {
|
||||
mapper := NewDefaultRESTMapper(testCase.DefaultVersions, fakeInterfaces)
|
||||
mapper := NewDefaultRESTMapper(testCase.DefaultVersions)
|
||||
mapper.Add(internalGroupVersion.WithKind("InternalObject"), RESTScopeNamespace)
|
||||
|
||||
preferredVersions := []string{}
|
||||
@@ -577,10 +548,6 @@ func TestRESTMapperRESTMapping(t *testing.T) {
|
||||
t.Errorf("%d: unexpected resource: %#v", i, mapping)
|
||||
}
|
||||
|
||||
if mapping.MetadataAccessor == nil || mapping.ObjectConvertor == nil {
|
||||
t.Errorf("%d: missing codec and accessor: %#v", i, mapping)
|
||||
}
|
||||
|
||||
groupVersion := testCase.ExpectedGroupVersion
|
||||
if groupVersion == nil {
|
||||
groupVersion = &testCase.APIGroupVersions[0]
|
||||
@@ -599,7 +566,7 @@ func TestRESTMapperRESTMappingSelectsVersion(t *testing.T) {
|
||||
internalObjectGK := schema.GroupKind{Group: "tgroup", Kind: "InternalObject"}
|
||||
otherObjectGK := schema.GroupKind{Group: "tgroup", Kind: "OtherObject"}
|
||||
|
||||
mapper := NewDefaultRESTMapper([]schema.GroupVersion{expectedGroupVersion1, expectedGroupVersion2}, fakeInterfaces)
|
||||
mapper := NewDefaultRESTMapper([]schema.GroupVersion{expectedGroupVersion1, expectedGroupVersion2})
|
||||
mapper.Add(expectedGroupVersion1.WithKind("InternalObject"), RESTScopeNamespace)
|
||||
mapper.Add(expectedGroupVersion2.WithKind("OtherObject"), RESTScopeNamespace)
|
||||
|
||||
@@ -608,7 +575,7 @@ func TestRESTMapperRESTMappingSelectsVersion(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if mapping.Resource != "otherobjects" || mapping.GroupVersionKind.GroupVersion() != expectedGroupVersion2 {
|
||||
if mapping.Resource != expectedGroupVersion2.WithResource("otherobjects") || mapping.GroupVersionKind.GroupVersion() != expectedGroupVersion2 {
|
||||
t.Errorf("unexpected mapping: %#v", mapping)
|
||||
}
|
||||
|
||||
@@ -616,7 +583,7 @@ func TestRESTMapperRESTMappingSelectsVersion(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if mapping.Resource != "internalobjects" || mapping.GroupVersionKind.GroupVersion() != expectedGroupVersion1 {
|
||||
if mapping.Resource != expectedGroupVersion1.WithResource("internalobjects") || mapping.GroupVersionKind.GroupVersion() != expectedGroupVersion1 {
|
||||
t.Errorf("unexpected mapping: %#v", mapping)
|
||||
}
|
||||
|
||||
@@ -646,7 +613,7 @@ func TestRESTMapperRESTMappingSelectsVersion(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if mapping.Resource != "otherobjects" || mapping.GroupVersionKind.GroupVersion() != expectedGroupVersion2 {
|
||||
if mapping.Resource != expectedGroupVersion2.WithResource("otherobjects") || mapping.GroupVersionKind.GroupVersion() != expectedGroupVersion2 {
|
||||
t.Errorf("unexpected mapping: %#v", mapping)
|
||||
}
|
||||
}
|
||||
@@ -678,7 +645,7 @@ func TestRESTMapperRESTMappings(t *testing.T) {
|
||||
Kind: "InternalObject",
|
||||
APIGroupVersions: []schema.GroupVersion{{Group: testGroup, Version: "v2"}},
|
||||
AddGroupVersionKind: []schema.GroupVersionKind{schema.GroupVersion{Group: testGroup, Version: "v2"}.WithKind("InternalObject")},
|
||||
ExpectedRESTMappings: []*RESTMapping{{Resource: "internalobjects", GroupVersionKind: schema.GroupVersionKind{Group: testGroup, Version: "v2", Kind: "InternalObject"}}},
|
||||
ExpectedRESTMappings: []*RESTMapping{{Resource: schema.GroupVersionResource{Group: testGroup, Version: "v2", Resource: "internalobjects"}, GroupVersionKind: schema.GroupVersionKind{Group: testGroup, Version: "v2", Kind: "InternalObject"}}},
|
||||
},
|
||||
|
||||
// ask for specific versions - only one available - check ExpectedRESTMappings
|
||||
@@ -687,20 +654,29 @@ func TestRESTMapperRESTMappings(t *testing.T) {
|
||||
Kind: "InternalObject",
|
||||
APIGroupVersions: []schema.GroupVersion{{Group: testGroup, Version: "v3"}, {Group: testGroup, Version: "v2"}},
|
||||
AddGroupVersionKind: []schema.GroupVersionKind{schema.GroupVersion{Group: testGroup, Version: "v2"}.WithKind("InternalObject")},
|
||||
ExpectedRESTMappings: []*RESTMapping{{Resource: "internalobjects", GroupVersionKind: schema.GroupVersionKind{Group: testGroup, Version: "v2", Kind: "InternalObject"}}},
|
||||
ExpectedRESTMappings: []*RESTMapping{{Resource: schema.GroupVersionResource{Group: testGroup, Version: "v2", Resource: "internalobjects"}, GroupVersionKind: schema.GroupVersionKind{Group: testGroup, Version: "v2", Kind: "InternalObject"}}},
|
||||
},
|
||||
|
||||
// do not ask for specific version - search through default versions - check ExpectedRESTMappings
|
||||
{
|
||||
DefaultVersions: []schema.GroupVersion{testGroupVersion, {Group: testGroup, Version: "v2"}},
|
||||
Kind: "InternalObject",
|
||||
AddGroupVersionKind: []schema.GroupVersionKind{schema.GroupVersion{Group: testGroup, Version: "v1"}.WithKind("InternalObject"), schema.GroupVersion{Group: testGroup, Version: "v2"}.WithKind("InternalObject")},
|
||||
ExpectedRESTMappings: []*RESTMapping{{Resource: "internalobjects", GroupVersionKind: schema.GroupVersionKind{Group: testGroup, Version: "v1", Kind: "InternalObject"}}, {Resource: "internalobjects", GroupVersionKind: schema.GroupVersionKind{Group: testGroup, Version: "v2", Kind: "InternalObject"}}},
|
||||
DefaultVersions: []schema.GroupVersion{testGroupVersion, {Group: testGroup, Version: "v2"}},
|
||||
Kind: "InternalObject",
|
||||
AddGroupVersionKind: []schema.GroupVersionKind{schema.GroupVersion{Group: testGroup, Version: "v1"}.WithKind("InternalObject"), schema.GroupVersion{Group: testGroup, Version: "v2"}.WithKind("InternalObject")},
|
||||
ExpectedRESTMappings: []*RESTMapping{
|
||||
{
|
||||
Resource: schema.GroupVersionResource{Group: testGroup, Version: "v1", Resource: "internalobjects"},
|
||||
GroupVersionKind: schema.GroupVersionKind{Group: testGroup, Version: "v1", Kind: "InternalObject"},
|
||||
},
|
||||
{
|
||||
Resource: schema.GroupVersionResource{Group: testGroup, Version: "v2", Resource: "internalobjects"},
|
||||
GroupVersionKind: schema.GroupVersionKind{Group: testGroup, Version: "v2", Kind: "InternalObject"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
mapper := NewDefaultRESTMapper(testCase.DefaultVersions, fakeInterfaces)
|
||||
mapper := NewDefaultRESTMapper(testCase.DefaultVersions)
|
||||
for _, gvk := range testCase.AddGroupVersionKind {
|
||||
mapper.Add(gvk, RESTScopeNamespace)
|
||||
}
|
||||
@@ -727,9 +703,6 @@ func TestRESTMapperRESTMappings(t *testing.T) {
|
||||
if mapping.Resource != exp.Resource {
|
||||
t.Errorf("%d - %d: unexpected resource: %#v", i, j, mapping)
|
||||
}
|
||||
if mapping.MetadataAccessor == nil || mapping.ObjectConvertor == nil {
|
||||
t.Errorf("%d - %d: missing codec and accessor: %#v", i, j, mapping)
|
||||
}
|
||||
if mapping.GroupVersionKind != exp.GroupVersionKind {
|
||||
t.Errorf("%d - %d: unexpected GroupVersionKind: %#v", i, j, mapping)
|
||||
}
|
||||
@@ -742,9 +715,9 @@ func TestRESTMapperReportsErrorOnBadVersion(t *testing.T) {
|
||||
expectedGroupVersion2 := schema.GroupVersion{Group: "tgroup", Version: "test2"}
|
||||
internalObjectGK := schema.GroupKind{Group: "tgroup", Kind: "InternalObject"}
|
||||
|
||||
mapper := NewDefaultRESTMapper([]schema.GroupVersion{expectedGroupVersion1, expectedGroupVersion2}, unmatchedVersionInterfaces)
|
||||
mapper := NewDefaultRESTMapper([]schema.GroupVersion{expectedGroupVersion1, expectedGroupVersion2})
|
||||
mapper.Add(expectedGroupVersion1.WithKind("InternalObject"), RESTScopeNamespace)
|
||||
_, err := mapper.RESTMapping(internalObjectGK, expectedGroupVersion1.Version)
|
||||
_, err := mapper.RESTMapping(internalObjectGK, "test3")
|
||||
if err == nil {
|
||||
t.Errorf("unexpected non-error")
|
||||
}
|
||||
|
||||
47
vendor/k8s.io/apimachinery/pkg/api/meta/unstructured.go
generated
vendored
47
vendor/k8s.io/apimachinery/pkg/api/meta/unstructured.go
generated
vendored
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
Copyright 2016 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 (
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"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. It will return errors for
|
||||
// other conversions.
|
||||
func InterfacesForUnstructured(schema.GroupVersion) (*VersionInterfaces, error) {
|
||||
return &VersionInterfaces{
|
||||
ObjectConvertor: &unstructured.UnstructuredObjectConverter{},
|
||||
MetadataAccessor: NewAccessor(),
|
||||
}, nil
|
||||
}
|
||||
69
vendor/k8s.io/apimachinery/pkg/api/resource/BUILD
generated
vendored
69
vendor/k8s.io/apimachinery/pkg/api/resource/BUILD
generated
vendored
@@ -1,69 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"amount_test.go",
|
||||
"math_test.go",
|
||||
"quantity_proto_test.go",
|
||||
"quantity_test.go",
|
||||
"scale_int_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/gopkg.in/inf.v0:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"amount.go",
|
||||
"generated.pb.go",
|
||||
"math.go",
|
||||
"quantity.go",
|
||||
"quantity_proto.go",
|
||||
"scale_int.go",
|
||||
"suffix.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/resource",
|
||||
deps = [
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/gopkg.in/inf.v0:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["quantity_example_test.go"],
|
||||
deps = ["//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "go_default_library_protos",
|
||||
srcs = ["generated.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
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 2018 The Kubernetes Authors.
|
||||
Copyright 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/api/resource/generated.proto
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto
generated
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
|
||||
42
vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
42
vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
@@ -25,8 +25,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
flag "github.com/spf13/pflag"
|
||||
|
||||
inf "gopkg.in/inf.v0"
|
||||
)
|
||||
|
||||
@@ -747,43 +745,3 @@ func (q *Quantity) Copy() *Quantity {
|
||||
Format: q.Format,
|
||||
}
|
||||
}
|
||||
|
||||
// qFlag is a helper type for the Flag function
|
||||
type qFlag struct {
|
||||
dest *Quantity
|
||||
}
|
||||
|
||||
// Sets the value of the internal Quantity. (used by flag & pflag)
|
||||
func (qf qFlag) Set(val string) error {
|
||||
q, err := ParseQuantity(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// This copy is OK because q will not be referenced again.
|
||||
*qf.dest = q
|
||||
return nil
|
||||
}
|
||||
|
||||
// Converts the value of the internal Quantity to a string. (used by flag & pflag)
|
||||
func (qf qFlag) String() string {
|
||||
return qf.dest.String()
|
||||
}
|
||||
|
||||
// States the type of flag this is (Quantity). (used by pflag)
|
||||
func (qf qFlag) Type() string {
|
||||
return "quantity"
|
||||
}
|
||||
|
||||
// QuantityFlag is a helper that makes a quantity flag (using standard flag package).
|
||||
// Will panic if defaultValue is not a valid quantity.
|
||||
func QuantityFlag(flagName, defaultValue, description string) *Quantity {
|
||||
q := MustParse(defaultValue)
|
||||
flag.Var(NewQuantityFlagValue(&q), flagName, description)
|
||||
return &q
|
||||
}
|
||||
|
||||
// NewQuantityFlagValue returns an object that can be used to back a flag,
|
||||
// pointing at the given Quantity variable.
|
||||
func NewQuantityFlagValue(q *Quantity) flag.Value {
|
||||
return qFlag{q}
|
||||
}
|
||||
|
||||
16
vendor/k8s.io/apimachinery/pkg/api/resource/quantity_test.go
generated
vendored
16
vendor/k8s.io/apimachinery/pkg/api/resource/quantity_test.go
generated
vendored
@@ -24,7 +24,6 @@ import (
|
||||
"unicode"
|
||||
|
||||
fuzz "github.com/google/gofuzz"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
inf "gopkg.in/inf.v0"
|
||||
)
|
||||
@@ -1059,21 +1058,6 @@ func TestCopy(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestQFlagSet(t *testing.T) {
|
||||
qf := qFlag{&Quantity{}}
|
||||
qf.Set("1Ki")
|
||||
if e, a := "1Ki", qf.String(); e != a {
|
||||
t.Errorf("Unexpected result %v != %v", e, a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestQFlagIsPFlag(t *testing.T) {
|
||||
var pfv pflag.Value = qFlag{}
|
||||
if e, a := "quantity", pfv.Type(); e != a {
|
||||
t.Errorf("Unexpected result %v != %v", e, a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSub(t *testing.T) {
|
||||
tests := []struct {
|
||||
a Quantity
|
||||
|
||||
2
vendor/k8s.io/apimachinery/pkg/api/resource/zz_generated.deepcopy.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/api/resource/zz_generated.deepcopy.go
generated
vendored
@@ -1,7 +1,7 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
|
||||
59
vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion/BUILD
generated
vendored
59
vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion/BUILD
generated
vendored
@@ -1,59 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"register_test.go",
|
||||
"roundtrip_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/testing/roundtrip:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/fuzzer:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"conversion.go",
|
||||
"doc.go",
|
||||
"register.go",
|
||||
"types.go",
|
||||
"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/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/labels: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/util/validation/field:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
2
vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion/zz_generated.conversion.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion/zz_generated.conversion.go
generated
vendored
@@ -1,7 +1,7 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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/internalversion/zz_generated.deepcopy.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion/zz_generated.deepcopy.go
generated
vendored
@@ -1,7 +1,7 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
|
||||
101
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/BUILD
generated
vendored
101
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/BUILD
generated
vendored
@@ -1,101 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"controller_ref_test.go",
|
||||
"duration_test.go",
|
||||
"group_version_test.go",
|
||||
"helpers_test.go",
|
||||
"labels_test.go",
|
||||
"micro_time_test.go",
|
||||
"time_test.go",
|
||||
"types_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/github.com/ghodss/yaml:go_default_library",
|
||||
"//vendor/github.com/json-iterator/go:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"controller_ref.go",
|
||||
"conversion.go",
|
||||
"doc.go",
|
||||
"duration.go",
|
||||
"generated.pb.go",
|
||||
"group_version.go",
|
||||
"helpers.go",
|
||||
"labels.go",
|
||||
"meta.go",
|
||||
"micro_time.go",
|
||||
"micro_time_proto.go",
|
||||
"register.go",
|
||||
"time.go",
|
||||
"time_proto.go",
|
||||
"types.go",
|
||||
"types_swagger_doc_generated.go",
|
||||
"watch.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
"zz_generated.defaults.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
deps = [
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
"//vendor/github.com/gogo/protobuf/sortkeys:go_default_library",
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/labels: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/selection:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/watch: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/apis/meta/v1/unstructured:all-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/validation:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "go_default_library_protos",
|
||||
srcs = ["generated.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["conversion_test.go"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
],
|
||||
)
|
||||
12
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/conversion.go
generated
vendored
12
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/conversion.go
generated
vendored
@@ -75,6 +75,8 @@ func AddConversionFuncs(scheme *runtime.Scheme) error {
|
||||
Convert_unversioned_LabelSelector_to_map,
|
||||
|
||||
Convert_Slice_string_To_Slice_int32,
|
||||
|
||||
Convert_Slice_string_To_v1_DeletionPropagation,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -304,3 +306,13 @@ func Convert_Slice_string_To_Slice_int32(in *[]string, out *[]int32, s conversio
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_Slice_string_To_v1_DeletionPropagation allows converting a URL query parameter propagationPolicy
|
||||
func Convert_Slice_string_To_v1_DeletionPropagation(input *[]string, out *DeletionPropagation, s conversion.Scope) error {
|
||||
if len(*input) > 0 {
|
||||
*out = DeletionPropagation((*input)[0])
|
||||
} else {
|
||||
*out = ""
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
35
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/conversion_test.go
generated
vendored
35
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/conversion_test.go
generated
vendored
@@ -47,3 +47,38 @@ func TestMapToLabelSelectorRoundTrip(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvertSliceStringToDeletionPropagation(t *testing.T) {
|
||||
tcs := []struct {
|
||||
Input []string
|
||||
Output v1.DeletionPropagation
|
||||
}{
|
||||
{
|
||||
Input: nil,
|
||||
Output: "",
|
||||
},
|
||||
{
|
||||
Input: []string{},
|
||||
Output: "",
|
||||
},
|
||||
{
|
||||
Input: []string{"foo"},
|
||||
Output: "foo",
|
||||
},
|
||||
{
|
||||
Input: []string{"bar", "foo"},
|
||||
Output: "bar",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tcs {
|
||||
var dp v1.DeletionPropagation
|
||||
if err := v1.Convert_Slice_string_To_v1_DeletionPropagation(&tc.Input, &dp, nil); err != nil {
|
||||
t.Errorf("Convert_Slice_string_To_v1_DeletionPropagation(%#v): %v", tc.Input, err)
|
||||
continue
|
||||
}
|
||||
if !apiequality.Semantic.DeepEqual(dp, tc.Output) {
|
||||
t.Errorf("slice string to DeletionPropagation conversion failed: got %v; want %v", dp, tc.Output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
5
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/duration.go
generated
vendored
5
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/duration.go
generated
vendored
@@ -31,7 +31,10 @@ type Duration struct {
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface.
|
||||
func (d *Duration) UnmarshalJSON(b []byte) error {
|
||||
var str string
|
||||
json.Unmarshal(b, &str)
|
||||
err := json.Unmarshal(b, &str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pd, err := time.ParseDuration(str)
|
||||
if err != nil {
|
||||
|
||||
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.pb.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.pb.go
generated
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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/apis/meta/v1/generated.proto
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto
generated
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
@@ -49,6 +49,7 @@ message APIGroup {
|
||||
// The server returns only those CIDRs that it thinks that the client can match.
|
||||
// For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP.
|
||||
// Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.
|
||||
// +optional
|
||||
repeated ServerAddressByClientCIDR serverAddressByClientCIDRs = 4;
|
||||
}
|
||||
|
||||
|
||||
5
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/group_version_test.go
generated
vendored
5
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/group_version_test.go
generated
vendored
@@ -21,7 +21,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
k8s_json "k8s.io/apimachinery/pkg/runtime/serializer/json"
|
||||
)
|
||||
|
||||
type GroupVersionHolder struct {
|
||||
@@ -47,7 +47,8 @@ func TestGroupVersionUnmarshalJSON(t *testing.T) {
|
||||
t.Errorf("JSON codec failed to unmarshal input '%s': expected %+v, got %+v", c.input, c.expect, result.GV)
|
||||
}
|
||||
// test the json-iterator codec
|
||||
if err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(c.input, &result); err != nil {
|
||||
iter := k8s_json.CaseSensitiveJsonIterator()
|
||||
if err := iter.Unmarshal(c.input, &result); err != nil {
|
||||
t.Errorf("json-iterator codec failed to unmarshal input '%v': %v", c.input, err)
|
||||
}
|
||||
if !reflect.DeepEqual(result.GV, c.expect) {
|
||||
|
||||
5
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go
generated
vendored
5
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go
generated
vendored
@@ -104,7 +104,10 @@ func (t *MicroTime) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
|
||||
var str string
|
||||
json.Unmarshal(b, &str)
|
||||
err := json.Unmarshal(b, &str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pt, err := time.Parse(RFC3339Micro, str)
|
||||
if err != nil {
|
||||
|
||||
5
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
generated
vendored
5
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
generated
vendored
@@ -106,7 +106,10 @@ func (t *Time) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
|
||||
var str string
|
||||
json.Unmarshal(b, &str)
|
||||
err := json.Unmarshal(b, &str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pt, err := time.Parse(time.RFC3339, str)
|
||||
if err != nil {
|
||||
|
||||
3
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types.go
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types.go
generated
vendored
@@ -799,7 +799,8 @@ type APIGroup struct {
|
||||
// The server returns only those CIDRs that it thinks that the client can match.
|
||||
// For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP.
|
||||
// Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.
|
||||
ServerAddressByClientCIDRs []ServerAddressByClientCIDR `json:"serverAddressByClientCIDRs" protobuf:"bytes,4,rep,name=serverAddressByClientCIDRs"`
|
||||
// +optional
|
||||
ServerAddressByClientCIDRs []ServerAddressByClientCIDR `json:"serverAddressByClientCIDRs,omitempty" protobuf:"bytes,4,rep,name=serverAddressByClientCIDRs"`
|
||||
}
|
||||
|
||||
// ServerAddressByClientCIDR helps the client to determine the server address that they should use, depending on the clientCIDR that they match.
|
||||
|
||||
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
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
@@ -26,7 +26,7 @@ package v1
|
||||
//
|
||||
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
|
||||
|
||||
// AUTO-GENERATED FUNCTIONS START HERE
|
||||
// AUTO-GENERATED FUNCTIONS START HERE. DO NOT EDIT.
|
||||
var map_APIGroup = map[string]string{
|
||||
"": "APIGroup contains the name, the supported versions, and the preferred version of a group.",
|
||||
"name": "name is the name of the group.",
|
||||
|
||||
7
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types_test.go
generated
vendored
7
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types_test.go
generated
vendored
@@ -21,7 +21,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
k8s_json "k8s.io/apimachinery/pkg/runtime/serializer/json"
|
||||
)
|
||||
|
||||
func TestVerbsUgorjiMarshalJSON(t *testing.T) {
|
||||
@@ -45,7 +45,7 @@ func TestVerbsUgorjiMarshalJSON(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestVerbsUgorjiUnmarshalJSON(t *testing.T) {
|
||||
func TestVerbsUJsonIterUnmarshalJSON(t *testing.T) {
|
||||
cases := []struct {
|
||||
input string
|
||||
result APIResource
|
||||
@@ -56,9 +56,10 @@ func TestVerbsUgorjiUnmarshalJSON(t *testing.T) {
|
||||
{`{"verbs":["delete"]}`, APIResource{Verbs: Verbs([]string{"delete"})}},
|
||||
}
|
||||
|
||||
iter := k8s_json.CaseSensitiveJsonIterator()
|
||||
for i, c := range cases {
|
||||
var result APIResource
|
||||
if err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(c.input), &result); err != nil {
|
||||
if err := iter.Unmarshal([]byte(c.input), &result); err != nil {
|
||||
t.Errorf("[%d] Failed to unmarshal input '%v': %v", i, c.input, err)
|
||||
}
|
||||
if !reflect.DeepEqual(result, c.result) {
|
||||
|
||||
53
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/BUILD
generated
vendored
53
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/BUILD
generated
vendored
@@ -1,53 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"helpers_test.go",
|
||||
"unstructured_list_test.go",
|
||||
],
|
||||
embed = [":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/k8s.io/apimachinery/pkg/apis/meta/v1: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",
|
||||
"//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"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
66
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/helpers.go
generated
vendored
66
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/helpers.go
generated
vendored
@@ -18,7 +18,6 @@ package unstructured
|
||||
|
||||
import (
|
||||
gojson "encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
@@ -34,14 +33,17 @@ import (
|
||||
// Returns false if the value is missing.
|
||||
// No error is returned for a nil field.
|
||||
func NestedFieldCopy(obj map[string]interface{}, fields ...string) (interface{}, bool, error) {
|
||||
val, found, err := nestedFieldNoCopy(obj, fields...)
|
||||
val, found, err := NestedFieldNoCopy(obj, fields...)
|
||||
if !found || err != nil {
|
||||
return nil, found, err
|
||||
}
|
||||
return runtime.DeepCopyJSONValue(val), true, nil
|
||||
}
|
||||
|
||||
func nestedFieldNoCopy(obj map[string]interface{}, fields ...string) (interface{}, bool, error) {
|
||||
// NestedFieldNoCopy returns a reference to a nested field.
|
||||
// Returns false if value is not found and an error if unable
|
||||
// to traverse obj.
|
||||
func NestedFieldNoCopy(obj map[string]interface{}, fields ...string) (interface{}, bool, error) {
|
||||
var val interface{} = obj
|
||||
|
||||
for i, field := range fields {
|
||||
@@ -60,7 +62,7 @@ func nestedFieldNoCopy(obj map[string]interface{}, fields ...string) (interface{
|
||||
// NestedString returns the string value of a nested field.
|
||||
// Returns false if value is not found and an error if not a string.
|
||||
func NestedString(obj map[string]interface{}, fields ...string) (string, bool, error) {
|
||||
val, found, err := nestedFieldNoCopy(obj, fields...)
|
||||
val, found, err := NestedFieldNoCopy(obj, fields...)
|
||||
if !found || err != nil {
|
||||
return "", found, err
|
||||
}
|
||||
@@ -74,7 +76,7 @@ func NestedString(obj map[string]interface{}, fields ...string) (string, bool, e
|
||||
// NestedBool returns the bool value of a nested field.
|
||||
// Returns false if value is not found and an error if not a bool.
|
||||
func NestedBool(obj map[string]interface{}, fields ...string) (bool, bool, error) {
|
||||
val, found, err := nestedFieldNoCopy(obj, fields...)
|
||||
val, found, err := NestedFieldNoCopy(obj, fields...)
|
||||
if !found || err != nil {
|
||||
return false, found, err
|
||||
}
|
||||
@@ -88,7 +90,7 @@ func NestedBool(obj map[string]interface{}, fields ...string) (bool, bool, error
|
||||
// NestedFloat64 returns the float64 value of a nested field.
|
||||
// Returns false if value is not found and an error if not a float64.
|
||||
func NestedFloat64(obj map[string]interface{}, fields ...string) (float64, bool, error) {
|
||||
val, found, err := nestedFieldNoCopy(obj, fields...)
|
||||
val, found, err := NestedFieldNoCopy(obj, fields...)
|
||||
if !found || err != nil {
|
||||
return 0, found, err
|
||||
}
|
||||
@@ -102,7 +104,7 @@ func NestedFloat64(obj map[string]interface{}, fields ...string) (float64, bool,
|
||||
// NestedInt64 returns the int64 value of a nested field.
|
||||
// Returns false if value is not found and an error if not an int64.
|
||||
func NestedInt64(obj map[string]interface{}, fields ...string) (int64, bool, error) {
|
||||
val, found, err := nestedFieldNoCopy(obj, fields...)
|
||||
val, found, err := NestedFieldNoCopy(obj, fields...)
|
||||
if !found || err != nil {
|
||||
return 0, found, err
|
||||
}
|
||||
@@ -116,7 +118,7 @@ func NestedInt64(obj map[string]interface{}, fields ...string) (int64, bool, err
|
||||
// NestedStringSlice returns a copy of []string value of a nested field.
|
||||
// Returns false if value is not found and an error if not a []interface{} or contains non-string items in the slice.
|
||||
func NestedStringSlice(obj map[string]interface{}, fields ...string) ([]string, bool, error) {
|
||||
val, found, err := nestedFieldNoCopy(obj, fields...)
|
||||
val, found, err := NestedFieldNoCopy(obj, fields...)
|
||||
if !found || err != nil {
|
||||
return nil, found, err
|
||||
}
|
||||
@@ -138,7 +140,7 @@ func NestedStringSlice(obj map[string]interface{}, fields ...string) ([]string,
|
||||
// NestedSlice returns a deep copy of []interface{} value of a nested field.
|
||||
// Returns false if value is not found and an error if not a []interface{}.
|
||||
func NestedSlice(obj map[string]interface{}, fields ...string) ([]interface{}, bool, error) {
|
||||
val, found, err := nestedFieldNoCopy(obj, fields...)
|
||||
val, found, err := NestedFieldNoCopy(obj, fields...)
|
||||
if !found || err != nil {
|
||||
return nil, found, err
|
||||
}
|
||||
@@ -180,7 +182,7 @@ func NestedMap(obj map[string]interface{}, fields ...string) (map[string]interfa
|
||||
// nestedMapNoCopy returns a map[string]interface{} value of a nested field.
|
||||
// Returns false if value is not found and an error if not a map[string]interface{}.
|
||||
func nestedMapNoCopy(obj map[string]interface{}, fields ...string) (map[string]interface{}, bool, error) {
|
||||
val, found, err := nestedFieldNoCopy(obj, fields...)
|
||||
val, found, err := NestedFieldNoCopy(obj, fields...)
|
||||
if !found || err != nil {
|
||||
return nil, found, err
|
||||
}
|
||||
@@ -433,43 +435,17 @@ func (s unstructuredJSONScheme) decodeToList(data []byte, list *UnstructuredList
|
||||
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
|
||||
type JSONFallbackEncoder struct {
|
||||
runtime.Encoder
|
||||
}
|
||||
|
||||
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)
|
||||
func (c JSONFallbackEncoder) Encode(obj runtime.Object, w io.Writer) error {
|
||||
err := c.Encoder.Encode(obj, w)
|
||||
if runtime.IsNotRegisteredError(err) {
|
||||
switch obj.(type) {
|
||||
case *Unstructured, *UnstructuredList:
|
||||
return UnstructuredJSONScheme.Encode(obj, w)
|
||||
}
|
||||
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")
|
||||
return err
|
||||
}
|
||||
|
||||
76
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/helpers_test.go
generated
vendored
76
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/helpers_test.go
generated
vendored
@@ -58,3 +58,79 @@ func TestRemoveNestedField(t *testing.T) {
|
||||
RemoveNestedField(obj, "x") // Remove of a non-existent field
|
||||
assert.Empty(t, obj)
|
||||
}
|
||||
|
||||
func TestNestedFieldNoCopy(t *testing.T) {
|
||||
target := map[string]interface{}{"foo": "bar"}
|
||||
|
||||
obj := map[string]interface{}{
|
||||
"a": map[string]interface{}{
|
||||
"b": target,
|
||||
"c": nil,
|
||||
"d": []interface{}{"foo"},
|
||||
},
|
||||
}
|
||||
|
||||
// case 1: field exists and is non-nil
|
||||
res, exists, err := NestedFieldNoCopy(obj, "a", "b")
|
||||
assert.True(t, exists)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, target, res)
|
||||
target["foo"] = "baz"
|
||||
assert.Equal(t, target["foo"], res.(map[string]interface{})["foo"], "result should be a reference to the expected item")
|
||||
|
||||
// case 2: field exists and is nil
|
||||
res, exists, err = NestedFieldNoCopy(obj, "a", "c")
|
||||
assert.True(t, exists)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, res)
|
||||
|
||||
// case 3: error traversing obj
|
||||
res, exists, err = NestedFieldNoCopy(obj, "a", "d", "foo")
|
||||
assert.False(t, exists)
|
||||
assert.NotNil(t, err)
|
||||
assert.Nil(t, res)
|
||||
|
||||
// case 4: field does not exist
|
||||
res, exists, err = NestedFieldNoCopy(obj, "a", "e")
|
||||
assert.False(t, exists)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, res)
|
||||
}
|
||||
|
||||
func TestNestedFieldCopy(t *testing.T) {
|
||||
target := map[string]interface{}{"foo": "bar"}
|
||||
|
||||
obj := map[string]interface{}{
|
||||
"a": map[string]interface{}{
|
||||
"b": target,
|
||||
"c": nil,
|
||||
"d": []interface{}{"foo"},
|
||||
},
|
||||
}
|
||||
|
||||
// case 1: field exists and is non-nil
|
||||
res, exists, err := NestedFieldCopy(obj, "a", "b")
|
||||
assert.True(t, exists)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, target, res)
|
||||
target["foo"] = "baz"
|
||||
assert.NotEqual(t, target["foo"], res.(map[string]interface{})["foo"], "result should be a copy of the expected item")
|
||||
|
||||
// case 2: field exists and is nil
|
||||
res, exists, err = NestedFieldCopy(obj, "a", "c")
|
||||
assert.True(t, exists)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, res)
|
||||
|
||||
// case 3: error traversing obj
|
||||
res, exists, err = NestedFieldCopy(obj, "a", "d", "foo")
|
||||
assert.False(t, exists)
|
||||
assert.NotNil(t, err)
|
||||
assert.Nil(t, res)
|
||||
|
||||
// case 4: field does not exist
|
||||
res, exists, err = NestedFieldCopy(obj, "a", "e")
|
||||
assert.False(t, exists)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, res)
|
||||
}
|
||||
|
||||
24
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go
generated
vendored
24
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go
generated
vendored
@@ -58,6 +58,26 @@ func (obj *Unstructured) IsList() bool {
|
||||
_, ok = field.([]interface{})
|
||||
return ok
|
||||
}
|
||||
func (obj *Unstructured) ToList() (*UnstructuredList, error) {
|
||||
if !obj.IsList() {
|
||||
// return an empty list back
|
||||
return &UnstructuredList{Object: obj.Object}, nil
|
||||
}
|
||||
|
||||
ret := &UnstructuredList{}
|
||||
ret.Object = obj.Object
|
||||
|
||||
err := obj.EachListItem(func(item runtime.Object) error {
|
||||
castItem := item.(*Unstructured)
|
||||
ret.Items = append(ret.Items, *castItem)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (obj *Unstructured) EachListItem(fn func(runtime.Object) error) error {
|
||||
field, ok := obj.Object["items"]
|
||||
@@ -82,7 +102,7 @@ func (obj *Unstructured) EachListItem(fn func(runtime.Object) error) error {
|
||||
|
||||
func (obj *Unstructured) UnstructuredContent() map[string]interface{} {
|
||||
if obj.Object == nil {
|
||||
obj.Object = make(map[string]interface{})
|
||||
return make(map[string]interface{})
|
||||
}
|
||||
return obj.Object
|
||||
}
|
||||
@@ -138,7 +158,7 @@ func (u *Unstructured) setNestedMap(value map[string]string, fields ...string) {
|
||||
}
|
||||
|
||||
func (u *Unstructured) GetOwnerReferences() []metav1.OwnerReference {
|
||||
field, found, err := nestedFieldNoCopy(u.Object, "metadata", "ownerReferences")
|
||||
field, found, err := NestedFieldNoCopy(u.Object, "metadata", "ownerReferences")
|
||||
if !found || err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
17
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_list.go
generated
vendored
17
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_list.go
generated
vendored
@@ -53,19 +53,18 @@ func (u *UnstructuredList) EachListItem(fn func(runtime.Object) error) error {
|
||||
}
|
||||
|
||||
// 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.
|
||||
// the Object field. Items always overwrites overlay.
|
||||
func (u *UnstructuredList) UnstructuredContent() map[string]interface{} {
|
||||
out := u.Object
|
||||
if out == nil {
|
||||
out = make(map[string]interface{})
|
||||
out := make(map[string]interface{}, len(u.Object)+1)
|
||||
|
||||
// shallow copy every property
|
||||
for k, v := range u.Object {
|
||||
out[k] = v
|
||||
}
|
||||
|
||||
items := make([]interface{}, len(u.Items))
|
||||
for i, item := range u.Items {
|
||||
items[i] = item.Object
|
||||
items[i] = item.UnstructuredContent()
|
||||
}
|
||||
out["items"] = items
|
||||
return out
|
||||
|
||||
32
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_test.go
generated
vendored
Normal file
32
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_test.go
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package unstructured
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNilUnstructuredContent(t *testing.T) {
|
||||
var u Unstructured
|
||||
uCopy := u.DeepCopy()
|
||||
content := u.UnstructuredContent()
|
||||
expContent := make(map[string]interface{})
|
||||
assert.EqualValues(t, expContent, content)
|
||||
assert.Equal(t, uCopy, &u)
|
||||
}
|
||||
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/zz_generated.deepcopy.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/zz_generated.deepcopy.go
generated
vendored
@@ -1,7 +1,7 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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/v1/zz_generated.deepcopy.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/zz_generated.deepcopy.go
generated
vendored
@@ -1,7 +1,7 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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/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 2018 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
|
||||
45
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/BUILD
generated
vendored
45
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/BUILD
generated
vendored
@@ -1,45 +0,0 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
filegroup(
|
||||
name = "go_default_library_protos",
|
||||
srcs = ["generated.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"conversion.go",
|
||||
"deepcopy.go",
|
||||
"doc.go",
|
||||
"generated.pb.go",
|
||||
"register.go",
|
||||
"types.go",
|
||||
"types_swagger_doc_generated.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
"zz_generated.defaults.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/gogo/protobuf/proto: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/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
23
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/deepcopy.go
generated
vendored
23
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/deepcopy.go
generated
vendored
@@ -16,6 +16,8 @@ limitations under the License.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import "k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
func (in *TableRow) DeepCopy() *TableRow {
|
||||
if in == nil {
|
||||
return nil
|
||||
@@ -26,7 +28,7 @@ func (in *TableRow) DeepCopy() *TableRow {
|
||||
if in.Cells != nil {
|
||||
out.Cells = make([]interface{}, len(in.Cells))
|
||||
for i := range in.Cells {
|
||||
out.Cells[i] = deepCopyJSON(in.Cells[i])
|
||||
out.Cells[i] = runtime.DeepCopyJSONValue(in.Cells[i])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,22 +42,3 @@ func (in *TableRow) DeepCopy() *TableRow {
|
||||
in.Object.DeepCopyInto(&out.Object)
|
||||
return out
|
||||
}
|
||||
|
||||
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:
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/generated.pb.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/generated.pb.go
generated
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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/v1beta1/generated.proto
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/generated.proto
generated
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
|
||||
4
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/types.go
generated
vendored
4
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/types.go
generated
vendored
@@ -66,8 +66,8 @@ type TableColumnDefinition struct {
|
||||
// TableRow is an individual row in a table.
|
||||
// +protobuf=false
|
||||
type TableRow struct {
|
||||
// cells will be as wide as headers and may contain strings, numbers, booleans, simple maps, or lists, or
|
||||
// null. See the type field of the column definition for a more detailed description.
|
||||
// cells will be as wide as headers and may contain strings, numbers (float64 or int64), booleans, simple
|
||||
// maps, or lists, or null. See the type field of the column definition for a more detailed description.
|
||||
Cells []interface{} `json:"cells"`
|
||||
// conditions describe additional status of a row that are relevant for a human user.
|
||||
// +optional
|
||||
|
||||
6
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/types_swagger_doc_generated.go
generated
vendored
6
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/types_swagger_doc_generated.go
generated
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
@@ -26,7 +26,7 @@ package v1beta1
|
||||
//
|
||||
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
|
||||
|
||||
// AUTO-GENERATED FUNCTIONS START HERE
|
||||
// AUTO-GENERATED FUNCTIONS START HERE. DO NOT EDIT.
|
||||
var map_PartialObjectMetadata = map[string]string{
|
||||
"": "PartialObjectMetadata is a generic representation of any object with ObjectMeta. It allows clients to get access to a particular ObjectMeta schema without knowing the details of the version.",
|
||||
"metadata": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata",
|
||||
@@ -80,7 +80,7 @@ func (TableOptions) SwaggerDoc() map[string]string {
|
||||
|
||||
var map_TableRow = map[string]string{
|
||||
"": "TableRow is an individual row in a table.",
|
||||
"cells": "cells will be as wide as headers and may contain strings, numbers, booleans, simple maps, or lists, or null. See the type field of the column definition for a more detailed description.",
|
||||
"cells": "cells will be as wide as headers and may contain strings, numbers (float64 or int64), booleans, simple maps, or lists, or null. See the type field of the column definition for a more detailed description.",
|
||||
"conditions": "conditions describe additional status of a row that are relevant for a human user.",
|
||||
"object": "This field contains the requested additional information about each object based on the includeObject policy when requesting the Table. If \"None\", this field is empty, if \"Object\" this will be the default serialization of the object for the current API version, and if \"Metadata\" (the default) will contain the object metadata. Check the returned kind and apiVersion of the object before parsing.",
|
||||
}
|
||||
|
||||
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/zz_generated.deepcopy.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/zz_generated.deepcopy.go
generated
vendored
@@ -1,7 +1,7 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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/v1beta1/zz_generated.defaults.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/zz_generated.defaults.go
generated
vendored
@@ -1,7 +1,7 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
|
||||
49
vendor/k8s.io/apimachinery/pkg/conversion/BUILD
generated
vendored
49
vendor/k8s.io/apimachinery/pkg/conversion/BUILD
generated
vendored
@@ -1,49 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"converter_test.go",
|
||||
"helper_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"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"],
|
||||
)
|
||||
|
||||
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/queryparams:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
39
vendor/k8s.io/apimachinery/pkg/conversion/queryparams/BUILD
generated
vendored
39
vendor/k8s.io/apimachinery/pkg/conversion/queryparams/BUILD
generated
vendored
@@ -1,39 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"convert.go",
|
||||
"doc.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/conversion/queryparams",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["convert_test.go"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion/queryparams:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
3
vendor/k8s.io/apimachinery/pkg/conversion/queryparams/convert.go
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/conversion/queryparams/convert.go
generated
vendored
@@ -174,6 +174,9 @@ func convertStruct(result url.Values, st reflect.Type, sv reflect.Value) {
|
||||
kind = ft.Kind()
|
||||
if !field.IsNil() {
|
||||
field = reflect.Indirect(field)
|
||||
// If the field is non-nil, it should be added to params
|
||||
// and the omitempty should be overwite to false
|
||||
omitempty = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
6
vendor/k8s.io/apimachinery/pkg/conversion/queryparams/convert_test.go
generated
vendored
6
vendor/k8s.io/apimachinery/pkg/conversion/queryparams/convert_test.go
generated
vendored
@@ -70,6 +70,7 @@ type childStructs struct {
|
||||
Follow bool `json:"follow,omitempty"`
|
||||
Previous bool `json:"previous,omitempty"`
|
||||
SinceSeconds *int64 `json:"sinceSeconds,omitempty"`
|
||||
TailLines *int64 `json:"tailLines,omitempty"`
|
||||
SinceTime *metav1.Time `json:"sinceTime,omitempty"`
|
||||
EmptyTime *metav1.Time `json:"emptyTime"`
|
||||
NonPointerTime metav1.Time `json:"nonPointerTime"`
|
||||
@@ -99,6 +100,7 @@ func validateResult(t *testing.T, input interface{}, actual, expected url.Values
|
||||
|
||||
func TestConvert(t *testing.T) {
|
||||
sinceSeconds := int64(123)
|
||||
tailLines := int64(0)
|
||||
sinceTime := metav1.Date(2000, 1, 1, 12, 34, 56, 0, time.UTC)
|
||||
|
||||
tests := []struct {
|
||||
@@ -182,6 +184,7 @@ func TestConvert(t *testing.T) {
|
||||
Follow: true,
|
||||
Previous: true,
|
||||
SinceSeconds: &sinceSeconds,
|
||||
TailLines: nil,
|
||||
SinceTime: &sinceTime, // test a custom marshaller
|
||||
EmptyTime: nil, // test a nil custom marshaller without omitempty
|
||||
NonPointerTime: sinceTime,
|
||||
@@ -194,10 +197,11 @@ func TestConvert(t *testing.T) {
|
||||
Follow: true,
|
||||
Previous: true,
|
||||
SinceSeconds: &sinceSeconds,
|
||||
TailLines: &tailLines,
|
||||
SinceTime: nil, // test a nil custom marshaller with omitempty
|
||||
NonPointerTime: sinceTime,
|
||||
},
|
||||
expected: url.Values{"container": {"mycontainer"}, "follow": {"true"}, "previous": {"true"}, "sinceSeconds": {"123"}, "emptyTime": {""}, "nonPointerTime": {"2000-01-01T12:34:56Z"}},
|
||||
expected: url.Values{"container": {"mycontainer"}, "follow": {"true"}, "previous": {"true"}, "sinceSeconds": {"123"}, "tailLines": {"0"}, "emptyTime": {""}, "nonPointerTime": {"2000-01-01T12:34:56Z"}},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
41
vendor/k8s.io/apimachinery/pkg/fields/BUILD
generated
vendored
41
vendor/k8s.io/apimachinery/pkg/fields/BUILD
generated
vendored
@@ -1,41 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"fields_test.go",
|
||||
"selector_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"fields.go",
|
||||
"requirements.go",
|
||||
"selector.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/fields",
|
||||
deps = ["//vendor/k8s.io/apimachinery/pkg/selection:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
21
vendor/k8s.io/apimachinery/pkg/fields/selector.go
generated
vendored
21
vendor/k8s.io/apimachinery/pkg/fields/selector.go
generated
vendored
@@ -55,6 +55,21 @@ type Selector interface {
|
||||
DeepCopySelector() Selector
|
||||
}
|
||||
|
||||
type nothingSelector struct{}
|
||||
|
||||
func (n nothingSelector) Matches(_ Fields) bool { return false }
|
||||
func (n nothingSelector) Empty() bool { return false }
|
||||
func (n nothingSelector) String() string { return "" }
|
||||
func (n nothingSelector) Requirements() Requirements { return nil }
|
||||
func (n nothingSelector) DeepCopySelector() Selector { return n }
|
||||
func (n nothingSelector) RequiresExactMatch(field string) (value string, found bool) { return "", false }
|
||||
func (n nothingSelector) Transform(fn TransformFunc) (Selector, error) { return n, nil }
|
||||
|
||||
// Nothing returns a selector that matches no fields
|
||||
func Nothing() Selector {
|
||||
return nothingSelector{}
|
||||
}
|
||||
|
||||
// Everything returns a selector that matches all fields.
|
||||
func Everything() Selector {
|
||||
return andTerm{}
|
||||
@@ -449,6 +464,12 @@ func OneTermEqualSelector(k, v string) Selector {
|
||||
return &hasTerm{field: k, value: v}
|
||||
}
|
||||
|
||||
// OneTermNotEqualSelector returns an object that matches objects where one field/field does not equal one value.
|
||||
// Cannot return an error.
|
||||
func OneTermNotEqualSelector(k, v string) Selector {
|
||||
return ¬HasTerm{field: k, value: v}
|
||||
}
|
||||
|
||||
// AndSelectors creates a selector that is the logical AND of all the given selectors
|
||||
func AndSelectors(selectors ...Selector) Selector {
|
||||
return andTerm(selectors)
|
||||
|
||||
50
vendor/k8s.io/apimachinery/pkg/labels/BUILD
generated
vendored
50
vendor/k8s.io/apimachinery/pkg/labels/BUILD
generated
vendored
@@ -1,50 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"labels_test.go",
|
||||
"selector_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/selection:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"labels.go",
|
||||
"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/selection:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/validation:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
2
vendor/k8s.io/apimachinery/pkg/labels/zz_generated.deepcopy.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/labels/zz_generated.deepcopy.go
generated
vendored
@@ -1,7 +1,7 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
|
||||
98
vendor/k8s.io/apimachinery/pkg/runtime/BUILD
generated
vendored
98
vendor/k8s.io/apimachinery/pkg/runtime/BUILD
generated
vendored
@@ -1,98 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["swagger_doc_generator_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"codec.go",
|
||||
"codec_check.go",
|
||||
"conversion.go",
|
||||
"converter.go",
|
||||
"doc.go",
|
||||
"embedded.go",
|
||||
"error.go",
|
||||
"extension.go",
|
||||
"generated.pb.go",
|
||||
"helper.go",
|
||||
"interfaces.go",
|
||||
"register.go",
|
||||
"scheme.go",
|
||||
"scheme_builder.go",
|
||||
"swagger_doc_generator.go",
|
||||
"types.go",
|
||||
"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",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = [
|
||||
"conversion_test.go",
|
||||
"converter_test.go",
|
||||
"embedded_test.go",
|
||||
"extension_test.go",
|
||||
"scheme_test.go",
|
||||
],
|
||||
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",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:all-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer:all-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/testing:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "go_default_library_protos",
|
||||
srcs = ["generated.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
28
vendor/k8s.io/apimachinery/pkg/runtime/converter.go
generated
vendored
28
vendor/k8s.io/apimachinery/pkg/runtime/converter.go
generated
vendored
@@ -73,7 +73,6 @@ var (
|
||||
mapStringInterfaceType = reflect.TypeOf(map[string]interface{}{})
|
||||
stringType = reflect.TypeOf(string(""))
|
||||
int64Type = reflect.TypeOf(int64(0))
|
||||
uint64Type = reflect.TypeOf(uint64(0))
|
||||
float64Type = reflect.TypeOf(float64(0))
|
||||
boolType = reflect.TypeOf(bool(false))
|
||||
fieldCache = newFieldsCache()
|
||||
@@ -411,8 +410,7 @@ func (c *unstructuredConverter) ToUnstructured(obj interface{}) (map[string]inte
|
||||
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()
|
||||
u = unstr.UnstructuredContent()
|
||||
} else {
|
||||
t := reflect.TypeOf(obj)
|
||||
value := reflect.ValueOf(obj)
|
||||
@@ -439,22 +437,32 @@ func (c *unstructuredConverter) ToUnstructured(obj interface{}) (map[string]inte
|
||||
}
|
||||
|
||||
// DeepCopyJSON deep copies the passed value, assuming it is a valid JSON representation i.e. only contains
|
||||
// types produced by json.Unmarshal().
|
||||
// types produced by json.Unmarshal() and also int64.
|
||||
// bool, int64, float64, string, []interface{}, map[string]interface{}, json.Number and nil
|
||||
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().
|
||||
// types produced by json.Unmarshal() and also int64.
|
||||
// bool, int64, float64, string, []interface{}, map[string]interface{}, json.Number and nil
|
||||
func DeepCopyJSONValue(x interface{}) interface{} {
|
||||
switch x := x.(type) {
|
||||
case map[string]interface{}:
|
||||
if x == nil {
|
||||
// Typed nil - an interface{} that contains a type map[string]interface{} with a value of nil
|
||||
return x
|
||||
}
|
||||
clone := make(map[string]interface{}, len(x))
|
||||
for k, v := range x {
|
||||
clone[k] = DeepCopyJSONValue(v)
|
||||
}
|
||||
return clone
|
||||
case []interface{}:
|
||||
if x == nil {
|
||||
// Typed nil - an interface{} that contains a type []interface{} with a value of nil
|
||||
return x
|
||||
}
|
||||
clone := make([]interface{}, len(x))
|
||||
for i, v := range x {
|
||||
clone[i] = DeepCopyJSONValue(v)
|
||||
@@ -584,10 +592,14 @@ func toUnstructured(sv, dv reflect.Value) error {
|
||||
dv.Set(reflect.ValueOf(sv.Int()))
|
||||
return nil
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
if dt.Kind() == reflect.Interface && dv.NumMethod() == 0 {
|
||||
dv.Set(reflect.New(uint64Type))
|
||||
uVal := sv.Uint()
|
||||
if uVal > math.MaxInt64 {
|
||||
return fmt.Errorf("unsigned value %d does not fit into int64 (overflow)", uVal)
|
||||
}
|
||||
dv.Set(reflect.ValueOf(sv.Uint()))
|
||||
if dt.Kind() == reflect.Interface && dv.NumMethod() == 0 {
|
||||
dv.Set(reflect.New(int64Type))
|
||||
}
|
||||
dv.Set(reflect.ValueOf(int64(uVal)))
|
||||
return nil
|
||||
case reflect.Float32, reflect.Float64:
|
||||
if dt.Kind() == reflect.Interface && dv.NumMethod() == 0 {
|
||||
|
||||
8
vendor/k8s.io/apimachinery/pkg/runtime/error.go
generated
vendored
8
vendor/k8s.io/apimachinery/pkg/runtime/error.go
generated
vendored
@@ -41,10 +41,18 @@ func NewNotRegisteredErrForTarget(t reflect.Type, target GroupVersioner) error {
|
||||
return ¬RegisteredErr{t: t, target: target}
|
||||
}
|
||||
|
||||
func NewNotRegisteredGVKErrForTarget(gvk schema.GroupVersionKind, target GroupVersioner) error {
|
||||
return ¬RegisteredErr{gvk: gvk, target: target}
|
||||
}
|
||||
|
||||
func (k *notRegisteredErr) Error() string {
|
||||
if k.t != nil && k.target != nil {
|
||||
return fmt.Sprintf("%v is not suitable for converting to %q", k.t, k.target)
|
||||
}
|
||||
nullGVK := schema.GroupVersionKind{}
|
||||
if k.gvk != nullGVK && k.target != nil {
|
||||
return fmt.Sprintf("%q is not suitable for converting to %q", k.gvk.GroupVersion(), k.target)
|
||||
}
|
||||
if k.t != nil {
|
||||
return fmt.Sprintf("no kind is registered for the type %v", k.t)
|
||||
}
|
||||
|
||||
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 2018 The Kubernetes Authors.
|
||||
Copyright 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 2018 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
|
||||
17
vendor/k8s.io/apimachinery/pkg/runtime/interfaces.go
generated
vendored
17
vendor/k8s.io/apimachinery/pkg/runtime/interfaces.go
generated
vendored
@@ -174,13 +174,16 @@ type ObjectVersioner interface {
|
||||
|
||||
// ObjectConvertor converts an object to a different version.
|
||||
type ObjectConvertor interface {
|
||||
// Convert attempts to convert one object into another, or returns an error. This method does
|
||||
// not guarantee the in object is not mutated. The context argument will be passed to
|
||||
// all nested conversions.
|
||||
// Convert attempts to convert one object into another, or returns an error. This
|
||||
// method does not mutate the in object, but the in and out object might share data structures,
|
||||
// i.e. the out object cannot be mutated without mutating the in object as well.
|
||||
// The context argument will be passed to all nested conversions.
|
||||
Convert(in, out, context interface{}) error
|
||||
// ConvertToVersion takes the provided object and converts it the provided version. This
|
||||
// method does not guarantee that the in object is not mutated. This method is similar to
|
||||
// Convert() but handles specific details of choosing the correct output version.
|
||||
// method does not mutate the in object, but the in and out object might share data structures,
|
||||
// i.e. the out object cannot be mutated without mutating the in object as well.
|
||||
// This method is similar to Convert() but handles specific details of choosing the correct
|
||||
// output version.
|
||||
ConvertToVersion(in Object, gv GroupVersioner) (out Object, err error)
|
||||
ConvertFieldLabel(version, kind, label, value string) (string, string, error)
|
||||
}
|
||||
@@ -234,9 +237,9 @@ type Object interface {
|
||||
// to JSON allowed.
|
||||
type Unstructured interface {
|
||||
Object
|
||||
// UnstructuredContent returns a non-nil, mutable map of the contents of this object. Values may be
|
||||
// UnstructuredContent returns a non-nil map with this object's contents. Values may be
|
||||
// []interface{}, map[string]interface{}, or any primitive type. Contents are typically serialized to
|
||||
// and from JSON.
|
||||
// and from JSON. SetUnstructuredContent should be used to mutate the contents.
|
||||
UnstructuredContent() map[string]interface{}
|
||||
// SetUnstructuredContent updates the object content to match the provided map.
|
||||
SetUnstructuredContent(map[string]interface{})
|
||||
|
||||
150
vendor/k8s.io/apimachinery/pkg/runtime/local_scheme_test.go
generated
vendored
Normal file
150
vendor/k8s.io/apimachinery/pkg/runtime/local_scheme_test.go
generated
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"reflect"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/diff"
|
||||
)
|
||||
|
||||
func TestPreferredVersionsAllGroups(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
versionPriority map[string][]string
|
||||
observedVersions []schema.GroupVersion
|
||||
expectedPrioritized map[string][]schema.GroupVersion
|
||||
expectedPreferred map[schema.GroupVersion]bool
|
||||
}{
|
||||
{
|
||||
name: "observedOnly",
|
||||
observedVersions: []schema.GroupVersion{
|
||||
{Group: "", Version: "v3"},
|
||||
{Group: "foo", Version: "v1"},
|
||||
{Group: "foo", Version: "v2"},
|
||||
{Group: "", Version: "v1"},
|
||||
},
|
||||
expectedPrioritized: map[string][]schema.GroupVersion{
|
||||
"": {
|
||||
{Group: "", Version: "v3"},
|
||||
{Group: "", Version: "v1"},
|
||||
},
|
||||
"foo": {
|
||||
{Group: "foo", Version: "v1"},
|
||||
{Group: "foo", Version: "v2"},
|
||||
},
|
||||
},
|
||||
expectedPreferred: map[schema.GroupVersion]bool{
|
||||
{Group: "", Version: "v3"}: true,
|
||||
{Group: "foo", Version: "v1"}: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "specifiedOnly",
|
||||
versionPriority: map[string][]string{
|
||||
"": {"v3", "v1"},
|
||||
"foo": {"v1", "v2"},
|
||||
},
|
||||
expectedPrioritized: map[string][]schema.GroupVersion{
|
||||
"": {
|
||||
{Group: "", Version: "v3"},
|
||||
{Group: "", Version: "v1"},
|
||||
},
|
||||
"foo": {
|
||||
{Group: "foo", Version: "v1"},
|
||||
{Group: "foo", Version: "v2"},
|
||||
},
|
||||
},
|
||||
expectedPreferred: map[schema.GroupVersion]bool{
|
||||
{Group: "", Version: "v3"}: true,
|
||||
{Group: "foo", Version: "v1"}: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "both",
|
||||
versionPriority: map[string][]string{
|
||||
"": {"v3", "v1"},
|
||||
"foo": {"v1", "v2"},
|
||||
},
|
||||
observedVersions: []schema.GroupVersion{
|
||||
{Group: "", Version: "v1"},
|
||||
{Group: "", Version: "v3"},
|
||||
{Group: "", Version: "v4"},
|
||||
{Group: "", Version: "v5"},
|
||||
{Group: "bar", Version: "v1"},
|
||||
{Group: "bar", Version: "v2"},
|
||||
},
|
||||
expectedPrioritized: map[string][]schema.GroupVersion{
|
||||
"": {
|
||||
{Group: "", Version: "v3"},
|
||||
{Group: "", Version: "v1"},
|
||||
{Group: "", Version: "v4"},
|
||||
{Group: "", Version: "v5"},
|
||||
},
|
||||
"foo": {
|
||||
{Group: "foo", Version: "v1"},
|
||||
{Group: "foo", Version: "v2"},
|
||||
},
|
||||
"bar": {
|
||||
{Group: "bar", Version: "v1"},
|
||||
{Group: "bar", Version: "v2"},
|
||||
},
|
||||
},
|
||||
expectedPreferred: map[schema.GroupVersion]bool{
|
||||
{Group: "", Version: "v3"}: true,
|
||||
{Group: "foo", Version: "v1"}: true,
|
||||
{Group: "bar", Version: "v1"}: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
scheme := NewScheme()
|
||||
scheme.versionPriority = test.versionPriority
|
||||
scheme.observedVersions = test.observedVersions
|
||||
|
||||
for group, expected := range test.expectedPrioritized {
|
||||
actual := scheme.PrioritizedVersionsForGroup(group)
|
||||
if !reflect.DeepEqual(expected, actual) {
|
||||
t.Error(diff.ObjectDiff(expected, actual))
|
||||
}
|
||||
}
|
||||
|
||||
prioritizedAll := scheme.PrioritizedVersionsAllGroups()
|
||||
actualPrioritizedAll := map[string][]schema.GroupVersion{}
|
||||
for _, actual := range prioritizedAll {
|
||||
actualPrioritizedAll[actual.Group] = append(actualPrioritizedAll[actual.Group], actual)
|
||||
}
|
||||
if !reflect.DeepEqual(test.expectedPrioritized, actualPrioritizedAll) {
|
||||
t.Error(diff.ObjectDiff(test.expectedPrioritized, actualPrioritizedAll))
|
||||
}
|
||||
|
||||
preferredAll := scheme.PreferredVersionAllGroups()
|
||||
actualPreferredAll := map[schema.GroupVersion]bool{}
|
||||
for _, actual := range preferredAll {
|
||||
actualPreferredAll[actual] = true
|
||||
}
|
||||
if !reflect.DeepEqual(test.expectedPreferred, actualPreferredAll) {
|
||||
t.Error(diff.ObjectDiff(test.expectedPreferred, actualPreferredAll))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
43
vendor/k8s.io/apimachinery/pkg/runtime/schema/BUILD
generated
vendored
43
vendor/k8s.io/apimachinery/pkg/runtime/schema/BUILD
generated
vendored
@@ -1,43 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["group_version_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"generated.pb.go",
|
||||
"group_version.go",
|
||||
"interfaces.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/schema",
|
||||
deps = ["//vendor/github.com/gogo/protobuf/proto:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "go_default_library_protos",
|
||||
srcs = ["generated.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
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 2018 The Kubernetes Authors.
|
||||
Copyright 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 2018 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
|
||||
44
vendor/k8s.io/apimachinery/pkg/runtime/schema/group_version_test.go
generated
vendored
44
vendor/k8s.io/apimachinery/pkg/runtime/schema/group_version_test.go
generated
vendored
@@ -134,3 +134,47 @@ func TestKindForGroupVersionKinds(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseKindArg(t *testing.T) {
|
||||
tests := []struct {
|
||||
input string
|
||||
gvk *GroupVersionKind
|
||||
gk GroupKind
|
||||
}{
|
||||
{input: "Pod", gk: GroupKind{Kind: "Pod"}},
|
||||
{input: ".apps", gk: GroupKind{Group: "apps"}},
|
||||
{input: "Pod.", gk: GroupKind{Kind: "Pod"}},
|
||||
{input: "StatefulSet.apps", gk: GroupKind{Group: "apps", Kind: "StatefulSet"}},
|
||||
{input: "StatefulSet.v1.apps", gvk: &GroupVersionKind{Group: "apps", Version: "v1", Kind: "StatefulSet"}, gk: GroupKind{Group: "v1.apps", Kind: "StatefulSet"}},
|
||||
}
|
||||
for i, test := range tests {
|
||||
t.Run(test.input, func(t *testing.T) {
|
||||
gvk, gk := ParseKindArg(test.input)
|
||||
if (gvk != nil && test.gvk == nil) || (gvk == nil && test.gvk != nil) || (test.gvk != nil && *gvk != *test.gvk) {
|
||||
t.Errorf("%d: expected output: %#v, got: %#v", i, test.gvk, gvk)
|
||||
}
|
||||
if gk != test.gk {
|
||||
t.Errorf("%d: expected output: %#v, got: %#v", i, test.gk, gk)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseGroupKind(t *testing.T) {
|
||||
tests := []struct {
|
||||
input string
|
||||
out GroupKind
|
||||
}{
|
||||
{input: "Pod", out: GroupKind{Kind: "Pod"}},
|
||||
{input: ".StatefulSet", out: GroupKind{Group: "StatefulSet"}},
|
||||
{input: "StatefulSet.apps", out: GroupKind{Group: "apps", Kind: "StatefulSet"}},
|
||||
}
|
||||
for i, test := range tests {
|
||||
t.Run(test.input, func(t *testing.T) {
|
||||
out := ParseGroupKind(test.input)
|
||||
if out != test.out {
|
||||
t.Errorf("%d: expected output: %#v, got: %#v", i, test.out, out)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
146
vendor/k8s.io/apimachinery/pkg/runtime/scheme.go
generated
vendored
146
vendor/k8s.io/apimachinery/pkg/runtime/scheme.go
generated
vendored
@@ -21,8 +21,11 @@ import (
|
||||
"net/url"
|
||||
"reflect"
|
||||
|
||||
"strings"
|
||||
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
)
|
||||
|
||||
// Scheme defines methods for serializing and deserializing API objects, a type
|
||||
@@ -68,6 +71,13 @@ type Scheme struct {
|
||||
// converter stores all registered conversion functions. It also has
|
||||
// default coverting behavior.
|
||||
converter *conversion.Converter
|
||||
|
||||
// versionPriority is a map of groups to ordered lists of versions for those groups indicating the
|
||||
// default priorities of these versions as registered in the scheme
|
||||
versionPriority map[string][]string
|
||||
|
||||
// observedVersions keeps track of the order we've seen versions during type registration
|
||||
observedVersions []schema.GroupVersion
|
||||
}
|
||||
|
||||
// Function to convert a field selector to internal representation.
|
||||
@@ -82,6 +92,7 @@ func NewScheme() *Scheme {
|
||||
unversionedKinds: map[string]reflect.Type{},
|
||||
fieldLabelConversionFuncs: map[string]map[string]FieldLabelConversionFunc{},
|
||||
defaulterFuncs: map[reflect.Type]func(interface{}){},
|
||||
versionPriority: map[string][]string{},
|
||||
}
|
||||
s.converter = conversion.NewConverter(s.nameFunc)
|
||||
|
||||
@@ -111,7 +122,7 @@ func (s *Scheme) nameFunc(t reflect.Type) string {
|
||||
|
||||
for _, gvk := range gvks {
|
||||
internalGV := gvk.GroupVersion()
|
||||
internalGV.Version = "__internal" // this is hacky and maybe should be passed in
|
||||
internalGV.Version = APIVersionInternal // this is hacky and maybe should be passed in
|
||||
internalGVK := internalGV.WithKind(gvk.Kind)
|
||||
|
||||
if internalType, exists := s.gvkToType[internalGVK]; exists {
|
||||
@@ -141,6 +152,7 @@ func (s *Scheme) Converter() *conversion.Converter {
|
||||
// TODO: there is discussion about removing unversioned and replacing it with objects that are manifest into
|
||||
// every version with particular schemas. Resolve this method at that point.
|
||||
func (s *Scheme) AddUnversionedTypes(version schema.GroupVersion, types ...Object) {
|
||||
s.addObservedVersion(version)
|
||||
s.AddKnownTypes(version, types...)
|
||||
for _, obj := range types {
|
||||
t := reflect.TypeOf(obj).Elem()
|
||||
@@ -158,6 +170,7 @@ func (s *Scheme) AddUnversionedTypes(version schema.GroupVersion, types ...Objec
|
||||
// the struct becomes the "kind" field when encoding. Version may not be empty - use the
|
||||
// APIVersionInternal constant if you have a type that does not have a formal version.
|
||||
func (s *Scheme) AddKnownTypes(gv schema.GroupVersion, types ...Object) {
|
||||
s.addObservedVersion(gv)
|
||||
for _, obj := range types {
|
||||
t := reflect.TypeOf(obj)
|
||||
if t.Kind() != reflect.Ptr {
|
||||
@@ -173,6 +186,7 @@ func (s *Scheme) AddKnownTypes(gv schema.GroupVersion, types ...Object) {
|
||||
// your structs. Version may not be empty - use the APIVersionInternal constant if you have a
|
||||
// type that does not have a formal version.
|
||||
func (s *Scheme) AddKnownTypeWithName(gvk schema.GroupVersionKind, obj Object) {
|
||||
s.addObservedVersion(gvk.GroupVersion())
|
||||
t := reflect.TypeOf(obj)
|
||||
if len(gvk.Version) == 0 {
|
||||
panic(fmt.Sprintf("version is required on all types: %s %v", gvk, t))
|
||||
@@ -620,3 +634,133 @@ func setTargetKind(obj Object, kind schema.GroupVersionKind) {
|
||||
}
|
||||
obj.GetObjectKind().SetGroupVersionKind(kind)
|
||||
}
|
||||
|
||||
// SetVersionPriority allows specifying a precise order of priority. All specified versions must be in the same group,
|
||||
// and the specified order overwrites any previously specified order for this group
|
||||
func (s *Scheme) SetVersionPriority(versions ...schema.GroupVersion) error {
|
||||
groups := sets.String{}
|
||||
order := []string{}
|
||||
for _, version := range versions {
|
||||
if len(version.Version) == 0 || version.Version == APIVersionInternal {
|
||||
return fmt.Errorf("internal versions cannot be prioritized: %v", version)
|
||||
}
|
||||
|
||||
groups.Insert(version.Group)
|
||||
order = append(order, version.Version)
|
||||
}
|
||||
if len(groups) != 1 {
|
||||
return fmt.Errorf("must register versions for exactly one group: %v", strings.Join(groups.List(), ", "))
|
||||
}
|
||||
|
||||
s.versionPriority[groups.List()[0]] = order
|
||||
return nil
|
||||
}
|
||||
|
||||
// PrioritizedVersionsForGroup returns versions for a single group in priority order
|
||||
func (s *Scheme) PrioritizedVersionsForGroup(group string) []schema.GroupVersion {
|
||||
ret := []schema.GroupVersion{}
|
||||
for _, version := range s.versionPriority[group] {
|
||||
ret = append(ret, schema.GroupVersion{Group: group, Version: version})
|
||||
}
|
||||
for _, observedVersion := range s.observedVersions {
|
||||
if observedVersion.Group != group {
|
||||
continue
|
||||
}
|
||||
found := false
|
||||
for _, existing := range ret {
|
||||
if existing == observedVersion {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
ret = append(ret, observedVersion)
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
// PrioritizedVersionsAllGroups returns all known versions in their priority order. Groups are random, but
|
||||
// versions for a single group are prioritized
|
||||
func (s *Scheme) PrioritizedVersionsAllGroups() []schema.GroupVersion {
|
||||
ret := []schema.GroupVersion{}
|
||||
for group, versions := range s.versionPriority {
|
||||
for _, version := range versions {
|
||||
ret = append(ret, schema.GroupVersion{Group: group, Version: version})
|
||||
}
|
||||
}
|
||||
for _, observedVersion := range s.observedVersions {
|
||||
found := false
|
||||
for _, existing := range ret {
|
||||
if existing == observedVersion {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
ret = append(ret, observedVersion)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// PreferredVersionAllGroups returns the most preferred version for every group.
|
||||
// group ordering is random.
|
||||
func (s *Scheme) PreferredVersionAllGroups() []schema.GroupVersion {
|
||||
ret := []schema.GroupVersion{}
|
||||
for group, versions := range s.versionPriority {
|
||||
for _, version := range versions {
|
||||
ret = append(ret, schema.GroupVersion{Group: group, Version: version})
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, observedVersion := range s.observedVersions {
|
||||
found := false
|
||||
for _, existing := range ret {
|
||||
if existing.Group == observedVersion.Group {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
ret = append(ret, observedVersion)
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
// IsGroupRegistered returns true if types for the group have been registered with the scheme
|
||||
func (s *Scheme) IsGroupRegistered(group string) bool {
|
||||
for _, observedVersion := range s.observedVersions {
|
||||
if observedVersion.Group == group {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsVersionRegistered returns true if types for the version have been registered with the scheme
|
||||
func (s *Scheme) IsVersionRegistered(version schema.GroupVersion) bool {
|
||||
for _, observedVersion := range s.observedVersions {
|
||||
if observedVersion == version {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *Scheme) addObservedVersion(version schema.GroupVersion) {
|
||||
if len(version.Version) == 0 || version.Version == APIVersionInternal {
|
||||
return
|
||||
}
|
||||
for _, observedVersion := range s.observedVersions {
|
||||
if observedVersion == version {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
s.observedVersions = append(s.observedVersions, version)
|
||||
}
|
||||
|
||||
64
vendor/k8s.io/apimachinery/pkg/runtime/serializer/BUILD
generated
vendored
64
vendor/k8s.io/apimachinery/pkg/runtime/serializer/BUILD
generated
vendored
@@ -1,64 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["codec_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/github.com/ghodss/yaml:go_default_library",
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag: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/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer/testing:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"codec_factory.go",
|
||||
"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",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer/json:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer/protobuf:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer/recognizer:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning: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/runtime/serializer/json:all-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/protobuf:all-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/recognizer:all-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/streaming:all-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing:all-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/versioning:all-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/yaml:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
55
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/BUILD
generated
vendored
55
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/BUILD
generated
vendored
@@ -1,55 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["meta_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"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",
|
||||
"//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/recognizer:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/framer:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/yaml:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["json_test.go"],
|
||||
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/runtime/serializer/json:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
27
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go
generated
vendored
27
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go
generated
vendored
@@ -75,11 +75,6 @@ func init() {
|
||||
case jsoniter.NumberValue:
|
||||
var number json.Number
|
||||
iter.ReadVal(&number)
|
||||
u64, err := strconv.ParseUint(string(number), 10, 64)
|
||||
if err == nil {
|
||||
*(*interface{})(ptr) = u64
|
||||
return
|
||||
}
|
||||
i64, err := strconv.ParseInt(string(number), 10, 64)
|
||||
if err == nil {
|
||||
*(*interface{})(ptr) = i64
|
||||
@@ -98,6 +93,20 @@ func init() {
|
||||
jsoniter.RegisterTypeDecoderFunc("interface {}", decodeNumberAsInt64IfPossible)
|
||||
}
|
||||
|
||||
// CaseSensitiveJsonIterator returns a jsoniterator API that's configured to be
|
||||
// case-sensitive when unmarshalling, and otherwise compatible with
|
||||
// the encoding/json standard library.
|
||||
func CaseSensitiveJsonIterator() jsoniter.API {
|
||||
return jsoniter.Config{
|
||||
EscapeHTML: true,
|
||||
SortMapKeys: true,
|
||||
ValidateJsonRawMessage: true,
|
||||
CaseSensitive: true,
|
||||
}.Froze()
|
||||
}
|
||||
|
||||
var caseSensitiveJsonIterator = CaseSensitiveJsonIterator()
|
||||
|
||||
// gvkWithDefaults returns group kind and version defaulting from provided default
|
||||
func gvkWithDefaults(actual, defaultGVK schema.GroupVersionKind) schema.GroupVersionKind {
|
||||
if len(actual.Kind) == 0 {
|
||||
@@ -162,7 +171,7 @@ func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, i
|
||||
types, _, err := s.typer.ObjectKinds(into)
|
||||
switch {
|
||||
case runtime.IsNotRegisteredError(err), isUnstructured:
|
||||
if err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(data, into); err != nil {
|
||||
if err := caseSensitiveJsonIterator.Unmarshal(data, into); err != nil {
|
||||
return nil, actual, err
|
||||
}
|
||||
return into, actual, nil
|
||||
@@ -186,7 +195,7 @@ func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, i
|
||||
return nil, actual, err
|
||||
}
|
||||
|
||||
if err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(data, obj); err != nil {
|
||||
if err := caseSensitiveJsonIterator.Unmarshal(data, obj); err != nil {
|
||||
return nil, actual, err
|
||||
}
|
||||
return obj, actual, nil
|
||||
@@ -195,7 +204,7 @@ func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, i
|
||||
// Encode serializes the provided object to the given writer.
|
||||
func (s *Serializer) Encode(obj runtime.Object, w io.Writer) error {
|
||||
if s.yaml {
|
||||
json, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(obj)
|
||||
json, err := caseSensitiveJsonIterator.Marshal(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -208,7 +217,7 @@ func (s *Serializer) Encode(obj runtime.Object, w io.Writer) error {
|
||||
}
|
||||
|
||||
if s.pretty {
|
||||
data, err := jsoniter.ConfigCompatibleWithStandardLibrary.MarshalIndent(obj, "", " ")
|
||||
data, err := caseSensitiveJsonIterator.MarshalIndent(obj, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
45
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json_test.go
generated
vendored
45
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json_test.go
generated
vendored
@@ -30,10 +30,31 @@ import (
|
||||
|
||||
type testDecodable struct {
|
||||
Other string
|
||||
Value int `json:"value"`
|
||||
Value int `json:"value"`
|
||||
Spec DecodableSpec `json:"spec"`
|
||||
gvk schema.GroupVersionKind
|
||||
}
|
||||
|
||||
// DecodableSpec has 15 fields. json-iterator treats struct with more than 10
|
||||
// fields differently from struct that has less than 10 fields.
|
||||
type DecodableSpec struct {
|
||||
A int `json:"A"`
|
||||
B int `json:"B"`
|
||||
C int `json:"C"`
|
||||
D int `json:"D"`
|
||||
E int `json:"E"`
|
||||
F int `json:"F"`
|
||||
G int `json:"G"`
|
||||
H int `json:"h"`
|
||||
I int `json:"i"`
|
||||
J int `json:"j"`
|
||||
K int `json:"k"`
|
||||
L int `json:"l"`
|
||||
M int `json:"m"`
|
||||
N int `json:"n"`
|
||||
O int `json:"o"`
|
||||
}
|
||||
|
||||
func (d *testDecodable) GetObjectKind() schema.ObjectKind { return d }
|
||||
func (d *testDecodable) SetGroupVersionKind(gvk schema.GroupVersionKind) { d.gvk = gvk }
|
||||
func (d *testDecodable) GroupVersionKind() schema.GroupVersionKind { return d.gvk }
|
||||
@@ -221,6 +242,28 @@ func TestDecode(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
// Unmarshalling is case-sensitive
|
||||
{
|
||||
// "VaLue" should have been "value"
|
||||
data: []byte(`{"kind":"Test","apiVersion":"other/blah","VaLue":1,"Other":"test"}`),
|
||||
into: &testDecodable{},
|
||||
typer: &mockTyper{err: runtime.NewNotRegisteredErrForKind(schema.GroupVersionKind{Kind: "Test", Group: "other", Version: "blah"})},
|
||||
expectedGVK: &schema.GroupVersionKind{Kind: "Test", Group: "other", Version: "blah"},
|
||||
expectedObject: &testDecodable{
|
||||
Other: "test",
|
||||
},
|
||||
},
|
||||
// Unmarshalling is case-sensitive for big struct.
|
||||
{
|
||||
// "b" should have been "B", "I" should have been "i"
|
||||
data: []byte(`{"kind":"Test","apiVersion":"other/blah","spec": {"A": 1, "b": 2, "h": 3, "I": 4}}`),
|
||||
into: &testDecodable{},
|
||||
typer: &mockTyper{err: runtime.NewNotRegisteredErrForKind(schema.GroupVersionKind{Kind: "Test", Group: "other", Version: "blah"})},
|
||||
expectedGVK: &schema.GroupVersionKind{Kind: "Test", Group: "other", Version: "blah"},
|
||||
expectedObject: &testDecodable{
|
||||
Spec: DecodableSpec{A: 1, H: 3},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range testCases {
|
||||
|
||||
35
vendor/k8s.io/apimachinery/pkg/runtime/serializer/protobuf/BUILD
generated
vendored
35
vendor/k8s.io/apimachinery/pkg/runtime/serializer/protobuf/BUILD
generated
vendored
@@ -1,35 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"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",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer/recognizer:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/framer:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
32
vendor/k8s.io/apimachinery/pkg/runtime/serializer/recognizer/BUILD
generated
vendored
32
vendor/k8s.io/apimachinery/pkg/runtime/serializer/recognizer/BUILD
generated
vendored
@@ -1,32 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
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",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/recognizer/testing:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
91
vendor/k8s.io/apimachinery/pkg/runtime/serializer/sparse_test.go
generated
vendored
Normal file
91
vendor/k8s.io/apimachinery/pkg/runtime/serializer/sparse_test.go
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package serializer
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/equality"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/diff"
|
||||
)
|
||||
|
||||
type FakeV1Obj struct {
|
||||
metav1.TypeMeta
|
||||
metav1.ObjectMeta
|
||||
}
|
||||
|
||||
func (*FakeV1Obj) DeepCopyObject() runtime.Object {
|
||||
panic("not supported")
|
||||
}
|
||||
|
||||
type FakeV2DifferentObj struct {
|
||||
metav1.TypeMeta
|
||||
metav1.ObjectMeta
|
||||
}
|
||||
|
||||
func (*FakeV2DifferentObj) DeepCopyObject() runtime.Object {
|
||||
panic("not supported")
|
||||
}
|
||||
func TestSparse(t *testing.T) {
|
||||
v1 := schema.GroupVersion{Group: "mygroup", Version: "v1"}
|
||||
v2 := schema.GroupVersion{Group: "mygroup", Version: "v2"}
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
scheme.AddKnownTypes(v1, &FakeV1Obj{})
|
||||
scheme.AddKnownTypes(v2, &FakeV2DifferentObj{})
|
||||
codecs := NewCodecFactory(scheme)
|
||||
|
||||
srcObj1 := &FakeV1Obj{ObjectMeta: metav1.ObjectMeta{Name: "foo"}}
|
||||
srcObj2 := &FakeV2DifferentObj{ObjectMeta: metav1.ObjectMeta{Name: "foo"}}
|
||||
|
||||
encoder := codecs.LegacyCodec(v2, v1)
|
||||
decoder := codecs.UniversalDecoder(v2, v1)
|
||||
|
||||
srcObj1Bytes, err := runtime.Encode(encoder, srcObj1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(string(srcObj1Bytes))
|
||||
srcObj2Bytes, err := runtime.Encode(encoder, srcObj2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(string(srcObj2Bytes))
|
||||
|
||||
uncastDstObj1, err := runtime.Decode(decoder, srcObj1Bytes)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
uncastDstObj2, err := runtime.Decode(decoder, srcObj2Bytes)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// clear typemeta
|
||||
uncastDstObj1.(*FakeV1Obj).TypeMeta = metav1.TypeMeta{}
|
||||
uncastDstObj2.(*FakeV2DifferentObj).TypeMeta = metav1.TypeMeta{}
|
||||
|
||||
if !equality.Semantic.DeepEqual(srcObj1, uncastDstObj1) {
|
||||
t.Fatal(diff.ObjectDiff(srcObj1, uncastDstObj1))
|
||||
}
|
||||
if !equality.Semantic.DeepEqual(srcObj2, uncastDstObj2) {
|
||||
t.Fatal(diff.ObjectDiff(srcObj2, uncastDstObj2))
|
||||
}
|
||||
}
|
||||
41
vendor/k8s.io/apimachinery/pkg/runtime/serializer/streaming/BUILD
generated
vendored
41
vendor/k8s.io/apimachinery/pkg/runtime/serializer/streaming/BUILD
generated
vendored
@@ -1,41 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["streaming_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
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/framer:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
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",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
41
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/BUILD
generated
vendored
41
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/BUILD
generated
vendored
@@ -1,41 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["versioning_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
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/diff:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
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",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
23
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/versioning.go
generated
vendored
23
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/versioning.go
generated
vendored
@@ -19,6 +19,7 @@ package versioning
|
||||
import (
|
||||
"io"
|
||||
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
@@ -166,9 +167,27 @@ func (c *codec) Decode(data []byte, defaultGVK *schema.GroupVersionKind, into ru
|
||||
// Encode ensures the provided object is output in the appropriate group and version, invoking
|
||||
// conversion if necessary. Unversioned objects (according to the ObjectTyper) are output as is.
|
||||
func (c *codec) Encode(obj runtime.Object, w io.Writer) error {
|
||||
switch obj.(type) {
|
||||
case *runtime.Unknown, runtime.Unstructured:
|
||||
switch obj := obj.(type) {
|
||||
case *runtime.Unknown:
|
||||
return c.encoder.Encode(obj, w)
|
||||
case runtime.Unstructured:
|
||||
// An unstructured list can contain objects of multiple group version kinds. don't short-circuit just
|
||||
// because the top-level type matches our desired destination type. actually send the object to the converter
|
||||
// to give it a chance to convert the list items if needed.
|
||||
if _, ok := obj.(*unstructured.UnstructuredList); !ok {
|
||||
// avoid conversion roundtrip if GVK is the right one already or is empty (yes, this is a hack, but the old behaviour we rely on in kubectl)
|
||||
objGVK := obj.GetObjectKind().GroupVersionKind()
|
||||
if len(objGVK.Version) == 0 {
|
||||
return c.encoder.Encode(obj, w)
|
||||
}
|
||||
targetGVK, ok := c.encodeVersion.KindForGroupVersionKinds([]schema.GroupVersionKind{objGVK})
|
||||
if !ok {
|
||||
return runtime.NewNotRegisteredGVKErrForTarget(objGVK, c.encodeVersion)
|
||||
}
|
||||
if targetGVK == objGVK {
|
||||
return c.encoder.Encode(obj, w)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gvks, isUnversioned, err := c.typer.ObjectKinds(obj)
|
||||
|
||||
16
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/versioning_test.go
generated
vendored
16
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/versioning_test.go
generated
vendored
@@ -129,25 +129,25 @@ func TestDecode(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
serializer: &mockSerializer{actual: gvk1},
|
||||
convertor: &checkConvertor{groupVersion: schema.GroupVersion{Group: "other", Version: "__internal"}},
|
||||
convertor: &checkConvertor{groupVersion: schema.GroupVersion{Group: "other", Version: runtime.APIVersionInternal}},
|
||||
expectedGVK: gvk1,
|
||||
decodes: schema.GroupVersion{Group: "other", Version: "__internal"},
|
||||
decodes: schema.GroupVersion{Group: "other", Version: runtime.APIVersionInternal},
|
||||
},
|
||||
{
|
||||
serializer: &mockSerializer{actual: gvk1, obj: decodable1},
|
||||
convertor: &checkConvertor{in: decodable1, obj: decodable2, groupVersion: schema.GroupVersion{Group: "other", Version: "__internal"}},
|
||||
convertor: &checkConvertor{in: decodable1, obj: decodable2, groupVersion: schema.GroupVersion{Group: "other", Version: runtime.APIVersionInternal}},
|
||||
expectedGVK: gvk1,
|
||||
sameObject: decodable2,
|
||||
decodes: schema.GroupVersion{Group: "other", Version: "__internal"},
|
||||
decodes: schema.GroupVersion{Group: "other", Version: runtime.APIVersionInternal},
|
||||
},
|
||||
// defaultGVK.Group is allowed to force a conversion to the destination group
|
||||
{
|
||||
serializer: &mockSerializer{actual: gvk1, obj: decodable1},
|
||||
defaultGVK: &schema.GroupVersionKind{Group: "force"},
|
||||
convertor: &checkConvertor{in: decodable1, obj: decodable2, groupVersion: schema.GroupVersion{Group: "force", Version: "__internal"}},
|
||||
convertor: &checkConvertor{in: decodable1, obj: decodable2, groupVersion: schema.GroupVersion{Group: "force", Version: runtime.APIVersionInternal}},
|
||||
expectedGVK: gvk1,
|
||||
sameObject: decodable2,
|
||||
decodes: schema.GroupVersion{Group: "force", Version: "__internal"},
|
||||
decodes: schema.GroupVersion{Group: "force", Version: runtime.APIVersionInternal},
|
||||
},
|
||||
// uses direct conversion for into when objects differ
|
||||
{
|
||||
@@ -184,10 +184,10 @@ func TestDecode(t *testing.T) {
|
||||
into: &runtime.VersionedObjects{Objects: []runtime.Object{}},
|
||||
|
||||
serializer: &mockSerializer{actual: gvk1, obj: decodable1},
|
||||
convertor: &checkConvertor{in: decodable1, obj: decodable2, groupVersion: schema.GroupVersion{Group: "other", Version: "__internal"}},
|
||||
convertor: &checkConvertor{in: decodable1, obj: decodable2, groupVersion: schema.GroupVersion{Group: "other", Version: runtime.APIVersionInternal}},
|
||||
expectedGVK: gvk1,
|
||||
expectedObject: &runtime.VersionedObjects{Objects: []runtime.Object{decodable1, decodable2}},
|
||||
decodes: schema.GroupVersion{Group: "other", Version: "__internal"},
|
||||
decodes: schema.GroupVersion{Group: "other", Version: runtime.APIVersionInternal},
|
||||
},
|
||||
|
||||
// decode into the same version as the serialized object
|
||||
|
||||
2
vendor/k8s.io/apimachinery/pkg/runtime/zz_generated.deepcopy.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/runtime/zz_generated.deepcopy.go
generated
vendored
@@ -1,7 +1,7 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
|
||||
25
vendor/k8s.io/apimachinery/pkg/selection/BUILD
generated
vendored
25
vendor/k8s.io/apimachinery/pkg/selection/BUILD
generated
vendored
@@ -1,25 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["operator.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/selection",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
31
vendor/k8s.io/apimachinery/pkg/types/BUILD
generated
vendored
31
vendor/k8s.io/apimachinery/pkg/types/BUILD
generated
vendored
@@ -1,31 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"namespacedname.go",
|
||||
"nodename.go",
|
||||
"patch.go",
|
||||
"uid.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/types",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
17
vendor/k8s.io/apimachinery/pkg/types/namespacedname.go
generated
vendored
17
vendor/k8s.io/apimachinery/pkg/types/namespacedname.go
generated
vendored
@@ -18,7 +18,6 @@ package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// NamespacedName comprises a resource name, with a mandatory namespace,
|
||||
@@ -42,19 +41,3 @@ const (
|
||||
func (n NamespacedName) String() string {
|
||||
return fmt.Sprintf("%s%c%s", n.Namespace, Separator, n.Name)
|
||||
}
|
||||
|
||||
// NewNamespacedNameFromString parses the provided string and returns a NamespacedName.
|
||||
// The expected format is as per String() above.
|
||||
// If the input string is invalid, the returned NamespacedName has all empty string field values.
|
||||
// This allows a single-value return from this function, while still allowing error checks in the caller.
|
||||
// Note that an input string which does not include exactly one Separator is not a valid input (as it could never
|
||||
// have neem returned by String() )
|
||||
func NewNamespacedNameFromString(s string) NamespacedName {
|
||||
nn := NamespacedName{}
|
||||
result := strings.Split(s, string(Separator))
|
||||
if len(result) == 2 {
|
||||
nn.Namespace = result[0]
|
||||
nn.Name = result[1]
|
||||
}
|
||||
return nn
|
||||
}
|
||||
|
||||
43
vendor/k8s.io/apimachinery/pkg/util/cache/BUILD
generated
vendored
43
vendor/k8s.io/apimachinery/pkg/util/cache/BUILD
generated
vendored
@@ -1,43 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"cache_test.go",
|
||||
"lruexpirecache_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/groupcache/lru:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/clock:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"cache.go",
|
||||
"lruexpirecache.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/cache",
|
||||
deps = ["//vendor/github.com/hashicorp/golang-lru:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
32
vendor/k8s.io/apimachinery/pkg/util/clock/BUILD
generated
vendored
32
vendor/k8s.io/apimachinery/pkg/util/clock/BUILD
generated
vendored
@@ -1,32 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["clock_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["clock.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/clock",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
63
vendor/k8s.io/apimachinery/pkg/util/clock/clock.go
generated
vendored
63
vendor/k8s.io/apimachinery/pkg/util/clock/clock.go
generated
vendored
@@ -26,18 +26,12 @@ import (
|
||||
type Clock interface {
|
||||
Now() time.Time
|
||||
Since(time.Time) time.Duration
|
||||
After(d time.Duration) <-chan time.Time
|
||||
NewTimer(d time.Duration) Timer
|
||||
Sleep(d time.Duration)
|
||||
Tick(d time.Duration) <-chan time.Time
|
||||
After(time.Duration) <-chan time.Time
|
||||
NewTimer(time.Duration) Timer
|
||||
Sleep(time.Duration)
|
||||
NewTicker(time.Duration) Ticker
|
||||
}
|
||||
|
||||
var (
|
||||
_ = Clock(RealClock{})
|
||||
_ = Clock(&FakeClock{})
|
||||
_ = Clock(&IntervalClock{})
|
||||
)
|
||||
|
||||
// RealClock really calls time.Now()
|
||||
type RealClock struct{}
|
||||
|
||||
@@ -62,8 +56,10 @@ func (RealClock) NewTimer(d time.Duration) Timer {
|
||||
}
|
||||
}
|
||||
|
||||
func (RealClock) Tick(d time.Duration) <-chan time.Time {
|
||||
return time.Tick(d)
|
||||
func (RealClock) NewTicker(d time.Duration) Ticker {
|
||||
return &realTicker{
|
||||
ticker: time.NewTicker(d),
|
||||
}
|
||||
}
|
||||
|
||||
func (RealClock) Sleep(d time.Duration) {
|
||||
@@ -137,7 +133,7 @@ func (f *FakeClock) NewTimer(d time.Duration) Timer {
|
||||
return timer
|
||||
}
|
||||
|
||||
func (f *FakeClock) Tick(d time.Duration) <-chan time.Time {
|
||||
func (f *FakeClock) NewTicker(d time.Duration) Ticker {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
tickTime := f.time.Add(d)
|
||||
@@ -149,7 +145,9 @@ func (f *FakeClock) Tick(d time.Duration) <-chan time.Time {
|
||||
destChan: ch,
|
||||
})
|
||||
|
||||
return ch
|
||||
return &fakeTicker{
|
||||
c: ch,
|
||||
}
|
||||
}
|
||||
|
||||
// Move clock by Duration, notify anyone that's called After, Tick, or NewTimer
|
||||
@@ -242,8 +240,8 @@ func (*IntervalClock) NewTimer(d time.Duration) Timer {
|
||||
|
||||
// Unimplemented, will panic.
|
||||
// TODO: make interval clock use FakeClock so this can be implemented.
|
||||
func (*IntervalClock) Tick(d time.Duration) <-chan time.Time {
|
||||
panic("IntervalClock doesn't implement Tick")
|
||||
func (*IntervalClock) NewTicker(d time.Duration) Ticker {
|
||||
panic("IntervalClock doesn't implement NewTicker")
|
||||
}
|
||||
|
||||
func (*IntervalClock) Sleep(d time.Duration) {
|
||||
@@ -258,11 +256,6 @@ type Timer interface {
|
||||
Reset(d time.Duration) bool
|
||||
}
|
||||
|
||||
var (
|
||||
_ = Timer(&realTimer{})
|
||||
_ = Timer(&fakeTimer{})
|
||||
)
|
||||
|
||||
// realTimer is backed by an actual time.Timer.
|
||||
type realTimer struct {
|
||||
timer *time.Timer
|
||||
@@ -325,3 +318,31 @@ func (f *fakeTimer) Reset(d time.Duration) bool {
|
||||
|
||||
return active
|
||||
}
|
||||
|
||||
type Ticker interface {
|
||||
C() <-chan time.Time
|
||||
Stop()
|
||||
}
|
||||
|
||||
type realTicker struct {
|
||||
ticker *time.Ticker
|
||||
}
|
||||
|
||||
func (t *realTicker) C() <-chan time.Time {
|
||||
return t.ticker.C
|
||||
}
|
||||
|
||||
func (t *realTicker) Stop() {
|
||||
t.ticker.Stop()
|
||||
}
|
||||
|
||||
type fakeTicker struct {
|
||||
c <-chan time.Time
|
||||
}
|
||||
|
||||
func (t *fakeTicker) C() <-chan time.Time {
|
||||
return t.c
|
||||
}
|
||||
|
||||
func (t *fakeTicker) Stop() {
|
||||
}
|
||||
|
||||
18
vendor/k8s.io/apimachinery/pkg/util/clock/clock_test.go
generated
vendored
18
vendor/k8s.io/apimachinery/pkg/util/clock/clock_test.go
generated
vendored
@@ -21,6 +21,18 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
_ = Clock(RealClock{})
|
||||
_ = Clock(&FakeClock{})
|
||||
_ = Clock(&IntervalClock{})
|
||||
|
||||
_ = Timer(&realTimer{})
|
||||
_ = Timer(&fakeTimer{})
|
||||
|
||||
_ = Ticker(&realTicker{})
|
||||
_ = Ticker(&fakeTicker{})
|
||||
)
|
||||
|
||||
func TestFakeClock(t *testing.T) {
|
||||
startTime := time.Now()
|
||||
tc := NewFakeClock(startTime)
|
||||
@@ -110,13 +122,13 @@ func TestFakeTick(t *testing.T) {
|
||||
if tc.HasWaiters() {
|
||||
t.Errorf("unexpected waiter?")
|
||||
}
|
||||
oneSec := tc.Tick(time.Second)
|
||||
oneSec := tc.NewTicker(time.Second).C()
|
||||
if !tc.HasWaiters() {
|
||||
t.Errorf("unexpected lack of waiter?")
|
||||
}
|
||||
|
||||
oneOhOneSec := tc.Tick(time.Second + time.Millisecond)
|
||||
twoSec := tc.Tick(2 * time.Second)
|
||||
oneOhOneSec := tc.NewTicker(time.Second + time.Millisecond).C()
|
||||
twoSec := tc.NewTicker(2 * time.Second).C()
|
||||
select {
|
||||
case <-oneSec:
|
||||
t.Errorf("unexpected channel read")
|
||||
|
||||
36
vendor/k8s.io/apimachinery/pkg/util/diff/BUILD
generated
vendored
36
vendor/k8s.io/apimachinery/pkg/util/diff/BUILD
generated
vendored
@@ -1,36 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["diff_test.go"],
|
||||
embed = [":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",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
44
vendor/k8s.io/apimachinery/pkg/util/diff/diff.go
generated
vendored
44
vendor/k8s.io/apimachinery/pkg/util/diff/diff.go
generated
vendored
@@ -89,20 +89,52 @@ func ObjectReflectDiff(a, b interface{}) string {
|
||||
}
|
||||
out := []string{""}
|
||||
for _, d := range diffs {
|
||||
elidedA, elidedB := limit(d.a, d.b, 80)
|
||||
out = append(out,
|
||||
fmt.Sprintf("%s:", d.path),
|
||||
limit(fmt.Sprintf(" a: %#v", d.a), 80),
|
||||
limit(fmt.Sprintf(" b: %#v", d.b), 80),
|
||||
fmt.Sprintf(" a: %s", elidedA),
|
||||
fmt.Sprintf(" b: %s", elidedB),
|
||||
)
|
||||
}
|
||||
return strings.Join(out, "\n")
|
||||
}
|
||||
|
||||
func limit(s string, max int) string {
|
||||
if len(s) > max {
|
||||
return s[:max]
|
||||
// limit:
|
||||
// 1. stringifies aObj and bObj
|
||||
// 2. elides identical prefixes if either is too long
|
||||
// 3. elides remaining content from the end if either is too long
|
||||
func limit(aObj, bObj interface{}, max int) (string, string) {
|
||||
elidedPrefix := ""
|
||||
elidedASuffix := ""
|
||||
elidedBSuffix := ""
|
||||
a, b := fmt.Sprintf("%#v", aObj), fmt.Sprintf("%#v", bObj)
|
||||
for {
|
||||
switch {
|
||||
case len(a) > max && len(a) > 4 && len(b) > 4 && a[:4] == b[:4]:
|
||||
// a is too long, b has data, and the first several characters are the same
|
||||
elidedPrefix = "..."
|
||||
a = a[2:]
|
||||
b = b[2:]
|
||||
|
||||
case len(b) > max && len(b) > 4 && len(a) > 4 && a[:4] == b[:4]:
|
||||
// b is too long, a has data, and the first several characters are the same
|
||||
elidedPrefix = "..."
|
||||
a = a[2:]
|
||||
b = b[2:]
|
||||
|
||||
case len(a) > max:
|
||||
a = a[:max]
|
||||
elidedASuffix = "..."
|
||||
|
||||
case len(b) > max:
|
||||
b = b[:max]
|
||||
elidedBSuffix = "..."
|
||||
|
||||
default:
|
||||
// both are short enough
|
||||
return elidedPrefix + a + elidedASuffix, elidedPrefix + b + elidedBSuffix
|
||||
}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func public(s string) bool {
|
||||
|
||||
47
vendor/k8s.io/apimachinery/pkg/util/diff/diff_test.go
generated
vendored
47
vendor/k8s.io/apimachinery/pkg/util/diff/diff_test.go
generated
vendored
@@ -94,3 +94,50 @@ func TestStringDiff(t *testing.T) {
|
||||
t.Errorf("diff returned %v", diff)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLimit(t *testing.T) {
|
||||
testcases := []struct {
|
||||
a interface{}
|
||||
b interface{}
|
||||
expectA string
|
||||
expectB string
|
||||
}{
|
||||
{
|
||||
a: `short a`,
|
||||
b: `short b`,
|
||||
expectA: `"short a"`,
|
||||
expectB: `"short b"`,
|
||||
},
|
||||
{
|
||||
a: `short a`,
|
||||
b: `long b needs truncating`,
|
||||
expectA: `"short a"`,
|
||||
expectB: `"long b ne...`,
|
||||
},
|
||||
{
|
||||
a: `long a needs truncating`,
|
||||
b: `long b needs truncating`,
|
||||
expectA: `...g a needs ...`,
|
||||
expectB: `...g b needs ...`,
|
||||
},
|
||||
{
|
||||
a: `long common prefix with different stuff at the end of a`,
|
||||
b: `long common prefix with different stuff at the end of b`,
|
||||
expectA: `...end of a"`,
|
||||
expectB: `...end of b"`,
|
||||
},
|
||||
{
|
||||
a: `long common prefix with different stuff at the end of a`,
|
||||
b: `long common prefix with different stuff at the end of b which continues`,
|
||||
expectA: `...of a"`,
|
||||
expectB: `...of b which...`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testcases {
|
||||
a, b := limit(tc.a, tc.b, 10)
|
||||
if a != tc.expectA || b != tc.expectB {
|
||||
t.Errorf("limit(%q, %q)\n\texpected: %s, %s\n\tgot: %s, %s", tc.a, tc.b, tc.expectA, tc.expectB, a, b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
35
vendor/k8s.io/apimachinery/pkg/util/errors/BUILD
generated
vendored
35
vendor/k8s.io/apimachinery/pkg/util/errors/BUILD
generated
vendored
@@ -1,35 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["errors_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"errors.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/errors",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
32
vendor/k8s.io/apimachinery/pkg/util/framer/BUILD
generated
vendored
32
vendor/k8s.io/apimachinery/pkg/util/framer/BUILD
generated
vendored
@@ -1,32 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["framer_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["framer.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/framer",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
47
vendor/k8s.io/apimachinery/pkg/util/intstr/BUILD
generated
vendored
47
vendor/k8s.io/apimachinery/pkg/util/intstr/BUILD
generated
vendored
@@ -1,47 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["intstr_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
deps = ["//vendor/github.com/ghodss/yaml:go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"generated.pb.go",
|
||||
"intstr.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/intstr",
|
||||
deps = [
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "go_default_library_protos",
|
||||
srcs = ["generated.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
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 2018 The Kubernetes Authors.
|
||||
Copyright 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/util/intstr/generated.proto
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/util/intstr/generated.proto
generated
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 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.
|
||||
|
||||
32
vendor/k8s.io/apimachinery/pkg/util/json/BUILD
generated
vendored
32
vendor/k8s.io/apimachinery/pkg/util/json/BUILD
generated
vendored
@@ -1,32 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["json.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/json",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["json_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
50
vendor/k8s.io/apimachinery/pkg/util/net/BUILD
generated
vendored
50
vendor/k8s.io/apimachinery/pkg/util/net/BUILD
generated
vendored
@@ -1,50 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"http_test.go",
|
||||
"interface_test.go",
|
||||
"port_range_test.go",
|
||||
"port_split_test.go",
|
||||
"util_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = ["//vendor/github.com/spf13/pflag:go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"http.go",
|
||||
"interface.go",
|
||||
"port_range.go",
|
||||
"port_split.go",
|
||||
"util.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/util/net",
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/golang.org/x/net/http2:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
12
vendor/k8s.io/apimachinery/pkg/util/net/http.go
generated
vendored
12
vendor/k8s.io/apimachinery/pkg/util/net/http.go
generated
vendored
@@ -19,6 +19,7 @@ package net
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -61,6 +62,9 @@ func JoinPreservingTrailingSlash(elem ...string) string {
|
||||
// differentiate probable errors in connection behavior between normal "this is
|
||||
// disconnected" should use the method.
|
||||
func IsProbableEOF(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
if uerr, ok := err.(*url.Error); ok {
|
||||
err = uerr.Err
|
||||
}
|
||||
@@ -87,8 +91,8 @@ func SetOldTransportDefaults(t *http.Transport) *http.Transport {
|
||||
// ProxierWithNoProxyCIDR allows CIDR rules in NO_PROXY
|
||||
t.Proxy = NewProxierWithNoProxyCIDR(http.ProxyFromEnvironment)
|
||||
}
|
||||
if t.Dial == nil {
|
||||
t.Dial = defaultTransport.Dial
|
||||
if t.DialContext == nil {
|
||||
t.DialContext = defaultTransport.DialContext
|
||||
}
|
||||
if t.TLSHandshakeTimeout == 0 {
|
||||
t.TLSHandshakeTimeout = defaultTransport.TLSHandshakeTimeout
|
||||
@@ -116,7 +120,7 @@ type RoundTripperWrapper interface {
|
||||
WrappedRoundTripper() http.RoundTripper
|
||||
}
|
||||
|
||||
type DialFunc func(net, addr string) (net.Conn, error)
|
||||
type DialFunc func(ctx context.Context, net, addr string) (net.Conn, error)
|
||||
|
||||
func DialerFor(transport http.RoundTripper) (DialFunc, error) {
|
||||
if transport == nil {
|
||||
@@ -125,7 +129,7 @@ func DialerFor(transport http.RoundTripper) (DialFunc, error) {
|
||||
|
||||
switch transport := transport.(type) {
|
||||
case *http.Transport:
|
||||
return transport.Dial, nil
|
||||
return transport.DialContext, nil
|
||||
case RoundTripperWrapper:
|
||||
return DialerFor(transport.WrappedRoundTripper())
|
||||
default:
|
||||
|
||||
66
vendor/k8s.io/apimachinery/pkg/util/net/port_range.go
generated
vendored
66
vendor/k8s.io/apimachinery/pkg/util/net/port_range.go
generated
vendored
@@ -43,14 +43,19 @@ func (pr PortRange) String() string {
|
||||
return fmt.Sprintf("%d-%d", pr.Base, pr.Base+pr.Size-1)
|
||||
}
|
||||
|
||||
// Set parses a string of the form "min-max", inclusive at both ends, and
|
||||
// Set parses a string of the form "value", "min-max", or "min+offset", inclusive at both ends, and
|
||||
// sets the PortRange from it. This is part of the flag.Value and pflag.Value
|
||||
// interfaces.
|
||||
func (pr *PortRange) Set(value string) error {
|
||||
value = strings.TrimSpace(value)
|
||||
const (
|
||||
SinglePortNotation = 1 << iota
|
||||
HyphenNotation
|
||||
PlusNotation
|
||||
)
|
||||
|
||||
// TODO: Accept "80" syntax
|
||||
// TODO: Accept "80+8" syntax
|
||||
value = strings.TrimSpace(value)
|
||||
hyphenIndex := strings.Index(value, "-")
|
||||
plusIndex := strings.Index(value, "+")
|
||||
|
||||
if value == "" {
|
||||
pr.Base = 0
|
||||
@@ -58,20 +63,51 @@ func (pr *PortRange) Set(value string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
hyphenIndex := strings.Index(value, "-")
|
||||
if hyphenIndex == -1 {
|
||||
return fmt.Errorf("expected hyphen in port range")
|
||||
var err error
|
||||
var low, high int
|
||||
var notation int
|
||||
|
||||
if plusIndex == -1 && hyphenIndex == -1 {
|
||||
notation |= SinglePortNotation
|
||||
}
|
||||
if hyphenIndex != -1 {
|
||||
notation |= HyphenNotation
|
||||
}
|
||||
if plusIndex != -1 {
|
||||
notation |= PlusNotation
|
||||
}
|
||||
|
||||
var err error
|
||||
var low int
|
||||
var high int
|
||||
low, err = strconv.Atoi(value[:hyphenIndex])
|
||||
if err == nil {
|
||||
switch notation {
|
||||
case SinglePortNotation:
|
||||
var port int
|
||||
port, err = strconv.Atoi(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
low = port
|
||||
high = port
|
||||
case HyphenNotation:
|
||||
low, err = strconv.Atoi(value[:hyphenIndex])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
high, err = strconv.Atoi(value[hyphenIndex+1:])
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to parse port range: %s: %v", value, err)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case PlusNotation:
|
||||
var offset int
|
||||
low, err = strconv.Atoi(value[:plusIndex])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
offset, err = strconv.Atoi(value[plusIndex+1:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
high = low + offset
|
||||
default:
|
||||
return fmt.Errorf("unable to parse port range: %s", value)
|
||||
}
|
||||
|
||||
if low > 65535 || high > 65535 {
|
||||
|
||||
12
vendor/k8s.io/apimachinery/pkg/util/net/port_range_test.go
generated
vendored
12
vendor/k8s.io/apimachinery/pkg/util/net/port_range_test.go
generated
vendored
@@ -34,13 +34,21 @@ func TestPortRange(t *testing.T) {
|
||||
{" 100-200 ", true, "100-200", 200, 201},
|
||||
{"0-0", true, "0-0", 0, 1},
|
||||
{"", true, "", -1, 0},
|
||||
{"100", false, "", -1, -1},
|
||||
{"100", true, "100-100", 100, 101},
|
||||
{"100 - 200", false, "", -1, -1},
|
||||
{"-100", false, "", -1, -1},
|
||||
{"100-", false, "", -1, -1},
|
||||
{"200-100", false, "", -1, -1},
|
||||
{"60000-70000", false, "", -1, -1},
|
||||
{"70000-80000", false, "", -1, -1},
|
||||
{"70000+80000", false, "", -1, -1},
|
||||
{"1+0", true, "1-1", 1, 2},
|
||||
{"0+0", true, "0-0", 0, 1},
|
||||
{"1+-1", false, "", -1, -1},
|
||||
{"1-+1", false, "", -1, -1},
|
||||
{"100+200", true, "100-300", 300, 301},
|
||||
{"1+65535", false, "", -1, -1},
|
||||
{"0+65535", true, "0-65535", 65535, 65536},
|
||||
}
|
||||
|
||||
for i := range testCases {
|
||||
@@ -52,7 +60,7 @@ func TestPortRange(t *testing.T) {
|
||||
t.Errorf("expected success, got %q", err)
|
||||
continue
|
||||
} else if err == nil && tc.success == false {
|
||||
t.Errorf("expected failure")
|
||||
t.Errorf("expected failure %#v", testCases[i])
|
||||
continue
|
||||
} else if tc.success {
|
||||
if f.String() != tc.expected {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user