mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
vendor updates
This commit is contained in:
3
vendor/k8s.io/apimachinery/pkg/runtime/serializer/BUILD
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/runtime/serializer/BUILD
generated
vendored
@ -9,8 +9,7 @@ load(
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["codec_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer",
|
||||
library = ":go_default_library",
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/github.com/ghodss/yaml:go_default_library",
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
|
4
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/BUILD
generated
vendored
4
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/BUILD
generated
vendored
@ -9,8 +9,7 @@ load(
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["meta_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/json",
|
||||
library = ":go_default_library",
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
@ -34,7 +33,6 @@ go_library(
|
||||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["json_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/json_test",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
|
58
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go
generated
vendored
58
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go
generated
vendored
@ -98,11 +98,29 @@ func init() {
|
||||
jsoniter.RegisterTypeDecoderFunc("interface {}", decodeNumberAsInt64IfPossible)
|
||||
}
|
||||
|
||||
// gvkWithDefaults returns group kind and version defaulting from provided default
|
||||
func gvkWithDefaults(actual, defaultGVK schema.GroupVersionKind) schema.GroupVersionKind {
|
||||
if len(actual.Kind) == 0 {
|
||||
actual.Kind = defaultGVK.Kind
|
||||
}
|
||||
if len(actual.Version) == 0 && len(actual.Group) == 0 {
|
||||
actual.Group = defaultGVK.Group
|
||||
actual.Version = defaultGVK.Version
|
||||
}
|
||||
if len(actual.Version) == 0 && actual.Group == defaultGVK.Group {
|
||||
actual.Version = defaultGVK.Version
|
||||
}
|
||||
return actual
|
||||
}
|
||||
|
||||
// Decode attempts to convert the provided data into YAML or JSON, extract the stored schema kind, apply the provided default gvk, and then
|
||||
// load that data into an object matching the desired schema kind or the provided into. If into is *runtime.Unknown, the raw data will be
|
||||
// extracted and no decoding will be performed. If into is not registered with the typer, then the object will be straight decoded using
|
||||
// normal JSON/YAML unmarshalling. If into is provided and the original data is not fully qualified with kind/version/group, the type of
|
||||
// the into will be used to alter the returned gvk. On success or most errors, the method will return the calculated schema kind.
|
||||
// load that data into an object matching the desired schema kind or the provided into.
|
||||
// If into is *runtime.Unknown, the raw data will be extracted and no decoding will be performed.
|
||||
// If into is not registered with the typer, then the object will be straight decoded using normal JSON/YAML unmarshalling.
|
||||
// If into is provided and the original data is not fully qualified with kind/version/group, the type of the into will be used to alter the returned gvk.
|
||||
// If into is nil or data's gvk different from into's gvk, it will generate a new Object with ObjectCreater.New(gvk)
|
||||
// On success or most errors, the method will return the calculated schema kind.
|
||||
// The gvk calculate priority will be originalData > default gvk > into
|
||||
func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, into runtime.Object) (runtime.Object, *schema.GroupVersionKind, error) {
|
||||
if versioned, ok := into.(*runtime.VersionedObjects); ok {
|
||||
into = versioned.Last()
|
||||
@ -129,17 +147,7 @@ func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, i
|
||||
}
|
||||
|
||||
if gvk != nil {
|
||||
// apply kind and version defaulting from provided default
|
||||
if len(actual.Kind) == 0 {
|
||||
actual.Kind = gvk.Kind
|
||||
}
|
||||
if len(actual.Version) == 0 && len(actual.Group) == 0 {
|
||||
actual.Group = gvk.Group
|
||||
actual.Version = gvk.Version
|
||||
}
|
||||
if len(actual.Version) == 0 && actual.Group == gvk.Group {
|
||||
actual.Version = gvk.Version
|
||||
}
|
||||
*actual = gvkWithDefaults(*actual, *gvk)
|
||||
}
|
||||
|
||||
if unk, ok := into.(*runtime.Unknown); ok && unk != nil {
|
||||
@ -154,24 +162,14 @@ 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.ConfigFastest.Unmarshal(data, into); err != nil {
|
||||
if err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(data, into); err != nil {
|
||||
return nil, actual, err
|
||||
}
|
||||
return into, actual, nil
|
||||
case err != nil:
|
||||
return nil, actual, err
|
||||
default:
|
||||
typed := types[0]
|
||||
if len(actual.Kind) == 0 {
|
||||
actual.Kind = typed.Kind
|
||||
}
|
||||
if len(actual.Version) == 0 && len(actual.Group) == 0 {
|
||||
actual.Group = typed.Group
|
||||
actual.Version = typed.Version
|
||||
}
|
||||
if len(actual.Version) == 0 && actual.Group == typed.Group {
|
||||
actual.Version = typed.Version
|
||||
}
|
||||
*actual = gvkWithDefaults(*actual, types[0])
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,7 +186,7 @@ func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, i
|
||||
return nil, actual, err
|
||||
}
|
||||
|
||||
if err := jsoniter.ConfigFastest.Unmarshal(data, obj); err != nil {
|
||||
if err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(data, obj); err != nil {
|
||||
return nil, actual, err
|
||||
}
|
||||
return obj, actual, nil
|
||||
@ -197,7 +195,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.ConfigFastest.Marshal(obj)
|
||||
json, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -210,7 +208,7 @@ func (s *Serializer) Encode(obj runtime.Object, w io.Writer) error {
|
||||
}
|
||||
|
||||
if s.pretty {
|
||||
data, err := jsoniter.ConfigFastest.MarshalIndent(obj, "", " ")
|
||||
data, err := jsoniter.ConfigCompatibleWithStandardLibrary.MarshalIndent(obj, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
26
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json_test.go
generated
vendored
26
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json_test.go
generated
vendored
@ -94,6 +94,32 @@ func TestDecode(t *testing.T) {
|
||||
expectedObject: &testDecodable{},
|
||||
expectedGVK: &schema.GroupVersionKind{Kind: "Test", Group: "other", Version: "blah"},
|
||||
},
|
||||
// group version, kind is defaulted
|
||||
{
|
||||
data: []byte(`{"apiVersion":"other1/blah1"}`),
|
||||
defaultGVK: &schema.GroupVersionKind{Kind: "Test", Group: "other", Version: "blah"},
|
||||
creater: &mockCreater{obj: &testDecodable{}},
|
||||
expectedObject: &testDecodable{},
|
||||
expectedGVK: &schema.GroupVersionKind{Kind: "Test", Group: "other1", Version: "blah1"},
|
||||
},
|
||||
// gvk all provided then not defaulted at all
|
||||
{
|
||||
data: []byte(`{"kind":"Test","apiVersion":"other/blah"}`),
|
||||
defaultGVK: &schema.GroupVersionKind{Kind: "Test1", Group: "other1", Version: "blah1"},
|
||||
creater: &mockCreater{obj: &testDecodable{}},
|
||||
expectedObject: &testDecodable{},
|
||||
expectedGVK: &schema.GroupVersionKind{Kind: "Test", Group: "other", Version: "blah"},
|
||||
},
|
||||
//gvk defaulting if kind not provided in data and defaultGVK use into's kind
|
||||
{
|
||||
data: []byte(`{"apiVersion":"b1/c1"}`),
|
||||
into: &testDecodable{gvk: schema.GroupVersionKind{Kind: "a3", Group: "b1", Version: "c1"}},
|
||||
typer: &mockTyper{gvk: &schema.GroupVersionKind{Kind: "a3", Group: "b1", Version: "c1"}},
|
||||
defaultGVK: nil,
|
||||
creater: &mockCreater{obj: &testDecodable{}},
|
||||
expectedObject: &testDecodable{gvk: schema.GroupVersionKind{Kind: "a3", Group: "b1", Version: "c1"}},
|
||||
expectedGVK: &schema.GroupVersionKind{Kind: "a3", Group: "b1", Version: "c1"},
|
||||
},
|
||||
|
||||
// accept runtime.Unknown as into and bypass creator
|
||||
{
|
||||
|
1
vendor/k8s.io/apimachinery/pkg/runtime/serializer/recognizer/testing/BUILD
generated
vendored
1
vendor/k8s.io/apimachinery/pkg/runtime/serializer/recognizer/testing/BUILD
generated
vendored
@ -8,7 +8,6 @@ load(
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["recognizer_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/recognizer/testing",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
|
3
vendor/k8s.io/apimachinery/pkg/runtime/serializer/streaming/BUILD
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/runtime/serializer/streaming/BUILD
generated
vendored
@ -9,8 +9,7 @@ load(
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["streaming_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
|
||||
library = ":go_default_library",
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
|
17
vendor/k8s.io/apimachinery/pkg/runtime/serializer/testing/zz_generated.deepcopy.go
generated
vendored
17
vendor/k8s.io/apimachinery/pkg/runtime/serializer/testing/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 testing
|
||||
|
||||
@ -46,9 +46,8 @@ func (in *ExternalInternalSame) DeepCopy() *ExternalInternalSame {
|
||||
func (in *ExternalInternalSame) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
@ -100,9 +99,8 @@ func (in *ExternalTestType1) DeepCopy() *ExternalTestType1 {
|
||||
func (in *ExternalTestType1) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
@ -125,9 +123,8 @@ func (in *ExternalTestType2) DeepCopy() *ExternalTestType2 {
|
||||
func (in *ExternalTestType2) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
@ -179,9 +176,8 @@ func (in *TestType1) DeepCopy() *TestType1 {
|
||||
func (in *TestType1) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
@ -204,7 +200,6 @@ func (in *TestType2) DeepCopy() *TestType2 {
|
||||
func (in *TestType2) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
3
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/BUILD
generated
vendored
3
vendor/k8s.io/apimachinery/pkg/runtime/serializer/versioning/BUILD
generated
vendored
@ -9,8 +9,7 @@ load(
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["versioning_test.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
|
||||
library = ":go_default_library",
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
|
Reference in New Issue
Block a user