mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
vendor updates
This commit is contained in:
3
vendor/k8s.io/apimachinery/pkg/api/errors/BUILD
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/api/errors/BUILD
generated
vendored
@ -9,8 +9,7 @@ load(
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["errors_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/errors",
|
||||
library = ":go_default_library",
|
||||
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",
|
||||
|
1
vendor/k8s.io/apimachinery/pkg/api/errors/OWNERS
generated
vendored
1
vendor/k8s.io/apimachinery/pkg/api/errors/OWNERS
generated
vendored
@ -16,7 +16,6 @@ reviewers:
|
||||
- janetkuo
|
||||
- tallclair
|
||||
- eparis
|
||||
- timothysc
|
||||
- dims
|
||||
- hongchaodeng
|
||||
- krousey
|
||||
|
21
vendor/k8s.io/apimachinery/pkg/api/errors/errors.go
generated
vendored
21
vendor/k8s.io/apimachinery/pkg/api/errors/errors.go
generated
vendored
@ -352,12 +352,23 @@ func NewGenericServerResponse(code int, verb string, qualifiedResource schema.Gr
|
||||
reason = metav1.StatusReasonForbidden
|
||||
// the server message has details about who is trying to perform what action. Keep its message.
|
||||
message = serverMessage
|
||||
case http.StatusNotAcceptable:
|
||||
reason = metav1.StatusReasonNotAcceptable
|
||||
// the server message has details about what types are acceptable
|
||||
message = serverMessage
|
||||
case http.StatusUnsupportedMediaType:
|
||||
reason = metav1.StatusReasonUnsupportedMediaType
|
||||
// the server message has details about what types are acceptable
|
||||
message = serverMessage
|
||||
case http.StatusMethodNotAllowed:
|
||||
reason = metav1.StatusReasonMethodNotAllowed
|
||||
message = "the server does not allow this method on the requested resource"
|
||||
case http.StatusUnprocessableEntity:
|
||||
reason = metav1.StatusReasonInvalid
|
||||
message = "the server rejected our request due to an error in our request"
|
||||
case http.StatusServiceUnavailable:
|
||||
reason = metav1.StatusReasonServiceUnavailable
|
||||
message = "the server is currently unable to handle the request"
|
||||
case http.StatusGatewayTimeout:
|
||||
reason = metav1.StatusReasonTimeout
|
||||
message = "the server was unable to return a response in the time allotted, but may still be processing the request"
|
||||
@ -434,6 +445,16 @@ func IsResourceExpired(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonExpired
|
||||
}
|
||||
|
||||
// IsNotAcceptable determines if err is an error which indicates that the request failed due to an invalid Accept header
|
||||
func IsNotAcceptable(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonNotAcceptable
|
||||
}
|
||||
|
||||
// IsUnsupportedMediaType determines if err is an error which indicates that the request failed due to an invalid Content-Type header
|
||||
func IsUnsupportedMediaType(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonUnsupportedMediaType
|
||||
}
|
||||
|
||||
// IsMethodNotSupported determines if the err is an error which indicates the provided action could not
|
||||
// be performed because it is not supported by the server.
|
||||
func IsMethodNotSupported(err error) bool {
|
||||
|
13
vendor/k8s.io/apimachinery/pkg/api/meta/BUILD
generated
vendored
13
vendor/k8s.io/apimachinery/pkg/api/meta/BUILD
generated
vendored
@ -14,12 +14,11 @@ go_test(
|
||||
"priority_test.go",
|
||||
"restmapper_test.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/meta",
|
||||
library = ":go_default_library",
|
||||
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/v1alpha1: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",
|
||||
@ -46,12 +45,13 @@ go_library(
|
||||
"//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/v1alpha1: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",
|
||||
],
|
||||
)
|
||||
|
||||
@ -64,6 +64,9 @@ filegroup(
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/meta/table:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
20
vendor/k8s.io/apimachinery/pkg/api/meta/errors.go
generated
vendored
20
vendor/k8s.io/apimachinery/pkg/api/meta/errors.go
generated
vendored
@ -20,6 +20,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
)
|
||||
|
||||
// AmbiguousResourceError is returned if the RESTMapper finds multiple matches for a resource
|
||||
@ -85,11 +86,26 @@ func (e *NoResourceMatchError) Error() string {
|
||||
|
||||
// NoKindMatchError is returned if the RESTMapper can't find any match for a kind
|
||||
type NoKindMatchError struct {
|
||||
PartialKind schema.GroupVersionKind
|
||||
// GroupKind is the API group and kind that was searched
|
||||
GroupKind schema.GroupKind
|
||||
// SearchedVersions is the optional list of versions the search was restricted to
|
||||
SearchedVersions []string
|
||||
}
|
||||
|
||||
func (e *NoKindMatchError) Error() string {
|
||||
return fmt.Sprintf("no matches for %v", e.PartialKind)
|
||||
searchedVersions := sets.NewString()
|
||||
for _, v := range e.SearchedVersions {
|
||||
searchedVersions.Insert(schema.GroupVersion{Group: e.GroupKind.Group, Version: v}.String())
|
||||
}
|
||||
|
||||
switch len(searchedVersions) {
|
||||
case 0:
|
||||
return fmt.Sprintf("no matches for kind %q in group %q", e.GroupKind.Kind, e.GroupKind.Group)
|
||||
case 1:
|
||||
return fmt.Sprintf("no matches for kind %q in version %q", e.GroupKind.Kind, searchedVersions.List()[0])
|
||||
default:
|
||||
return fmt.Sprintf("no matches for kind %q in versions %q", e.GroupKind.Kind, searchedVersions.List())
|
||||
}
|
||||
}
|
||||
|
||||
func IsNoMatchError(err error) bool {
|
||||
|
8
vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
generated
vendored
8
vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
generated
vendored
@ -23,7 +23,7 @@ import (
|
||||
"github.com/golang/glog"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
metav1alpha1 "k8s.io/apimachinery/pkg/apis/meta/v1alpha1"
|
||||
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
@ -118,12 +118,12 @@ func Accessor(obj interface{}) (metav1.Object, error) {
|
||||
|
||||
// AsPartialObjectMetadata takes the metav1 interface and returns a partial object.
|
||||
// TODO: consider making this solely a conversion action.
|
||||
func AsPartialObjectMetadata(m metav1.Object) *metav1alpha1.PartialObjectMetadata {
|
||||
func AsPartialObjectMetadata(m metav1.Object) *metav1beta1.PartialObjectMetadata {
|
||||
switch t := m.(type) {
|
||||
case *metav1.ObjectMeta:
|
||||
return &metav1alpha1.PartialObjectMetadata{ObjectMeta: *t}
|
||||
return &metav1beta1.PartialObjectMetadata{ObjectMeta: *t}
|
||||
default:
|
||||
return &metav1alpha1.PartialObjectMetadata{
|
||||
return &metav1beta1.PartialObjectMetadata{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: m.GetName(),
|
||||
GenerateName: m.GetGenerateName(),
|
||||
|
4
vendor/k8s.io/apimachinery/pkg/api/meta/meta_test.go
generated
vendored
4
vendor/k8s.io/apimachinery/pkg/api/meta/meta_test.go
generated
vendored
@ -22,7 +22,7 @@ import (
|
||||
"testing"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
metav1alpha1 "k8s.io/apimachinery/pkg/apis/meta/v1alpha1"
|
||||
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/util/diff"
|
||||
|
||||
fuzz "github.com/google/gofuzz"
|
||||
@ -41,7 +41,7 @@ func TestAsPartialObjectMetadata(t *testing.T) {
|
||||
}
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
m := &metav1alpha1.PartialObjectMetadata{}
|
||||
m := &metav1beta1.PartialObjectMetadata{}
|
||||
f.Fuzz(&m.ObjectMeta)
|
||||
partial := AsPartialObjectMetadata(m)
|
||||
if !reflect.DeepEqual(&partial.ObjectMeta, &m.ObjectMeta) {
|
||||
|
4
vendor/k8s.io/apimachinery/pkg/api/meta/multirestmapper.go
generated
vendored
4
vendor/k8s.io/apimachinery/pkg/api/meta/multirestmapper.go
generated
vendored
@ -179,7 +179,7 @@ func (m MultiRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (*
|
||||
if len(errors) > 0 {
|
||||
return nil, utilerrors.NewAggregate(errors)
|
||||
}
|
||||
return nil, &NoKindMatchError{PartialKind: gk.WithVersion("")}
|
||||
return nil, &NoKindMatchError{GroupKind: gk, SearchedVersions: versions}
|
||||
}
|
||||
|
||||
// RESTMappings returns all possible RESTMappings for the provided group kind, or an error
|
||||
@ -204,7 +204,7 @@ func (m MultiRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) (
|
||||
return nil, utilerrors.NewAggregate(errors)
|
||||
}
|
||||
if len(allMappings) == 0 {
|
||||
return nil, &NoKindMatchError{PartialKind: gk.WithVersion("")}
|
||||
return nil, &NoKindMatchError{GroupKind: gk, SearchedVersions: versions}
|
||||
}
|
||||
return allMappings, nil
|
||||
}
|
||||
|
84
vendor/k8s.io/apimachinery/pkg/api/meta/multirestmapper_test.go
generated
vendored
84
vendor/k8s.io/apimachinery/pkg/api/meta/multirestmapper_test.go
generated
vendored
@ -261,42 +261,78 @@ func TestMultiRESTMapperRESTMappings(t *testing.T) {
|
||||
tcs := []struct {
|
||||
name string
|
||||
|
||||
mapper MultiRESTMapper
|
||||
input schema.GroupKind
|
||||
result []*RESTMapping
|
||||
err error
|
||||
mapper MultiRESTMapper
|
||||
groupKind schema.GroupKind
|
||||
versions []string
|
||||
result []*RESTMapping
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "empty",
|
||||
mapper: MultiRESTMapper{},
|
||||
input: schema.GroupKind{Kind: "Foo"},
|
||||
result: nil,
|
||||
err: &NoKindMatchError{PartialKind: schema.GroupVersionKind{Kind: "Foo"}},
|
||||
name: "empty with no versions",
|
||||
mapper: MultiRESTMapper{},
|
||||
groupKind: schema.GroupKind{Kind: "Foo"},
|
||||
result: nil,
|
||||
err: &NoKindMatchError{GroupKind: schema.GroupKind{Kind: "Foo"}},
|
||||
},
|
||||
{
|
||||
name: "ignore not found",
|
||||
mapper: MultiRESTMapper{fixedRESTMapper{err: &NoKindMatchError{PartialKind: schema.GroupVersionKind{Kind: "IGNORE_THIS"}}}},
|
||||
input: schema.GroupKind{Kind: "Foo"},
|
||||
result: nil,
|
||||
err: &NoKindMatchError{PartialKind: schema.GroupVersionKind{Kind: "Foo"}},
|
||||
name: "empty with one version",
|
||||
mapper: MultiRESTMapper{},
|
||||
groupKind: schema.GroupKind{Kind: "Foo"},
|
||||
versions: []string{"v1beta"},
|
||||
result: nil,
|
||||
err: &NoKindMatchError{GroupKind: schema.GroupKind{Kind: "Foo"}, SearchedVersions: []string{"v1beta"}},
|
||||
},
|
||||
{
|
||||
name: "accept first failure",
|
||||
mapper: MultiRESTMapper{fixedRESTMapper{err: errors.New("fail on this")}, fixedRESTMapper{mappings: []*RESTMapping{mapping1}}},
|
||||
input: schema.GroupKind{Kind: "Foo"},
|
||||
result: nil,
|
||||
err: errors.New("fail on this"),
|
||||
name: "empty with multi(two) vesions",
|
||||
mapper: MultiRESTMapper{},
|
||||
groupKind: schema.GroupKind{Kind: "Foo"},
|
||||
versions: []string{"v1beta", "v2"},
|
||||
result: nil,
|
||||
err: &NoKindMatchError{GroupKind: schema.GroupKind{Kind: "Foo"}, SearchedVersions: []string{"v1beta", "v2"}},
|
||||
},
|
||||
{
|
||||
name: "return both",
|
||||
mapper: MultiRESTMapper{fixedRESTMapper{mappings: []*RESTMapping{mapping1}}, fixedRESTMapper{mappings: []*RESTMapping{mapping2}}},
|
||||
input: schema.GroupKind{Kind: "Foo"},
|
||||
result: []*RESTMapping{mapping1, mapping2},
|
||||
name: "ignore not found with kind not exist",
|
||||
mapper: MultiRESTMapper{fixedRESTMapper{err: &NoKindMatchError{GroupKind: schema.GroupKind{Kind: "IGNORE_THIS"}}}},
|
||||
groupKind: schema.GroupKind{Kind: "Foo"},
|
||||
versions: nil,
|
||||
result: nil,
|
||||
err: &NoKindMatchError{GroupKind: schema.GroupKind{Kind: "Foo"}},
|
||||
},
|
||||
{
|
||||
name: "ignore not found with version not exist",
|
||||
mapper: MultiRESTMapper{fixedRESTMapper{err: &NoKindMatchError{GroupKind: schema.GroupKind{Kind: "Foo"}, SearchedVersions: []string{"v1"}}}},
|
||||
groupKind: schema.GroupKind{Kind: "Foo"},
|
||||
versions: []string{"v1beta"},
|
||||
result: nil,
|
||||
err: &NoKindMatchError{GroupKind: schema.GroupKind{Kind: "Foo"}, SearchedVersions: []string{"v1beta"}},
|
||||
},
|
||||
{
|
||||
name: "ignore not found with multi versions not exist",
|
||||
mapper: MultiRESTMapper{fixedRESTMapper{err: &NoKindMatchError{GroupKind: schema.GroupKind{Kind: "Foo"}, SearchedVersions: []string{"v1"}}}},
|
||||
groupKind: schema.GroupKind{Kind: "Foo"},
|
||||
versions: []string{"v1beta", "v2"},
|
||||
result: nil,
|
||||
err: &NoKindMatchError{GroupKind: schema.GroupKind{Kind: "Foo"}, SearchedVersions: []string{"v1beta", "v2"}},
|
||||
},
|
||||
{
|
||||
name: "accept first failure",
|
||||
mapper: MultiRESTMapper{fixedRESTMapper{err: errors.New("fail on this")}, fixedRESTMapper{mappings: []*RESTMapping{mapping1}}},
|
||||
groupKind: schema.GroupKind{Kind: "Foo"},
|
||||
versions: []string{"v1beta"},
|
||||
result: nil,
|
||||
err: errors.New("fail on this"),
|
||||
},
|
||||
{
|
||||
name: "return both",
|
||||
mapper: MultiRESTMapper{fixedRESTMapper{mappings: []*RESTMapping{mapping1}}, fixedRESTMapper{mappings: []*RESTMapping{mapping2}}},
|
||||
groupKind: schema.GroupKind{Kind: "Foo"},
|
||||
versions: []string{"v1beta"},
|
||||
result: []*RESTMapping{mapping1, mapping2},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tcs {
|
||||
actualResult, actualErr := tc.mapper.RESTMappings(tc.input)
|
||||
actualResult, actualErr := tc.mapper.RESTMappings(tc.groupKind, tc.versions...)
|
||||
if e, a := tc.result, actualResult; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%s: expected %v, got %v", tc.name, e, a)
|
||||
}
|
||||
|
2
vendor/k8s.io/apimachinery/pkg/api/meta/priority.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/api/meta/priority.go
generated
vendored
@ -153,7 +153,7 @@ func kindMatches(pattern schema.GroupVersionKind, kind schema.GroupVersionKind)
|
||||
}
|
||||
|
||||
func (m PriorityRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (mapping *RESTMapping, err error) {
|
||||
mappings, err := m.Delegate.RESTMappings(gk)
|
||||
mappings, err := m.Delegate.RESTMappings(gk, versions...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
6
vendor/k8s.io/apimachinery/pkg/api/meta/priority_test.go
generated
vendored
6
vendor/k8s.io/apimachinery/pkg/api/meta/priority_test.go
generated
vendored
@ -234,13 +234,13 @@ func TestPriorityRESTMapperRESTMapping(t *testing.T) {
|
||||
name: "empty",
|
||||
mapper: PriorityRESTMapper{Delegate: MultiRESTMapper{}},
|
||||
input: schema.GroupKind{Kind: "Foo"},
|
||||
err: &NoKindMatchError{PartialKind: schema.GroupVersionKind{Kind: "Foo"}},
|
||||
err: &NoKindMatchError{GroupKind: schema.GroupKind{Kind: "Foo"}},
|
||||
},
|
||||
{
|
||||
name: "ignore not found",
|
||||
mapper: PriorityRESTMapper{Delegate: MultiRESTMapper{fixedRESTMapper{err: &NoKindMatchError{PartialKind: schema.GroupVersionKind{Kind: "IGNORE_THIS"}}}}},
|
||||
mapper: PriorityRESTMapper{Delegate: MultiRESTMapper{fixedRESTMapper{err: &NoKindMatchError{GroupKind: schema.GroupKind{Kind: "IGNORE_THIS"}}}}},
|
||||
input: schema.GroupKind{Kind: "Foo"},
|
||||
err: &NoKindMatchError{PartialKind: schema.GroupVersionKind{Kind: "Foo"}},
|
||||
err: &NoKindMatchError{GroupKind: schema.GroupKind{Kind: "Foo"}},
|
||||
},
|
||||
{
|
||||
name: "accept first failure",
|
||||
|
4
vendor/k8s.io/apimachinery/pkg/api/meta/restmapper.go
generated
vendored
4
vendor/k8s.io/apimachinery/pkg/api/meta/restmapper.go
generated
vendored
@ -472,7 +472,7 @@ func (m *DefaultRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string)
|
||||
return nil, err
|
||||
}
|
||||
if len(mappings) == 0 {
|
||||
return nil, &NoKindMatchError{PartialKind: gk.WithVersion("")}
|
||||
return nil, &NoKindMatchError{GroupKind: gk, SearchedVersions: versions}
|
||||
}
|
||||
// since we rely on RESTMappings method
|
||||
// take the first match and return to the caller
|
||||
@ -510,7 +510,7 @@ func (m *DefaultRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string
|
||||
}
|
||||
|
||||
if len(potentialGVK) == 0 {
|
||||
return nil, &NoKindMatchError{PartialKind: gk.WithVersion("")}
|
||||
return nil, &NoKindMatchError{GroupKind: gk, SearchedVersions: versions}
|
||||
}
|
||||
|
||||
for _, gvk := range potentialGVK {
|
||||
|
2
vendor/k8s.io/apimachinery/pkg/api/meta/restmapper_test.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/api/meta/restmapper_test.go
generated
vendored
@ -507,7 +507,7 @@ func TestRESTMapperResourceSingularizer(t *testing.T) {
|
||||
|
||||
{Kind: "lowercase", Plural: "lowercases", Singular: "lowercase"},
|
||||
// TODO this test is broken. This updates to reflect actual behavior. Kinds are expected to be singular
|
||||
// old (incorrect), coment: Don't add extra s if the original object is already plural
|
||||
// old (incorrect), comment: Don't add extra s if the original object is already plural
|
||||
{Kind: "lowercases", Plural: "lowercaseses", Singular: "lowercases"},
|
||||
}
|
||||
for i, testCase := range testCases {
|
||||
|
29
vendor/k8s.io/apimachinery/pkg/api/meta/table/BUILD
generated
vendored
Normal file
29
vendor/k8s.io/apimachinery/pkg/api/meta/table/BUILD
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["table.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/meta/table",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta: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/util/duration: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"],
|
||||
)
|
71
vendor/k8s.io/apimachinery/pkg/api/meta/table/table.go
generated
vendored
Normal file
71
vendor/k8s.io/apimachinery/pkg/api/meta/table/table.go
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
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 table
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/duration"
|
||||
)
|
||||
|
||||
// MetaToTableRow converts a list or object into one or more table rows. The provided rowFn is invoked for
|
||||
// each accessed item, with name and age being passed to each.
|
||||
func MetaToTableRow(obj runtime.Object, rowFn func(obj runtime.Object, m metav1.Object, name, age string) ([]interface{}, error)) ([]metav1beta1.TableRow, error) {
|
||||
if meta.IsListType(obj) {
|
||||
rows := make([]metav1beta1.TableRow, 0, 16)
|
||||
err := meta.EachListItem(obj, func(obj runtime.Object) error {
|
||||
nestedRows, err := MetaToTableRow(obj, rowFn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rows = append(rows, nestedRows...)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
rows := make([]metav1beta1.TableRow, 0, 1)
|
||||
m, err := meta.Accessor(obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
row.Cells, err = rowFn(obj, m, m.GetName(), translateTimestamp(m.GetCreationTimestamp()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rows = append(rows, row)
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
// translateTimestamp returns the elapsed time since timestamp in
|
||||
// human-readable approximation.
|
||||
func translateTimestamp(timestamp metav1.Time) string {
|
||||
if timestamp.IsZero() {
|
||||
return "<unknown>"
|
||||
}
|
||||
return duration.ShortHumanDuration(time.Now().Sub(timestamp.Time))
|
||||
}
|
6
vendor/k8s.io/apimachinery/pkg/api/resource/BUILD
generated
vendored
6
vendor/k8s.io/apimachinery/pkg/api/resource/BUILD
generated
vendored
@ -15,8 +15,7 @@ go_test(
|
||||
"quantity_test.go",
|
||||
"scale_int_test.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/resource",
|
||||
library = ":go_default_library",
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
@ -38,18 +37,15 @@ go_library(
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/resource",
|
||||
deps = [
|
||||
"//vendor/github.com/go-openapi/spec:go_default_library",
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/gopkg.in/inf.v0:go_default_library",
|
||||
"//vendor/k8s.io/kube-openapi/pkg/common:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["quantity_example_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/resource_test",
|
||||
deps = ["//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library"],
|
||||
)
|
||||
|
||||
|
1
vendor/k8s.io/apimachinery/pkg/api/resource/OWNERS
generated
vendored
1
vendor/k8s.io/apimachinery/pkg/api/resource/OWNERS
generated
vendored
@ -9,7 +9,6 @@ reviewers:
|
||||
- janetkuo
|
||||
- tallclair
|
||||
- eparis
|
||||
- timothysc
|
||||
- jbeda
|
||||
- xiang90
|
||||
- mbohlool
|
||||
|
22
vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
22
vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
@ -27,9 +27,7 @@ import (
|
||||
|
||||
flag "github.com/spf13/pflag"
|
||||
|
||||
"github.com/go-openapi/spec"
|
||||
inf "gopkg.in/inf.v0"
|
||||
openapi "k8s.io/kube-openapi/pkg/common"
|
||||
)
|
||||
|
||||
// Quantity is a fixed-point representation of a number.
|
||||
@ -399,17 +397,15 @@ func (q Quantity) DeepCopy() Quantity {
|
||||
return q
|
||||
}
|
||||
|
||||
// OpenAPIDefinition returns openAPI definition for this type.
|
||||
func (_ Quantity) OpenAPIDefinition() openapi.OpenAPIDefinition {
|
||||
return openapi.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
// OpenAPISchemaType is used by the kube-openapi generator when constructing
|
||||
// the OpenAPI spec of this type.
|
||||
//
|
||||
// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators
|
||||
func (_ Quantity) OpenAPISchemaType() []string { return []string{"string"} }
|
||||
|
||||
// OpenAPISchemaFormat is used by the kube-openapi generator when constructing
|
||||
// the OpenAPI spec of this type.
|
||||
func (_ Quantity) OpenAPISchemaFormat() string { return "" }
|
||||
|
||||
// CanonicalizeBytes returns the canonical form of q and its suffix (see comment on Quantity).
|
||||
//
|
||||
|
2
vendor/k8s.io/apimachinery/pkg/api/resource/scale_int_test.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/api/resource/scale_int_test.go
generated
vendored
@ -45,7 +45,7 @@ func TestScaledValueInternal(t *testing.T) {
|
||||
{big.NewInt(1), 3, 0, 1},
|
||||
// large scaled value does not lose precision
|
||||
{big.NewInt(0).Sub(maxInt64, bigOne), 1, 0, (math.MaxInt64-1)/10 + 1},
|
||||
// large intermidiate result.
|
||||
// large intermediate result.
|
||||
{big.NewInt(1).Exp(big.NewInt(10), big.NewInt(100), nil), 100, 0, 1},
|
||||
|
||||
// scale up
|
||||
|
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
@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
|
||||
// Code generated by deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package resource
|
||||
|
||||
|
3
vendor/k8s.io/apimachinery/pkg/api/testing/fuzzer/BUILD
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/api/testing/fuzzer/BUILD
generated
vendored
@ -9,8 +9,7 @@ load(
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["valuefuzz_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/testing/fuzzer",
|
||||
library = ":go_default_library",
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
|
6
vendor/k8s.io/apimachinery/pkg/api/testing/roundtrip/roundtrip.go
generated
vendored
6
vendor/k8s.io/apimachinery/pkg/api/testing/roundtrip/roundtrip.go
generated
vendored
@ -277,12 +277,6 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object
|
||||
return
|
||||
}
|
||||
|
||||
// catch deepcopy errors early
|
||||
if !apiequality.Semantic.DeepEqual(original, object) {
|
||||
t.Errorf("%v: DeepCopy did not lead to equal object, diff: %v", name, diff.ObjectReflectDiff(original, object))
|
||||
return
|
||||
}
|
||||
|
||||
// encode (serialize) the deep copy using the provided codec
|
||||
data, err := runtime.Encode(codec, object)
|
||||
if err != nil {
|
||||
|
3
vendor/k8s.io/apimachinery/pkg/api/validation/BUILD
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/api/validation/BUILD
generated
vendored
@ -9,8 +9,7 @@ load(
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["objectmeta_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/validation",
|
||||
library = ":go_default_library",
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
||||
|
3
vendor/k8s.io/apimachinery/pkg/api/validation/path/BUILD
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/api/validation/path/BUILD
generated
vendored
@ -9,8 +9,7 @@ load(
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["name_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/validation/path",
|
||||
library = ":go_default_library",
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
|
Reference in New Issue
Block a user