From 43dac0bc4302fed79eaeb661723ca584a9c0496a Mon Sep 17 00:00:00 2001 From: HuabingZhao Date: Mon, 4 Sep 2017 15:00:54 +0800 Subject: restructure the source directory Issue-ID: OOM-61 Change-Id: Ib6f633d517ad197bfdbca59b374cdad2f1ed897e Signed-off-by: HuabingZhao --- .../vendor/k8s.io/kubernetes/pkg/runtime/OWNERS | 5 - .../vendor/k8s.io/kubernetes/pkg/runtime/codec.go | 198 ------ .../k8s.io/kubernetes/pkg/runtime/codec_check.go | 50 -- .../k8s.io/kubernetes/pkg/runtime/conversion.go | 98 --- .../kubernetes/pkg/runtime/deep_copy_generated.go | 63 -- .../vendor/k8s.io/kubernetes/pkg/runtime/doc.go | 45 -- .../k8s.io/kubernetes/pkg/runtime/embedded.go | 136 ---- .../vendor/k8s.io/kubernetes/pkg/runtime/error.go | 102 --- .../k8s.io/kubernetes/pkg/runtime/extension.go | 48 -- .../k8s.io/kubernetes/pkg/runtime/generated.pb.go | 689 --------------------- .../k8s.io/kubernetes/pkg/runtime/generated.proto | 124 ---- .../vendor/k8s.io/kubernetes/pkg/runtime/helper.go | 212 ------- .../k8s.io/kubernetes/pkg/runtime/interfaces.go | 217 ------- .../k8s.io/kubernetes/pkg/runtime/register.go | 66 -- .../vendor/k8s.io/kubernetes/pkg/runtime/scheme.go | 623 ------------------- .../pkg/runtime/serializer/codec_factory.go | 364 ----------- .../kubernetes/pkg/runtime/serializer/json/json.go | 243 -------- .../kubernetes/pkg/runtime/serializer/json/meta.go | 61 -- .../pkg/runtime/serializer/negotiated_codec.go | 57 -- .../pkg/runtime/serializer/protobuf/doc.go | 18 - .../pkg/runtime/serializer/protobuf/protobuf.go | 433 ------------- .../pkg/runtime/serializer/protobuf_extension.go | 52 -- .../runtime/serializer/recognizer/recognizer.go | 127 ---- .../pkg/runtime/serializer/streaming/streaming.go | 137 ---- .../runtime/serializer/versioning/versioning.go | 275 -------- .../pkg/runtime/swagger_doc_generator.go | 262 -------- .../vendor/k8s.io/kubernetes/pkg/runtime/types.go | 514 --------------- .../k8s.io/kubernetes/pkg/runtime/types_proto.go | 69 --- .../k8s.io/kubernetes/pkg/runtime/unstructured.go | 199 ------ 29 files changed, 5487 deletions(-) delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/OWNERS delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/codec.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/codec_check.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/conversion.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/deep_copy_generated.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/doc.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/embedded.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/error.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/extension.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/generated.pb.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/generated.proto delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/helper.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/interfaces.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/register.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/scheme.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/codec_factory.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/json/json.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/json/meta.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/negotiated_codec.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/protobuf/doc.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/protobuf/protobuf.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/protobuf_extension.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/recognizer/recognizer.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/streaming/streaming.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/swagger_doc_generator.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/types.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/types_proto.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/unstructured.go (limited to 'kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime') diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/OWNERS b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/OWNERS deleted file mode 100644 index d038b5e..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/OWNERS +++ /dev/null @@ -1,5 +0,0 @@ -assignees: - - caesarxuchao - - deads2k - - lavalamp - - smarterclayton diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/codec.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/codec.go deleted file mode 100644 index 3f7681c..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/codec.go +++ /dev/null @@ -1,198 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package runtime - -import ( - "bytes" - "encoding/base64" - "fmt" - "io" - "net/url" - "reflect" - - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/conversion/queryparams" -) - -// codec binds an encoder and decoder. -type codec struct { - Encoder - Decoder -} - -// NewCodec creates a Codec from an Encoder and Decoder. -func NewCodec(e Encoder, d Decoder) Codec { - return codec{e, d} -} - -// Encode is a convenience wrapper for encoding to a []byte from an Encoder -func Encode(e Encoder, obj Object) ([]byte, error) { - // TODO: reuse buffer - buf := &bytes.Buffer{} - if err := e.Encode(obj, buf); err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// Decode is a convenience wrapper for decoding data into an Object. -func Decode(d Decoder, data []byte) (Object, error) { - obj, _, err := d.Decode(data, nil, nil) - return obj, err -} - -// DecodeInto performs a Decode into the provided object. -func DecodeInto(d Decoder, data []byte, into Object) error { - out, gvk, err := d.Decode(data, nil, into) - if err != nil { - return err - } - if out != into { - return fmt.Errorf("unable to decode %s into %v", gvk, reflect.TypeOf(into)) - } - return nil -} - -// EncodeOrDie is a version of Encode which will panic instead of returning an error. For tests. -func EncodeOrDie(e Encoder, obj Object) string { - bytes, err := Encode(e, obj) - if err != nil { - panic(err) - } - return string(bytes) -} - -// UseOrCreateObject returns obj if the canonical ObjectKind returned by the provided typer matches gvk, or -// invokes the ObjectCreator to instantiate a new gvk. Returns an error if the typer cannot find the object. -func UseOrCreateObject(t ObjectTyper, c ObjectCreater, gvk unversioned.GroupVersionKind, obj Object) (Object, error) { - if obj != nil { - into, _, err := t.ObjectKinds(obj) - if err != nil { - return nil, err - } - if gvk == into[0] { - return obj, nil - } - } - return c.New(gvk) -} - -// NoopEncoder converts an Decoder to a Serializer or Codec for code that expects them but only uses decoding. -type NoopEncoder struct { - Decoder -} - -var _ Serializer = NoopEncoder{} - -func (n NoopEncoder) Encode(obj Object, w io.Writer) error { - return fmt.Errorf("encoding is not allowed for this codec: %v", reflect.TypeOf(n.Decoder)) -} - -// NoopDecoder converts an Encoder to a Serializer or Codec for code that expects them but only uses encoding. -type NoopDecoder struct { - Encoder -} - -var _ Serializer = NoopDecoder{} - -func (n NoopDecoder) Decode(data []byte, gvk *unversioned.GroupVersionKind, into Object) (Object, *unversioned.GroupVersionKind, error) { - return nil, nil, fmt.Errorf("decoding is not allowed for this codec: %v", reflect.TypeOf(n.Encoder)) -} - -// NewParameterCodec creates a ParameterCodec capable of transforming url values into versioned objects and back. -func NewParameterCodec(scheme *Scheme) ParameterCodec { - return ¶meterCodec{ - typer: scheme, - convertor: scheme, - creator: scheme, - } -} - -// parameterCodec implements conversion to and from query parameters and objects. -type parameterCodec struct { - typer ObjectTyper - convertor ObjectConvertor - creator ObjectCreater -} - -var _ ParameterCodec = ¶meterCodec{} - -// DecodeParameters converts the provided url.Values into an object of type From with the kind of into, and then -// converts that object to into (if necessary). Returns an error if the operation cannot be completed. -func (c *parameterCodec) DecodeParameters(parameters url.Values, from unversioned.GroupVersion, into Object) error { - if len(parameters) == 0 { - return nil - } - targetGVKs, _, err := c.typer.ObjectKinds(into) - if err != nil { - return err - } - targetGVK := targetGVKs[0] - if targetGVK.GroupVersion() == from { - return c.convertor.Convert(¶meters, into) - } - input, err := c.creator.New(from.WithKind(targetGVK.Kind)) - if err != nil { - return err - } - if err := c.convertor.Convert(¶meters, input); err != nil { - return err - } - return c.convertor.Convert(input, into) -} - -// EncodeParameters converts the provided object into the to version, then converts that object to url.Values. -// Returns an error if conversion is not possible. -func (c *parameterCodec) EncodeParameters(obj Object, to unversioned.GroupVersion) (url.Values, error) { - gvks, _, err := c.typer.ObjectKinds(obj) - if err != nil { - return nil, err - } - gvk := gvks[0] - if to != gvk.GroupVersion() { - out, err := c.convertor.ConvertToVersion(obj, to) - if err != nil { - return nil, err - } - obj = out - } - return queryparams.Convert(obj) -} - -type base64Serializer struct { - Serializer -} - -func NewBase64Serializer(s Serializer) Serializer { - return &base64Serializer{s} -} - -func (s base64Serializer) Encode(obj Object, stream io.Writer) error { - e := base64.NewEncoder(base64.StdEncoding, stream) - err := s.Serializer.Encode(obj, e) - e.Close() - return err -} - -func (s base64Serializer) Decode(data []byte, defaults *unversioned.GroupVersionKind, into Object) (Object, *unversioned.GroupVersionKind, error) { - out := make([]byte, base64.StdEncoding.DecodedLen(len(data))) - n, err := base64.StdEncoding.Decode(out, data) - if err != nil { - return nil, nil, err - } - return s.Serializer.Decode(out[:n], defaults, into) -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/codec_check.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/codec_check.go deleted file mode 100644 index b012696..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/codec_check.go +++ /dev/null @@ -1,50 +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 runtime - -import ( - "fmt" - "reflect" - - "k8s.io/kubernetes/pkg/api/unversioned" -) - -// CheckCodec makes sure that the codec can encode objects like internalType, -// decode all of the external types listed, and also decode them into the given -// object. (Will modify internalObject.) (Assumes JSON serialization.) -// TODO: verify that the correct external version is chosen on encode... -func CheckCodec(c Codec, internalType Object, externalTypes ...unversioned.GroupVersionKind) error { - _, err := Encode(c, internalType) - if err != nil { - return fmt.Errorf("Internal type not encodable: %v", err) - } - for _, et := range externalTypes { - exBytes := []byte(fmt.Sprintf(`{"kind":"%v","apiVersion":"%v"}`, et.Kind, et.GroupVersion().String())) - obj, err := Decode(c, exBytes) - if err != nil { - return fmt.Errorf("external type %s not interpretable: %v", et, err) - } - if reflect.TypeOf(obj) != reflect.TypeOf(internalType) { - return fmt.Errorf("decode of external type %s produced: %#v", et, obj) - } - err = DecodeInto(c, exBytes, internalType) - if err != nil { - return fmt.Errorf("external type %s not convertable to internal type: %v", et, err) - } - } - return nil -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/conversion.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/conversion.go deleted file mode 100644 index dd6e26a..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/conversion.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Defines conversions between generic types and structs to map query strings -// to struct objects. -package runtime - -import ( - "reflect" - "strconv" - "strings" - - "k8s.io/kubernetes/pkg/conversion" -) - -// JSONKeyMapper uses the struct tags on a conversion to determine the key value for -// the other side. Use when mapping from a map[string]* to a struct or vice versa. -func JSONKeyMapper(key string, sourceTag, destTag reflect.StructTag) (string, string) { - if s := destTag.Get("json"); len(s) > 0 { - return strings.SplitN(s, ",", 2)[0], key - } - if s := sourceTag.Get("json"); len(s) > 0 { - return key, strings.SplitN(s, ",", 2)[0] - } - return key, key -} - -// DefaultStringConversions are helpers for converting []string and string to real values. -var DefaultStringConversions = []interface{}{ - Convert_Slice_string_To_string, - Convert_Slice_string_To_int, - Convert_Slice_string_To_bool, - Convert_Slice_string_To_int64, -} - -func Convert_Slice_string_To_string(input *[]string, out *string, s conversion.Scope) error { - if len(*input) == 0 { - *out = "" - } - *out = (*input)[0] - return nil -} - -func Convert_Slice_string_To_int(input *[]string, out *int, s conversion.Scope) error { - if len(*input) == 0 { - *out = 0 - } - str := (*input)[0] - i, err := strconv.Atoi(str) - if err != nil { - return err - } - *out = i - return nil -} - -// Conver_Slice_string_To_bool will convert a string parameter to boolean. -// Only the absence of a value, a value of "false", or a value of "0" resolve to false. -// Any other value (including empty string) resolves to true. -func Convert_Slice_string_To_bool(input *[]string, out *bool, s conversion.Scope) error { - if len(*input) == 0 { - *out = false - return nil - } - switch strings.ToLower((*input)[0]) { - case "false", "0": - *out = false - default: - *out = true - } - return nil -} - -func Convert_Slice_string_To_int64(input *[]string, out *int64, s conversion.Scope) error { - if len(*input) == 0 { - *out = 0 - } - str := (*input)[0] - i, err := strconv.ParseInt(str, 10, 64) - if err != nil { - return err - } - *out = i - return nil -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/deep_copy_generated.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/deep_copy_generated.go deleted file mode 100644 index 6f5f613..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/deep_copy_generated.go +++ /dev/null @@ -1,63 +0,0 @@ -// +build !ignore_autogenerated - -/* -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. -*/ - -// This file was autogenerated by deepcopy-gen. Do not edit it manually! - -package runtime - -import ( - conversion "k8s.io/kubernetes/pkg/conversion" -) - -func DeepCopy_runtime_RawExtension(in RawExtension, out *RawExtension, c *conversion.Cloner) error { - if in.Raw != nil { - in, out := in.Raw, &out.Raw - *out = make([]byte, len(in)) - copy(*out, in) - } else { - out.Raw = nil - } - if in.Object == nil { - out.Object = nil - } else if newVal, err := c.DeepCopy(in.Object); err != nil { - return err - } else { - out.Object = newVal.(Object) - } - return nil -} - -func DeepCopy_runtime_TypeMeta(in TypeMeta, out *TypeMeta, c *conversion.Cloner) error { - out.APIVersion = in.APIVersion - out.Kind = in.Kind - return nil -} - -func DeepCopy_runtime_Unknown(in Unknown, out *Unknown, c *conversion.Cloner) error { - out.TypeMeta = in.TypeMeta - if in.Raw != nil { - in, out := in.Raw, &out.Raw - *out = make([]byte, len(in)) - copy(*out, in) - } else { - out.Raw = nil - } - out.ContentEncoding = in.ContentEncoding - out.ContentType = in.ContentType - return nil -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/doc.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/doc.go deleted file mode 100644 index a9d084d..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/doc.go +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package runtime includes helper functions for working with API objects -// that follow the kubernetes API object conventions, which are: -// -// 0. Your API objects have a common metadata struct member, TypeMeta. -// 1. Your code refers to an internal set of API objects. -// 2. In a separate package, you have an external set of API objects. -// 3. The external set is considered to be versioned, and no breaking -// changes are ever made to it (fields may be added but not changed -// or removed). -// 4. As your api evolves, you'll make an additional versioned package -// with every major change. -// 5. Versioned packages have conversion functions which convert to -// and from the internal version. -// 6. You'll continue to support older versions according to your -// deprecation policy, and you can easily provide a program/library -// to update old versions into new versions because of 5. -// 7. All of your serializations and deserializations are handled in a -// centralized place. -// -// Package runtime provides a conversion helper to make 5 easy, and the -// Encode/Decode/DecodeInto trio to accomplish 7. You can also register -// additional "codecs" which use a version of your choice. It's -// recommended that you register your types with runtime in your -// package's init function. -// -// As a bonus, a few common types useful from all api objects and versions -// are provided in types.go. - -package runtime diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/embedded.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/embedded.go deleted file mode 100644 index eb1f573..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/embedded.go +++ /dev/null @@ -1,136 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package runtime - -import ( - "errors" - - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/conversion" -) - -type encodable struct { - E Encoder `json:"-"` - obj Object - versions []unversioned.GroupVersion -} - -func (e encodable) GetObjectKind() unversioned.ObjectKind { return e.obj.GetObjectKind() } - -// NewEncodable creates an object that will be encoded with the provided codec on demand. -// Provided as a convenience for test cases dealing with internal objects. -func NewEncodable(e Encoder, obj Object, versions ...unversioned.GroupVersion) Object { - if _, ok := obj.(*Unknown); ok { - return obj - } - return encodable{e, obj, versions} -} - -func (re encodable) UnmarshalJSON(in []byte) error { - return errors.New("runtime.encodable cannot be unmarshalled from JSON") -} - -// Marshal may get called on pointers or values, so implement MarshalJSON on value. -// http://stackoverflow.com/questions/21390979/custom-marshaljson-never-gets-called-in-go -func (re encodable) MarshalJSON() ([]byte, error) { - return Encode(re.E, re.obj) -} - -// NewEncodableList creates an object that will be encoded with the provided codec on demand. -// Provided as a convenience for test cases dealing with internal objects. -func NewEncodableList(e Encoder, objects []Object, versions ...unversioned.GroupVersion) []Object { - out := make([]Object, len(objects)) - for i := range objects { - if _, ok := objects[i].(*Unknown); ok { - out[i] = objects[i] - continue - } - out[i] = NewEncodable(e, objects[i], versions...) - } - return out -} - -func (re *Unknown) UnmarshalJSON(in []byte) error { - if re == nil { - return errors.New("runtime.Unknown: UnmarshalJSON on nil pointer") - } - re.TypeMeta = TypeMeta{} - re.Raw = append(re.Raw[0:0], in...) - re.ContentEncoding = "" - re.ContentType = ContentTypeJSON - return nil -} - -// Marshal may get called on pointers or values, so implement MarshalJSON on value. -// http://stackoverflow.com/questions/21390979/custom-marshaljson-never-gets-called-in-go -func (re Unknown) MarshalJSON() ([]byte, error) { - // If ContentType is unset, we assume this is JSON. - if re.ContentType != "" && re.ContentType != ContentTypeJSON { - return nil, errors.New("runtime.Unknown: MarshalJSON on non-json data") - } - if re.Raw == nil { - return []byte("null"), nil - } - return re.Raw, nil -} - -func Convert_runtime_Object_To_runtime_RawExtension(in *Object, out *RawExtension, s conversion.Scope) error { - if in == nil { - out.Raw = []byte("null") - return nil - } - obj := *in - if unk, ok := obj.(*Unknown); ok { - if unk.Raw != nil { - out.Raw = unk.Raw - return nil - } - obj = out.Object - } - if obj == nil { - out.Raw = nil - return nil - } - out.Object = obj - return nil -} - -func Convert_runtime_RawExtension_To_runtime_Object(in *RawExtension, out *Object, s conversion.Scope) error { - if in.Object != nil { - *out = in.Object - return nil - } - data := in.Raw - if len(data) == 0 || (len(data) == 4 && string(data) == "null") { - *out = nil - return nil - } - *out = &Unknown{ - Raw: data, - // TODO: Set ContentEncoding and ContentType appropriately. - // Currently we set ContentTypeJSON to make tests passing. - ContentType: ContentTypeJSON, - } - return nil -} - -func DefaultEmbeddedConversions() []interface{} { - return []interface{}{ - Convert_runtime_Object_To_runtime_RawExtension, - Convert_runtime_RawExtension_To_runtime_Object, - } -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/error.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/error.go deleted file mode 100644 index 4041b4d..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/error.go +++ /dev/null @@ -1,102 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package runtime - -import ( - "fmt" - "reflect" - - "k8s.io/kubernetes/pkg/api/unversioned" -) - -type notRegisteredErr struct { - gvk unversioned.GroupVersionKind - t reflect.Type -} - -// NewNotRegisteredErr is exposed for testing. -func NewNotRegisteredErr(gvk unversioned.GroupVersionKind, t reflect.Type) error { - return ¬RegisteredErr{gvk: gvk, t: t} -} - -func (k *notRegisteredErr) Error() string { - if k.t != nil { - return fmt.Sprintf("no kind is registered for the type %v", k.t) - } - if len(k.gvk.Kind) == 0 { - return fmt.Sprintf("no version %q has been registered", k.gvk.GroupVersion()) - } - if k.gvk.Version == APIVersionInternal { - return fmt.Sprintf("no kind %q is registered for the internal version of group %q", k.gvk.Kind, k.gvk.Group) - } - - return fmt.Sprintf("no kind %q is registered for version %q", k.gvk.Kind, k.gvk.GroupVersion()) -} - -// IsNotRegisteredError returns true if the error indicates the provided -// object or input data is not registered. -func IsNotRegisteredError(err error) bool { - if err == nil { - return false - } - _, ok := err.(*notRegisteredErr) - return ok -} - -type missingKindErr struct { - data string -} - -func NewMissingKindErr(data string) error { - return &missingKindErr{data} -} - -func (k *missingKindErr) Error() string { - return fmt.Sprintf("Object 'Kind' is missing in '%s'", k.data) -} - -// IsMissingKind returns true if the error indicates that the provided object -// is missing a 'Kind' field. -func IsMissingKind(err error) bool { - if err == nil { - return false - } - _, ok := err.(*missingKindErr) - return ok -} - -type missingVersionErr struct { - data string -} - -// IsMissingVersion returns true if the error indicates that the provided object -// is missing a 'Versioj' field. -func NewMissingVersionErr(data string) error { - return &missingVersionErr{data} -} - -func (k *missingVersionErr) Error() string { - return fmt.Sprintf("Object 'apiVersion' is missing in '%s'", k.data) -} - -func IsMissingVersion(err error) bool { - if err == nil { - return false - } - _, ok := err.(*missingVersionErr) - return ok -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/extension.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/extension.go deleted file mode 100644 index 4d23ee9..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/extension.go +++ /dev/null @@ -1,48 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package runtime - -import ( - "encoding/json" - "errors" -) - -func (re *RawExtension) UnmarshalJSON(in []byte) error { - if re == nil { - return errors.New("runtime.RawExtension: UnmarshalJSON on nil pointer") - } - re.Raw = append(re.Raw[0:0], in...) - return nil -} - -// Marshal may get called on pointers or values, so implement MarshalJSON on value. -// http://stackoverflow.com/questions/21390979/custom-marshaljson-never-gets-called-in-go -func (re RawExtension) MarshalJSON() ([]byte, error) { - if re.Raw == nil { - // TODO: this is to support legacy behavior of JSONPrinter and YAMLPrinter, which - // expect to call json.Marshal on arbitrary versioned objects (even those not in - // the scheme). pkg/kubectl/resource#AsVersionedObjects and its interaction with - // kubectl get on objects not in the scheme needs to be updated to ensure that the - // objects that are not part of the scheme are correctly put into the right form. - if re.Object != nil { - return json.Marshal(re.Object) - } - return []byte("null"), nil - } - // TODO: Check whether ContentType is actually JSON before returning it. - return re.Raw, nil -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/generated.pb.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/generated.pb.go deleted file mode 100644 index 889dbfb..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/generated.pb.go +++ /dev/null @@ -1,689 +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. -*/ - -// Code generated by protoc-gen-gogo. -// source: k8s.io/kubernetes/pkg/runtime/generated.proto -// DO NOT EDIT! - -/* - Package runtime is a generated protocol buffer package. - - It is generated from these files: - k8s.io/kubernetes/pkg/runtime/generated.proto - - It has these top-level messages: - RawExtension - TypeMeta - Unknown -*/ -package runtime - -import proto "github.com/gogo/protobuf/proto" -import fmt "fmt" -import math "math" - -import io "io" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -func (m *RawExtension) Reset() { *m = RawExtension{} } -func (m *RawExtension) String() string { return proto.CompactTextString(m) } -func (*RawExtension) ProtoMessage() {} - -func (m *TypeMeta) Reset() { *m = TypeMeta{} } -func (m *TypeMeta) String() string { return proto.CompactTextString(m) } -func (*TypeMeta) ProtoMessage() {} - -func (m *Unknown) Reset() { *m = Unknown{} } -func (m *Unknown) String() string { return proto.CompactTextString(m) } -func (*Unknown) ProtoMessage() {} - -func init() { - proto.RegisterType((*RawExtension)(nil), "k8s.io.kubernetes.pkg.runtime.RawExtension") - proto.RegisterType((*TypeMeta)(nil), "k8s.io.kubernetes.pkg.runtime.TypeMeta") - proto.RegisterType((*Unknown)(nil), "k8s.io.kubernetes.pkg.runtime.Unknown") -} -func (m *RawExtension) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *RawExtension) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Raw != nil { - data[i] = 0xa - i++ - i = encodeVarintGenerated(data, i, uint64(len(m.Raw))) - i += copy(data[i:], m.Raw) - } - return i, nil -} - -func (m *TypeMeta) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *TypeMeta) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - data[i] = 0xa - i++ - i = encodeVarintGenerated(data, i, uint64(len(m.APIVersion))) - i += copy(data[i:], m.APIVersion) - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, uint64(len(m.Kind))) - i += copy(data[i:], m.Kind) - return i, nil -} - -func (m *Unknown) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Unknown) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - data[i] = 0xa - i++ - i = encodeVarintGenerated(data, i, uint64(m.TypeMeta.Size())) - n1, err := m.TypeMeta.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n1 - if m.Raw != nil { - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, uint64(len(m.Raw))) - i += copy(data[i:], m.Raw) - } - data[i] = 0x1a - i++ - i = encodeVarintGenerated(data, i, uint64(len(m.ContentEncoding))) - i += copy(data[i:], m.ContentEncoding) - data[i] = 0x22 - i++ - i = encodeVarintGenerated(data, i, uint64(len(m.ContentType))) - i += copy(data[i:], m.ContentType) - return i, nil -} - -func encodeFixed64Generated(data []byte, offset int, v uint64) int { - data[offset] = uint8(v) - data[offset+1] = uint8(v >> 8) - data[offset+2] = uint8(v >> 16) - data[offset+3] = uint8(v >> 24) - data[offset+4] = uint8(v >> 32) - data[offset+5] = uint8(v >> 40) - data[offset+6] = uint8(v >> 48) - data[offset+7] = uint8(v >> 56) - return offset + 8 -} -func encodeFixed32Generated(data []byte, offset int, v uint32) int { - data[offset] = uint8(v) - data[offset+1] = uint8(v >> 8) - data[offset+2] = uint8(v >> 16) - data[offset+3] = uint8(v >> 24) - return offset + 4 -} -func encodeVarintGenerated(data []byte, offset int, v uint64) int { - for v >= 1<<7 { - data[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - data[offset] = uint8(v) - return offset + 1 -} -func (m *RawExtension) Size() (n int) { - var l int - _ = l - if m.Raw != nil { - l = len(m.Raw) - n += 1 + l + sovGenerated(uint64(l)) - } - return n -} - -func (m *TypeMeta) Size() (n int) { - var l int - _ = l - l = len(m.APIVersion) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Kind) - n += 1 + l + sovGenerated(uint64(l)) - return n -} - -func (m *Unknown) Size() (n int) { - var l int - _ = l - l = m.TypeMeta.Size() - n += 1 + l + sovGenerated(uint64(l)) - if m.Raw != nil { - l = len(m.Raw) - n += 1 + l + sovGenerated(uint64(l)) - } - l = len(m.ContentEncoding) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.ContentType) - n += 1 + l + sovGenerated(uint64(l)) - return n -} - -func sovGenerated(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n -} -func sozGenerated(x uint64) (n int) { - return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *RawExtension) Unmarshal(data []byte) error { - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RawExtension: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RawExtension: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Raw", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - byteLen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + byteLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Raw = append(m.Raw[:0], data[iNdEx:postIndex]...) - if m.Raw == nil { - m.Raw = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *TypeMeta) Unmarshal(data []byte) error { - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: TypeMeta: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TypeMeta: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field APIVersion", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.APIVersion = string(data[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Kind = string(data[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Unknown) Unmarshal(data []byte) error { - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Unknown: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Unknown: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TypeMeta", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TypeMeta.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Raw", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - byteLen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + byteLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Raw = append(m.Raw[:0], data[iNdEx:postIndex]...) - if m.Raw == nil { - m.Raw = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ContentEncoding", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ContentEncoding = string(data[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ContentType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ContentType = string(data[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipGenerated(data []byte) (n int, err error) { - l := len(data) - iNdEx := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if data[iNdEx-1] < 0x80 { - break - } - } - return iNdEx, nil - case 1: - iNdEx += 8 - return iNdEx, nil - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - iNdEx += length - if length < 0 { - return 0, ErrInvalidLengthGenerated - } - return iNdEx, nil - case 3: - for { - var innerWire uint64 - var start int = iNdEx - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - innerWire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - innerWireType := int(innerWire & 0x7) - if innerWireType == 4 { - break - } - next, err := skipGenerated(data[start:]) - if err != nil { - return 0, err - } - iNdEx = start + next - } - return iNdEx, nil - case 4: - return iNdEx, nil - case 5: - iNdEx += 4 - return iNdEx, nil - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - } - panic("unreachable") -} - -var ( - ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow") -) diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/generated.proto b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/generated.proto deleted file mode 100644 index 0e602ab..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/generated.proto +++ /dev/null @@ -1,124 +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. -*/ - - -// This file was autogenerated by go-to-protobuf. Do not edit it manually! - -syntax = 'proto2'; - -package k8s.io.kubernetes.pkg.runtime; - -import "k8s.io/kubernetes/pkg/api/resource/generated.proto"; -import "k8s.io/kubernetes/pkg/util/intstr/generated.proto"; - -// Package-wide variables from generator "generated". -option go_package = "runtime"; - -// RawExtension is used to hold extensions in external versions. -// -// To use this, make a field which has RawExtension as its type in your external, versioned -// struct, and Object in your internal struct. You also need to register your -// various plugin types. -// -// // Internal package: -// type MyAPIObject struct { -// runtime.TypeMeta `json:",inline"` -// MyPlugin runtime.Object `json:"myPlugin"` -// } -// type PluginA struct { -// AOption string `json:"aOption"` -// } -// -// // External package: -// type MyAPIObject struct { -// runtime.TypeMeta `json:",inline"` -// MyPlugin runtime.RawExtension `json:"myPlugin"` -// } -// type PluginA struct { -// AOption string `json:"aOption"` -// } -// -// // On the wire, the JSON will look something like this: -// { -// "kind":"MyAPIObject", -// "apiVersion":"v1", -// "myPlugin": { -// "kind":"PluginA", -// "aOption":"foo", -// }, -// } -// -// So what happens? Decode first uses json or yaml to unmarshal the serialized data into -// your external MyAPIObject. That causes the raw JSON to be stored, but not unpacked. -// The next step is to copy (using pkg/conversion) into the internal struct. The runtime -// package's DefaultScheme has conversion functions installed which will unpack the -// JSON stored in RawExtension, turning it into the correct object type, and storing it -// in the Object. (TODO: In the case where the object is of an unknown type, a -// runtime.Unknown object will be created and stored.) -// -// +k8s:deepcopy-gen=true -// +protobuf=true -message RawExtension { - // Raw is the underlying serialization of this object. - // - // TODO: Determine how to detect ContentType and ContentEncoding of 'Raw' data. - optional bytes raw = 1; -} - -// TypeMeta is shared by all top level objects. The proper way to use it is to inline it in your type, -// like this: -// type MyAwesomeAPIObject struct { -// runtime.TypeMeta `json:",inline"` -// ... // other fields -// } -// func (obj *MyAwesomeAPIObject) SetGroupVersionKind(gvk *unversioned.GroupVersionKind) { unversioned.UpdateTypeMeta(obj,gvk) }; GroupVersionKind() *GroupVersionKind -// -// TypeMeta is provided here for convenience. You may use it directly from this package or define -// your own with the same fields. -// -// +k8s:deepcopy-gen=true -// +protobuf=true -message TypeMeta { - optional string apiVersion = 1; - - optional string kind = 2; -} - -// Unknown allows api objects with unknown types to be passed-through. This can be used -// to deal with the API objects from a plug-in. Unknown objects still have functioning -// TypeMeta features-- kind, version, etc. -// TODO: Make this object have easy access to field based accessors and settors for -// metadata and field mutatation. -// -// +k8s:deepcopy-gen=true -// +protobuf=true -message Unknown { - optional TypeMeta typeMeta = 1; - - // Raw will hold the complete serialized object which couldn't be matched - // with a registered type. Most likely, nothing should be done with this - // except for passing it through the system. - optional bytes raw = 2; - - // ContentEncoding is encoding used to encode 'Raw' data. - // Unspecified means no encoding. - optional string contentEncoding = 3; - - // ContentType is serialization method used to serialize 'Raw'. - // Unspecified means ContentTypeJSON. - optional string contentType = 4; -} - diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/helper.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/helper.go deleted file mode 100644 index 827cff1..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/helper.go +++ /dev/null @@ -1,212 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package runtime - -import ( - "fmt" - "io" - "reflect" - - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/conversion" - "k8s.io/kubernetes/pkg/util/errors" -) - -// unsafeObjectConvertor implements ObjectConvertor using the unsafe conversion path. -type unsafeObjectConvertor struct { - *Scheme -} - -var _ ObjectConvertor = unsafeObjectConvertor{} - -// ConvertToVersion converts in to the provided outVersion without copying the input first, which -// is only safe if the output object is not mutated or reused. -func (c unsafeObjectConvertor) ConvertToVersion(in Object, outVersion unversioned.GroupVersion) (Object, error) { - return c.Scheme.UnsafeConvertToVersion(in, outVersion) -} - -// UnsafeObjectConvertor performs object conversion without copying the object structure, -// for use when the converted object will not be reused or mutated. Primarily for use within -// versioned codecs, which use the external object for serialization but do not return it. -func UnsafeObjectConvertor(scheme *Scheme) ObjectConvertor { - return unsafeObjectConvertor{scheme} -} - -// SetField puts the value of src, into fieldName, which must be a member of v. -// The value of src must be assignable to the field. -func SetField(src interface{}, v reflect.Value, fieldName string) error { - field := v.FieldByName(fieldName) - if !field.IsValid() { - return fmt.Errorf("couldn't find %v field in %#v", fieldName, v.Interface()) - } - srcValue := reflect.ValueOf(src) - if srcValue.Type().AssignableTo(field.Type()) { - field.Set(srcValue) - return nil - } - if srcValue.Type().ConvertibleTo(field.Type()) { - field.Set(srcValue.Convert(field.Type())) - return nil - } - return fmt.Errorf("couldn't assign/convert %v to %v", srcValue.Type(), field.Type()) -} - -// Field puts the value of fieldName, which must be a member of v, into dest, -// which must be a variable to which this field's value can be assigned. -func Field(v reflect.Value, fieldName string, dest interface{}) error { - field := v.FieldByName(fieldName) - if !field.IsValid() { - return fmt.Errorf("couldn't find %v field in %#v", fieldName, v.Interface()) - } - destValue, err := conversion.EnforcePtr(dest) - if err != nil { - return err - } - if field.Type().AssignableTo(destValue.Type()) { - destValue.Set(field) - return nil - } - if field.Type().ConvertibleTo(destValue.Type()) { - destValue.Set(field.Convert(destValue.Type())) - return nil - } - return fmt.Errorf("couldn't assign/convert %v to %v", field.Type(), destValue.Type()) -} - -// fieldPtr puts the address of fieldName, which must be a member of v, -// into dest, which must be an address of a variable to which this field's -// address can be assigned. -func FieldPtr(v reflect.Value, fieldName string, dest interface{}) error { - field := v.FieldByName(fieldName) - if !field.IsValid() { - return fmt.Errorf("couldn't find %v field in %#v", fieldName, v.Interface()) - } - v, err := conversion.EnforcePtr(dest) - if err != nil { - return err - } - field = field.Addr() - if field.Type().AssignableTo(v.Type()) { - v.Set(field) - return nil - } - if field.Type().ConvertibleTo(v.Type()) { - v.Set(field.Convert(v.Type())) - return nil - } - return fmt.Errorf("couldn't assign/convert %v to %v", field.Type(), v.Type()) -} - -// EncodeList ensures that each object in an array is converted to a Unknown{} in serialized form. -// TODO: accept a content type. -func EncodeList(e Encoder, objects []Object) error { - var errs []error - for i := range objects { - data, err := Encode(e, objects[i]) - if err != nil { - errs = append(errs, err) - continue - } - // TODO: Set ContentEncoding and ContentType. - objects[i] = &Unknown{Raw: data} - } - return errors.NewAggregate(errs) -} - -func decodeListItem(obj *Unknown, decoders []Decoder) (Object, error) { - for _, decoder := range decoders { - // TODO: Decode based on ContentType. - obj, err := Decode(decoder, obj.Raw) - if err != nil { - if IsNotRegisteredError(err) { - continue - } - return nil, err - } - return obj, nil - } - // could not decode, so leave the object as Unknown, but give the decoders the - // chance to set Unknown.TypeMeta if it is available. - for _, decoder := range decoders { - if err := DecodeInto(decoder, obj.Raw, obj); err == nil { - return obj, nil - } - } - return obj, nil -} - -// DecodeList alters the list in place, attempting to decode any objects found in -// the list that have the Unknown type. Any errors that occur are returned -// after the entire list is processed. Decoders are tried in order. -func DecodeList(objects []Object, decoders ...Decoder) []error { - errs := []error(nil) - for i, obj := range objects { - switch t := obj.(type) { - case *Unknown: - decoded, err := decodeListItem(t, decoders) - if err != nil { - errs = append(errs, err) - break - } - objects[i] = decoded - } - } - return errs -} - -// MultiObjectTyper returns the types of objects across multiple schemes in order. -type MultiObjectTyper []ObjectTyper - -var _ ObjectTyper = MultiObjectTyper{} - -func (m MultiObjectTyper) ObjectKinds(obj Object) (gvks []unversioned.GroupVersionKind, unversionedType bool, err error) { - for _, t := range m { - gvks, unversionedType, err = t.ObjectKinds(obj) - if err == nil { - return - } - } - return -} - -func (m MultiObjectTyper) Recognizes(gvk unversioned.GroupVersionKind) bool { - for _, t := range m { - if t.Recognizes(gvk) { - return true - } - } - return false -} - -// SetZeroValue would set the object of objPtr to zero value of its type. -func SetZeroValue(objPtr Object) error { - v, err := conversion.EnforcePtr(objPtr) - if err != nil { - return err - } - v.Set(reflect.Zero(v.Type())) - return nil -} - -// DefaultFramer is valid for any stream that can read objects serially without -// any separation in the stream. -var DefaultFramer = defaultFramer{} - -type defaultFramer struct{} - -func (defaultFramer) NewFrameReader(r io.ReadCloser) io.ReadCloser { return r } -func (defaultFramer) NewFrameWriter(w io.Writer) io.Writer { return w } diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/interfaces.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/interfaces.go deleted file mode 100644 index e463246..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/interfaces.go +++ /dev/null @@ -1,217 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package runtime - -import ( - "io" - "net/url" - - "k8s.io/kubernetes/pkg/api/unversioned" -) - -const ( - // APIVersionInternal may be used if you are registering a type that should not - // be considered stable or serialized - it is a convention only and has no - // special behavior in this package. - APIVersionInternal = "__internal" -) - -type Encoder interface { - // Encode writes an object to a stream. Implementations may return errors if the versions are - // incompatible, or if no conversion is defined. - Encode(obj Object, w io.Writer) error -} - -type Decoder interface { - // Decode attempts to deserialize the provided data using either the innate typing of the scheme or the - // default kind, group, and version provided. It returns a decoded object as well as the kind, group, and - // version from the serialized data, or an error. If into is non-nil, it will be used as the target type - // and implementations may choose to use it rather than reallocating an object. However, the object is not - // guaranteed to be populated. The returned object is not guaranteed to match into. If defaults are - // provided, they are applied to the data by default. If no defaults or partial defaults are provided, the - // type of the into may be used to guide conversion decisions. - Decode(data []byte, defaults *unversioned.GroupVersionKind, into Object) (Object, *unversioned.GroupVersionKind, error) -} - -// Serializer is the core interface for transforming objects into a serialized format and back. -// Implementations may choose to perform conversion of the object, but no assumptions should be made. -type Serializer interface { - Encoder - Decoder -} - -// Codec is a Serializer that deals with the details of versioning objects. It offers the same -// interface as Serializer, so this is a marker to consumers that care about the version of the objects -// they receive. -type Codec Serializer - -// ParameterCodec defines methods for serializing and deserializing API objects to url.Values and -// performing any necessary conversion. Unlike the normal Codec, query parameters are not self describing -// and the desired version must be specified. -type ParameterCodec interface { - // DecodeParameters takes the given url.Values in the specified group version and decodes them - // into the provided object, or returns an error. - DecodeParameters(parameters url.Values, from unversioned.GroupVersion, into Object) error - // EncodeParameters encodes the provided object as query parameters or returns an error. - EncodeParameters(obj Object, to unversioned.GroupVersion) (url.Values, error) -} - -// Framer is a factory for creating readers and writers that obey a particular framing pattern. -type Framer interface { - NewFrameReader(r io.ReadCloser) io.ReadCloser - NewFrameWriter(w io.Writer) io.Writer -} - -// SerializerInfo contains information about a specific serialization format -type SerializerInfo struct { - Serializer - // EncodesAsText indicates this serializer can be encoded to UTF-8 safely. - EncodesAsText bool - // MediaType is the value that represents this serializer over the wire. - MediaType string -} - -// StreamSerializerInfo contains information about a specific stream serialization format -type StreamSerializerInfo struct { - SerializerInfo - // Framer is the factory for retrieving streams that separate objects on the wire - Framer - // Embedded is the type of the nested serialization that should be used. - Embedded SerializerInfo -} - -// NegotiatedSerializer is an interface used for obtaining encoders, decoders, and serializers -// for multiple supported media types. This would commonly be accepted by a server component -// that performs HTTP content negotiation to accept multiple formats. -type NegotiatedSerializer interface { - // SupportedMediaTypes is the media types supported for reading and writing single objects. - SupportedMediaTypes() []string - // SerializerForMediaType returns a serializer for the provided media type. params is the set of - // parameters applied to the media type that may modify the resulting output. ok will be false - // if no serializer matched the media type. - SerializerForMediaType(mediaType string, params map[string]string) (s SerializerInfo, ok bool) - - // SupportedStreamingMediaTypes returns the media types of the supported streaming serializers. - // Streaming serializers control how multiple objects are written to a stream output. - SupportedStreamingMediaTypes() []string - // StreamingSerializerForMediaType returns a serializer for the provided media type that supports - // reading and writing multiple objects to a stream. It returns a framer and serializer, or an - // error if no such serializer can be created. Params is the set of parameters applied to the - // media type that may modify the resulting output. ok will be false if no serializer matched - // the media type. - StreamingSerializerForMediaType(mediaType string, params map[string]string) (s StreamSerializerInfo, ok bool) - - // EncoderForVersion returns an encoder that ensures objects being written to the provided - // serializer are in the provided group version. - // TODO: take multiple group versions - EncoderForVersion(serializer Encoder, gv unversioned.GroupVersion) Encoder - // DecoderForVersion returns a decoder that ensures objects being read by the provided - // serializer are in the provided group version by default. - // TODO: take multiple group versions - DecoderToVersion(serializer Decoder, gv unversioned.GroupVersion) Decoder -} - -// StorageSerializer is an interface used for obtaining encoders, decoders, and serializers -// that can read and write data at rest. This would commonly be used by client tools that must -// read files, or server side storage interfaces that persist restful objects. -type StorageSerializer interface { - // SerializerForMediaType returns a serializer for the provided media type. Options is a set of - // parameters applied to the media type that may modify the resulting output. - SerializerForMediaType(mediaType string, options map[string]string) (SerializerInfo, bool) - - // UniversalDeserializer returns a Serializer that can read objects in multiple supported formats - // by introspecting the data at rest. - UniversalDeserializer() Decoder - - // EncoderForVersion returns an encoder that ensures objects being written to the provided - // serializer are in the provided group version. - // TODO: take multiple group versions - EncoderForVersion(serializer Encoder, gv unversioned.GroupVersion) Encoder - // DecoderForVersion returns a decoder that ensures objects being read by the provided - // serializer are in the provided group version by default. - // TODO: take multiple group versions - DecoderToVersion(serializer Decoder, gv unversioned.GroupVersion) Decoder -} - -/////////////////////////////////////////////////////////////////////////////// -// Non-codec interfaces - -type ObjectVersioner interface { - ConvertToVersion(in Object, outVersion unversioned.GroupVersion) (out Object, err error) -} - -// 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. - Convert(in, out 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. - ConvertToVersion(in Object, outVersion unversioned.GroupVersion) (out Object, err error) - ConvertFieldLabel(version, kind, label, value string) (string, string, error) -} - -// ObjectTyper contains methods for extracting the APIVersion and Kind -// of objects. -type ObjectTyper interface { - // ObjectKinds returns the all possible group,version,kind of the provided object, true if - // the object is unversioned, or an error if the object is not recognized - // (IsNotRegisteredError will return true). - ObjectKinds(Object) ([]unversioned.GroupVersionKind, bool, error) - // Recognizes returns true if the scheme is able to handle the provided version and kind, - // or more precisely that the provided version is a possible conversion or decoding - // target. - Recognizes(gvk unversioned.GroupVersionKind) bool -} - -// ObjectCreater contains methods for instantiating an object by kind and version. -type ObjectCreater interface { - New(kind unversioned.GroupVersionKind) (out Object, err error) -} - -// ObjectCopier duplicates an object. -type ObjectCopier interface { - // Copy returns an exact copy of the provided Object, or an error if the - // copy could not be completed. - Copy(Object) (Object, error) -} - -// ResourceVersioner provides methods for setting and retrieving -// the resource version from an API object. -type ResourceVersioner interface { - SetResourceVersion(obj Object, version string) error - ResourceVersion(obj Object) (string, error) -} - -// SelfLinker provides methods for setting and retrieving the SelfLink field of an API object. -type SelfLinker interface { - SetSelfLink(obj Object, selfLink string) error - SelfLink(obj Object) (string, error) - - // Knowing Name is sometimes necessary to use a SelfLinker. - Name(obj Object) (string, error) - // Knowing Namespace is sometimes necessary to use a SelfLinker - Namespace(obj Object) (string, error) -} - -// All API types registered with Scheme must support the Object interface. Since objects in a scheme are -// expected to be serialized to the wire, the interface an Object must provide to the Scheme allows -// serializers to set the kind, version, and group the object is represented as. An Object may choose -// to return a no-op ObjectKindAccessor in cases where it is not expected to be serialized. -type Object interface { - GetObjectKind() unversioned.ObjectKind -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/register.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/register.go deleted file mode 100644 index 39a1eb1..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/register.go +++ /dev/null @@ -1,66 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package runtime - -import ( - "k8s.io/kubernetes/pkg/api/unversioned" -) - -// SetGroupVersionKind satisfies the ObjectKind interface for all objects that embed TypeMeta -func (obj *TypeMeta) SetGroupVersionKind(gvk unversioned.GroupVersionKind) { - obj.APIVersion, obj.Kind = gvk.ToAPIVersionAndKind() -} - -// GroupVersionKind satisfies the ObjectKind interface for all objects that embed TypeMeta -func (obj *TypeMeta) GroupVersionKind() unversioned.GroupVersionKind { - return unversioned.FromAPIVersionAndKind(obj.APIVersion, obj.Kind) -} - -func (obj *Unknown) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta } - -func (obj *Unstructured) GetObjectKind() unversioned.ObjectKind { return obj } -func (obj *UnstructuredList) GetObjectKind() unversioned.ObjectKind { return obj } - -// GetObjectKind implements Object for VersionedObjects, returning an empty ObjectKind -// interface if no objects are provided, or the ObjectKind interface of the object in the -// highest array position. -func (obj *VersionedObjects) GetObjectKind() unversioned.ObjectKind { - last := obj.Last() - if last == nil { - return unversioned.EmptyObjectKind - } - return last.GetObjectKind() -} - -// First returns the leftmost object in the VersionedObjects array, which is usually the -// object as serialized on the wire. -func (obj *VersionedObjects) First() Object { - if len(obj.Objects) == 0 { - return nil - } - return obj.Objects[0] -} - -// Last is the rightmost object in the VersionedObjects array, which is the object after -// all transformations have been applied. This is the same object that would be returned -// by Decode in a normal invocation (without VersionedObjects in the into argument). -func (obj *VersionedObjects) Last() Object { - if len(obj.Objects) == 0 { - return nil - } - return obj.Objects[len(obj.Objects)-1] -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/scheme.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/scheme.go deleted file mode 100644 index f98ec54..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/scheme.go +++ /dev/null @@ -1,623 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package runtime - -import ( - "fmt" - "net/url" - "reflect" - - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/conversion" -) - -// Scheme defines methods for serializing and deserializing API objects, a type -// registry for converting group, version, and kind information to and from Go -// schemas, and mappings between Go schemas of different versions. A scheme is the -// foundation for a versioned API and versioned configuration over time. -// -// In a Scheme, a Type is a particular Go struct, a Version is a point-in-time -// identifier for a particular representation of that Type (typically backwards -// compatible), a Kind is the unique name for that Type within the Version, and a -// Group identifies a set of Versions, Kinds, and Types that evolve over time. An -// Unversioned Type is one that is not yet formally bound to a type and is promised -// to be backwards compatible (effectively a "v1" of a Type that does not expect -// to break in the future). -// -// Schemes are not expected to change at runtime and are only threadsafe after -// registration is complete. -type Scheme struct { - // versionMap allows one to figure out the go type of an object with - // the given version and name. - gvkToType map[unversioned.GroupVersionKind]reflect.Type - - // typeToGroupVersion allows one to find metadata for a given go object. - // The reflect.Type we index by should *not* be a pointer. - typeToGVK map[reflect.Type][]unversioned.GroupVersionKind - - // unversionedTypes are transformed without conversion in ConvertToVersion. - unversionedTypes map[reflect.Type]unversioned.GroupVersionKind - - // unversionedKinds are the names of kinds that can be created in the context of any group - // or version - // TODO: resolve the status of unversioned types. - unversionedKinds map[string]reflect.Type - - // Map from version and resource to the corresponding func to convert - // resource field labels in that version to internal version. - fieldLabelConversionFuncs map[string]map[string]FieldLabelConversionFunc - - // converter stores all registered conversion functions. It also has - // default coverting behavior. - converter *conversion.Converter - - // cloner stores all registered copy functions. It also has default - // deep copy behavior. - cloner *conversion.Cloner -} - -// Function to convert a field selector to internal representation. -type FieldLabelConversionFunc func(label, value string) (internalLabel, internalValue string, err error) - -// NewScheme creates a new Scheme. This scheme is pluggable by default. -func NewScheme() *Scheme { - s := &Scheme{ - gvkToType: map[unversioned.GroupVersionKind]reflect.Type{}, - typeToGVK: map[reflect.Type][]unversioned.GroupVersionKind{}, - unversionedTypes: map[reflect.Type]unversioned.GroupVersionKind{}, - unversionedKinds: map[string]reflect.Type{}, - cloner: conversion.NewCloner(), - fieldLabelConversionFuncs: map[string]map[string]FieldLabelConversionFunc{}, - } - s.converter = conversion.NewConverter(s.nameFunc) - - s.AddConversionFuncs(DefaultEmbeddedConversions()...) - - // Enable map[string][]string conversions by default - if err := s.AddConversionFuncs(DefaultStringConversions...); err != nil { - panic(err) - } - if err := s.RegisterInputDefaults(&map[string][]string{}, JSONKeyMapper, conversion.AllowDifferentFieldTypeNames|conversion.IgnoreMissingFields); err != nil { - panic(err) - } - if err := s.RegisterInputDefaults(&url.Values{}, JSONKeyMapper, conversion.AllowDifferentFieldTypeNames|conversion.IgnoreMissingFields); err != nil { - panic(err) - } - return s -} - -// nameFunc returns the name of the type that we wish to use to determine when two types attempt -// a conversion. Defaults to the go name of the type if the type is not registered. -func (s *Scheme) nameFunc(t reflect.Type) string { - // find the preferred names for this type - gvks, ok := s.typeToGVK[t] - if !ok { - return t.Name() - } - - for _, gvk := range gvks { - internalGV := gvk.GroupVersion() - internalGV.Version = "__internal" // this is hacky and maybe should be passed in - internalGVK := internalGV.WithKind(gvk.Kind) - - if internalType, exists := s.gvkToType[internalGVK]; exists { - return s.typeToGVK[internalType][0].Kind - } - } - - return gvks[0].Kind -} - -// fromScope gets the input version, desired output version, and desired Scheme -// from a conversion.Scope. -func (s *Scheme) fromScope(scope conversion.Scope) *Scheme { - return s -} - -// Converter allows access to the converter for the scheme -func (s *Scheme) Converter() *conversion.Converter { - return s.converter -} - -// AddUnversionedTypes registers the provided types as "unversioned", which means that they follow special rules. -// Whenever an object of this type is serialized, it is serialized with the provided group version and is not -// converted. Thus unversioned objects are expected to remain backwards compatible forever, as if they were in an -// API group and version that would never be updated. -// -// 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 unversioned.GroupVersion, types ...Object) { - s.AddKnownTypes(version, types...) - for _, obj := range types { - t := reflect.TypeOf(obj).Elem() - gvk := version.WithKind(t.Name()) - s.unversionedTypes[t] = gvk - if _, ok := s.unversionedKinds[gvk.Kind]; ok { - panic(fmt.Sprintf("%v has already been registered as unversioned kind %q - kind name must be unique", reflect.TypeOf(t), gvk.Kind)) - } - s.unversionedKinds[gvk.Kind] = t - } -} - -// AddKnownTypes registers all types passed in 'types' as being members of version 'version'. -// All objects passed to types should be pointers to structs. The name that go reports for -// 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 unversioned.GroupVersion, types ...Object) { - if len(gv.Version) == 0 { - panic(fmt.Sprintf("version is required on all types: %s %v", gv, types[0])) - } - for _, obj := range types { - t := reflect.TypeOf(obj) - if t.Kind() != reflect.Ptr { - panic("All types must be pointers to structs.") - } - t = t.Elem() - if t.Kind() != reflect.Struct { - panic("All types must be pointers to structs.") - } - - gvk := gv.WithKind(t.Name()) - s.gvkToType[gvk] = t - s.typeToGVK[t] = append(s.typeToGVK[t], gvk) - } -} - -// AddKnownTypeWithName is like AddKnownTypes, but it lets you specify what this type should -// be encoded as. Useful for testing when you don't want to make multiple packages to define -// 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 unversioned.GroupVersionKind, obj Object) { - t := reflect.TypeOf(obj) - if len(gvk.Version) == 0 { - panic(fmt.Sprintf("version is required on all types: %s %v", gvk, t)) - } - if t.Kind() != reflect.Ptr { - panic("All types must be pointers to structs.") - } - t = t.Elem() - if t.Kind() != reflect.Struct { - panic("All types must be pointers to structs.") - } - - s.gvkToType[gvk] = t - s.typeToGVK[t] = append(s.typeToGVK[t], gvk) -} - -// KnownTypes returns the types known for the given version. -func (s *Scheme) KnownTypes(gv unversioned.GroupVersion) map[string]reflect.Type { - types := make(map[string]reflect.Type) - for gvk, t := range s.gvkToType { - if gv != gvk.GroupVersion() { - continue - } - - types[gvk.Kind] = t - } - return types -} - -// ObjectKind returns the group,version,kind of the go object and true if this object -// is considered unversioned, or an error if it's not a pointer or is unregistered. -func (s *Scheme) ObjectKind(obj Object) (unversioned.GroupVersionKind, bool, error) { - gvks, unversionedType, err := s.ObjectKinds(obj) - if err != nil { - return unversioned.GroupVersionKind{}, false, err - } - return gvks[0], unversionedType, nil -} - -// ObjectKinds returns all possible group,version,kind of the go object, true if the -// object is considered unversioned, or an error if it's not a pointer or is unregistered. -func (s *Scheme) ObjectKinds(obj Object) ([]unversioned.GroupVersionKind, bool, error) { - v, err := conversion.EnforcePtr(obj) - if err != nil { - return nil, false, err - } - t := v.Type() - - gvks, ok := s.typeToGVK[t] - if !ok { - return nil, false, ¬RegisteredErr{t: t} - } - _, unversionedType := s.unversionedTypes[t] - - return gvks, unversionedType, nil -} - -// Recognizes returns true if the scheme is able to handle the provided group,version,kind -// of an object. -func (s *Scheme) Recognizes(gvk unversioned.GroupVersionKind) bool { - _, exists := s.gvkToType[gvk] - return exists -} - -func (s *Scheme) IsUnversioned(obj Object) (bool, bool) { - v, err := conversion.EnforcePtr(obj) - if err != nil { - return false, false - } - t := v.Type() - - if _, ok := s.typeToGVK[t]; !ok { - return false, false - } - _, ok := s.unversionedTypes[t] - return ok, true -} - -// New returns a new API object of the given version and name, or an error if it hasn't -// been registered. The version and kind fields must be specified. -func (s *Scheme) New(kind unversioned.GroupVersionKind) (Object, error) { - if t, exists := s.gvkToType[kind]; exists { - return reflect.New(t).Interface().(Object), nil - } - - if t, exists := s.unversionedKinds[kind.Kind]; exists { - return reflect.New(t).Interface().(Object), nil - } - return nil, ¬RegisteredErr{gvk: kind} -} - -// AddGenericConversionFunc adds a function that accepts the ConversionFunc call pattern -// (for two conversion types) to the converter. These functions are checked first during -// a normal conversion, but are otherwise not called. Use AddConversionFuncs when registering -// typed conversions. -func (s *Scheme) AddGenericConversionFunc(fn conversion.GenericConversionFunc) { - s.converter.AddGenericConversionFunc(fn) -} - -// Log sets a logger on the scheme. For test purposes only -func (s *Scheme) Log(l conversion.DebugLogger) { - s.converter.Debug = l -} - -// AddIgnoredConversionType identifies a pair of types that should be skipped by -// conversion (because the data inside them is explicitly dropped during -// conversion). -func (s *Scheme) AddIgnoredConversionType(from, to interface{}) error { - return s.converter.RegisterIgnoredConversion(from, to) -} - -// AddConversionFuncs adds functions to the list of conversion functions. The given -// functions should know how to convert between two of your API objects, or their -// sub-objects. We deduce how to call these functions from the types of their two -// parameters; see the comment for Converter.Register. -// -// Note that, if you need to copy sub-objects that didn't change, you can use the -// conversion.Scope object that will be passed to your conversion function. -// Additionally, all conversions started by Scheme will set the SrcVersion and -// DestVersion fields on the Meta object. Example: -// -// s.AddConversionFuncs( -// func(in *InternalObject, out *ExternalObject, scope conversion.Scope) error { -// // You can depend on Meta() being non-nil, and this being set to -// // the source version, e.g., "" -// s.Meta().SrcVersion -// // You can depend on this being set to the destination version, -// // e.g., "v1". -// s.Meta().DestVersion -// // Call scope.Convert to copy sub-fields. -// s.Convert(&in.SubFieldThatMoved, &out.NewLocation.NewName, 0) -// return nil -// }, -// ) -// -// (For more detail about conversion functions, see Converter.Register's comment.) -// -// Also note that the default behavior, if you don't add a conversion function, is to -// sanely copy fields that have the same names and same type names. It's OK if the -// destination type has extra fields, but it must not remove any. So you only need to -// add conversion functions for things with changed/removed fields. -func (s *Scheme) AddConversionFuncs(conversionFuncs ...interface{}) error { - for _, f := range conversionFuncs { - if err := s.converter.RegisterConversionFunc(f); err != nil { - return err - } - } - return nil -} - -// Similar to AddConversionFuncs, but registers conversion functions that were -// automatically generated. -func (s *Scheme) AddGeneratedConversionFuncs(conversionFuncs ...interface{}) error { - for _, f := range conversionFuncs { - if err := s.converter.RegisterGeneratedConversionFunc(f); err != nil { - return err - } - } - return nil -} - -// AddDeepCopyFuncs adds a function to the list of deep-copy functions. -// For the expected format of deep-copy function, see the comment for -// Copier.RegisterDeepCopyFunction. -func (s *Scheme) AddDeepCopyFuncs(deepCopyFuncs ...interface{}) error { - for _, f := range deepCopyFuncs { - if err := s.cloner.RegisterDeepCopyFunc(f); err != nil { - return err - } - } - return nil -} - -// Similar to AddDeepCopyFuncs, but registers deep-copy functions that were -// automatically generated. -func (s *Scheme) AddGeneratedDeepCopyFuncs(deepCopyFuncs ...interface{}) error { - for _, f := range deepCopyFuncs { - if err := s.cloner.RegisterGeneratedDeepCopyFunc(f); err != nil { - return err - } - } - return nil -} - -// AddFieldLabelConversionFunc adds a conversion function to convert field selectors -// of the given kind from the given version to internal version representation. -func (s *Scheme) AddFieldLabelConversionFunc(version, kind string, conversionFunc FieldLabelConversionFunc) error { - if s.fieldLabelConversionFuncs[version] == nil { - s.fieldLabelConversionFuncs[version] = map[string]FieldLabelConversionFunc{} - } - - s.fieldLabelConversionFuncs[version][kind] = conversionFunc - return nil -} - -// AddStructFieldConversion allows you to specify a mechanical copy for a moved -// or renamed struct field without writing an entire conversion function. See -// the comment in conversion.Converter.SetStructFieldCopy for parameter details. -// Call as many times as needed, even on the same fields. -func (s *Scheme) AddStructFieldConversion(srcFieldType interface{}, srcFieldName string, destFieldType interface{}, destFieldName string) error { - return s.converter.SetStructFieldCopy(srcFieldType, srcFieldName, destFieldType, destFieldName) -} - -// RegisterInputDefaults sets the provided field mapping function and field matching -// as the defaults for the provided input type. The fn may be nil, in which case no -// mapping will happen by default. Use this method to register a mechanism for handling -// a specific input type in conversion, such as a map[string]string to structs. -func (s *Scheme) RegisterInputDefaults(in interface{}, fn conversion.FieldMappingFunc, defaultFlags conversion.FieldMatchingFlags) error { - return s.converter.RegisterInputDefaults(in, fn, defaultFlags) -} - -// AddDefaultingFuncs adds functions to the list of default-value functions. -// Each of the given functions is responsible for applying default values -// when converting an instance of a versioned API object into an internal -// API object. These functions do not need to handle sub-objects. We deduce -// how to call these functions from the types of their two parameters. -// -// s.AddDefaultingFuncs( -// func(obj *v1.Pod) { -// if obj.OptionalField == "" { -// obj.OptionalField = "DefaultValue" -// } -// }, -// ) -func (s *Scheme) AddDefaultingFuncs(defaultingFuncs ...interface{}) error { - for _, f := range defaultingFuncs { - err := s.converter.RegisterDefaultingFunc(f) - if err != nil { - return err - } - } - return nil -} - -// Copy does a deep copy of an API object. -func (s *Scheme) Copy(src Object) (Object, error) { - dst, err := s.DeepCopy(src) - if err != nil { - return nil, err - } - return dst.(Object), nil -} - -// Performs a deep copy of the given object. -func (s *Scheme) DeepCopy(src interface{}) (interface{}, error) { - return s.cloner.DeepCopy(src) -} - -// Convert will attempt to convert in into out. Both must be pointers. For easy -// testing of conversion functions. Returns an error if the conversion isn't -// possible. You can call this with types that haven't been registered (for example, -// a to test conversion of types that are nested within registered types), but in -// that case, the conversion.Scope object passed to your conversion functions won't -// have SrcVersion or DestVersion fields set correctly in Meta(). -func (s *Scheme) Convert(in, out interface{}) error { - inVersion := unversioned.GroupVersion{Group: "unknown", Version: "unknown"} - outVersion := unversioned.GroupVersion{Group: "unknown", Version: "unknown"} - if inObj, ok := in.(Object); ok { - if gvks, _, err := s.ObjectKinds(inObj); err == nil { - inVersion = gvks[0].GroupVersion() - } - } - if outObj, ok := out.(Object); ok { - if gvks, _, err := s.ObjectKinds(outObj); err == nil { - outVersion = gvks[0].GroupVersion() - } - } - flags, meta := s.generateConvertMeta(inVersion, outVersion, in) - if flags == 0 { - flags = conversion.AllowDifferentFieldTypeNames - } - return s.converter.Convert(in, out, flags, meta) -} - -// Converts the given field label and value for an kind field selector from -// versioned representation to an unversioned one. -func (s *Scheme) ConvertFieldLabel(version, kind, label, value string) (string, string, error) { - if s.fieldLabelConversionFuncs[version] == nil { - return "", "", fmt.Errorf("No field label conversion function found for version: %s", version) - } - conversionFunc, ok := s.fieldLabelConversionFuncs[version][kind] - if !ok { - return "", "", fmt.Errorf("No field label conversion function found for version %s and kind %s", version, kind) - } - return conversionFunc(label, value) -} - -// ConvertToVersion attempts to convert an input object to its matching Kind in another -// version within this scheme. Will return an error if the provided version does not -// contain the inKind (or a mapping by name defined with AddKnownTypeWithName). Will also -// return an error if the conversion does not result in a valid Object being -// returned. The serializer handles loading/serializing nested objects. -func (s *Scheme) ConvertToVersion(in Object, outVersion unversioned.GroupVersion) (Object, error) { - switch in.(type) { - case *Unknown, *Unstructured, *UnstructuredList: - old := in.GetObjectKind().GroupVersionKind() - defer in.GetObjectKind().SetGroupVersionKind(old) - setTargetVersion(in, s, outVersion) - return in, nil - } - t := reflect.TypeOf(in) - if t.Kind() != reflect.Ptr { - return nil, fmt.Errorf("only pointer types may be converted: %v", t) - } - - t = t.Elem() - if t.Kind() != reflect.Struct { - return nil, fmt.Errorf("only pointers to struct types may be converted: %v", t) - } - - var kind unversioned.GroupVersionKind - if unversionedKind, ok := s.unversionedTypes[t]; ok { - kind = unversionedKind - } else { - kinds, ok := s.typeToGVK[t] - if !ok || len(kinds) == 0 { - return nil, fmt.Errorf("%v is not a registered type and cannot be converted into version %q", t, outVersion) - } - kind = kinds[0] - } - - outKind := outVersion.WithKind(kind.Kind) - - inKinds, _, err := s.ObjectKinds(in) - if err != nil { - return nil, err - } - - out, err := s.New(outKind) - if err != nil { - return nil, err - } - - flags, meta := s.generateConvertMeta(inKinds[0].GroupVersion(), outVersion, in) - if err := s.converter.Convert(in, out, flags, meta); err != nil { - return nil, err - } - - setTargetVersion(out, s, outVersion) - return out, nil -} - -// UnsafeConvertToVersion will convert in to the provided outVersion if such a conversion is possible, -// but does not guarantee the output object does not share fields with the input object. It attempts to be as -// efficient as possible when doing conversion. -func (s *Scheme) UnsafeConvertToVersion(in Object, outVersion unversioned.GroupVersion) (Object, error) { - switch t := in.(type) { - case *Unknown: - t.APIVersion = outVersion.String() - return t, nil - case *Unstructured: - t.SetAPIVersion(outVersion.String()) - return t, nil - case *UnstructuredList: - t.SetAPIVersion(outVersion.String()) - return t, nil - } - - // determine the incoming kinds with as few allocations as possible. - t := reflect.TypeOf(in) - if t.Kind() != reflect.Ptr { - return nil, fmt.Errorf("only pointer types may be converted: %v", t) - } - t = t.Elem() - if t.Kind() != reflect.Struct { - return nil, fmt.Errorf("only pointers to struct types may be converted: %v", t) - } - kinds, ok := s.typeToGVK[t] - if !ok || len(kinds) == 0 { - return nil, fmt.Errorf("%v is not a registered type and cannot be converted into version %q", t, outVersion) - } - - // if the Go type is also registered to the destination kind, no conversion is necessary - for i := range kinds { - if kinds[i].Version == outVersion.Version && kinds[i].Group == outVersion.Group { - setTargetKind(in, kinds[i]) - return in, nil - } - } - - // type is unversioned, no conversion necessary - // it should be possible to avoid this allocation - if unversionedKind, ok := s.unversionedTypes[t]; ok { - kind := unversionedKind - outKind := outVersion.WithKind(kind.Kind) - setTargetKind(in, outKind) - return in, nil - } - - // allocate a new object as the target using the target kind - // TODO: this should look in the target group version and find the first kind that matches, rather than the - // first kind registered in typeToGVK - kind := kinds[0] - kind.Version = outVersion.Version - kind.Group = outVersion.Group - out, err := s.New(kind) - if err != nil { - return nil, err - } - - // TODO: try to avoid the allocations here - in fast paths we are not likely to need these flags or meta - flags, meta := s.converter.DefaultMeta(t) - if err := s.converter.Convert(in, out, flags, meta); err != nil { - return nil, err - } - - setTargetKind(out, kind) - return out, nil -} - -// generateConvertMeta constructs the meta value we pass to Convert. -func (s *Scheme) generateConvertMeta(srcGroupVersion, destGroupVersion unversioned.GroupVersion, in interface{}) (conversion.FieldMatchingFlags, *conversion.Meta) { - return s.converter.DefaultMeta(reflect.TypeOf(in)) -} - -// setTargetVersion is deprecated and should be replaced by use of setTargetKind -func setTargetVersion(obj Object, raw *Scheme, gv unversioned.GroupVersion) { - if gv.Version == APIVersionInternal { - // internal is a special case - obj.GetObjectKind().SetGroupVersionKind(unversioned.GroupVersionKind{}) - return - } - if gvks, _, _ := raw.ObjectKinds(obj); len(gvks) > 0 { - obj.GetObjectKind().SetGroupVersionKind(unversioned.GroupVersionKind{Group: gv.Group, Version: gv.Version, Kind: gvks[0].Kind}) - } else { - obj.GetObjectKind().SetGroupVersionKind(unversioned.GroupVersionKind{Group: gv.Group, Version: gv.Version}) - } -} - -// setTargetKind sets the kind on an object, taking into account whether the target kind is the internal version. -func setTargetKind(obj Object, kind unversioned.GroupVersionKind) { - if kind.Version == APIVersionInternal { - // internal is a special case - // TODO: look at removing the need to special case this - obj.GetObjectKind().SetGroupVersionKind(unversioned.GroupVersionKind{}) - return - } - obj.GetObjectKind().SetGroupVersionKind(kind) -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/codec_factory.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/codec_factory.go deleted file mode 100644 index 758aa6b..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/codec_factory.go +++ /dev/null @@ -1,364 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package serializer - -import ( - "io" - - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/runtime/serializer/json" - "k8s.io/kubernetes/pkg/runtime/serializer/recognizer" - "k8s.io/kubernetes/pkg/runtime/serializer/versioning" -) - -// serializerExtensions are for serializers that are conditionally compiled in -var serializerExtensions = []func(*runtime.Scheme) (serializerType, bool){} - -type serializerType struct { - AcceptContentTypes []string - ContentType string - FileExtensions []string - // EncodesAsText should be true if this content type can be represented safely in UTF-8 - EncodesAsText bool - - Serializer runtime.Serializer - PrettySerializer runtime.Serializer - // RawSerializer serializes an object without adding a type wrapper. Some serializers, like JSON - // automatically include identifying type information with the JSON. Others, like Protobuf, need - // a wrapper object that includes type information. This serializer should be set if the serializer - // can serialize / deserialize objects without type info. Note that this serializer will always - // be expected to pass into or a gvk to Decode, since no type information will be available on - // the object itself. - RawSerializer runtime.Serializer - // Specialize gives the type the opportunity to return a different serializer implementation if - // the content type contains alternate operations. Here it is used to implement "pretty" as an - // option to application/json, but could also be used to allow serializers to perform type - // defaulting or alter output. - Specialize func(map[string]string) (runtime.Serializer, bool) - - AcceptStreamContentTypes []string - StreamContentType string - - Framer runtime.Framer - StreamSerializer runtime.Serializer - StreamSpecialize func(map[string]string) (runtime.Serializer, bool) -} - -func newSerializersForScheme(scheme *runtime.Scheme, mf json.MetaFactory) []serializerType { - jsonSerializer := json.NewSerializer(mf, scheme, scheme, false) - jsonPrettySerializer := json.NewSerializer(mf, scheme, scheme, true) - yamlSerializer := json.NewYAMLSerializer(mf, scheme, scheme) - - serializers := []serializerType{ - { - AcceptContentTypes: []string{"application/json"}, - ContentType: "application/json", - FileExtensions: []string{"json"}, - EncodesAsText: true, - Serializer: jsonSerializer, - PrettySerializer: jsonPrettySerializer, - - AcceptStreamContentTypes: []string{"application/json", "application/json;stream=watch"}, - StreamContentType: "application/json", - Framer: json.Framer, - StreamSerializer: jsonSerializer, - }, - { - AcceptContentTypes: []string{"application/yaml"}, - ContentType: "application/yaml", - FileExtensions: []string{"yaml"}, - EncodesAsText: true, - Serializer: yamlSerializer, - - // TODO: requires runtime.RawExtension to properly distinguish when the nested content is - // yaml, because the yaml encoder invokes MarshalJSON first - //AcceptStreamContentTypes: []string{"application/yaml", "application/yaml;stream=watch"}, - //StreamContentType: "application/yaml;stream=watch", - //Framer: json.YAMLFramer, - //StreamSerializer: yamlSerializer, - }, - } - - for _, fn := range serializerExtensions { - if serializer, ok := fn(scheme); ok { - serializers = append(serializers, serializer) - } - } - return serializers -} - -// CodecFactory provides methods for retrieving codecs and serializers for specific -// versions and content types. -type CodecFactory struct { - scheme *runtime.Scheme - serializers []serializerType - universal runtime.Decoder - accepts []string - streamingAccepts []string - - legacySerializer runtime.Serializer -} - -// NewCodecFactory provides methods for retrieving serializers for the supported wire formats -// and conversion wrappers to define preferred internal and external versions. In the future, -// as the internal version is used less, callers may instead use a defaulting serializer and -// only convert objects which are shared internally (Status, common API machinery). -// TODO: allow other codecs to be compiled in? -// TODO: accept a scheme interface -func NewCodecFactory(scheme *runtime.Scheme) CodecFactory { - serializers := newSerializersForScheme(scheme, json.DefaultMetaFactory) - return newCodecFactory(scheme, serializers) -} - -// newCodecFactory is a helper for testing that allows a different metafactory to be specified. -func newCodecFactory(scheme *runtime.Scheme, serializers []serializerType) CodecFactory { - decoders := make([]runtime.Decoder, 0, len(serializers)) - accepts := []string{} - alreadyAccepted := make(map[string]struct{}) - - var legacySerializer runtime.Serializer - for _, d := range serializers { - decoders = append(decoders, d.Serializer) - for _, mediaType := range d.AcceptContentTypes { - if _, ok := alreadyAccepted[mediaType]; ok { - continue - } - alreadyAccepted[mediaType] = struct{}{} - accepts = append(accepts, mediaType) - if mediaType == "application/json" { - legacySerializer = d.Serializer - } - } - } - if legacySerializer == nil { - legacySerializer = serializers[0].Serializer - } - - streamAccepts := []string{} - alreadyAccepted = make(map[string]struct{}) - for _, d := range serializers { - if len(d.StreamContentType) == 0 { - continue - } - for _, mediaType := range d.AcceptStreamContentTypes { - if _, ok := alreadyAccepted[mediaType]; ok { - continue - } - alreadyAccepted[mediaType] = struct{}{} - streamAccepts = append(streamAccepts, mediaType) - } - } - - return CodecFactory{ - scheme: scheme, - serializers: serializers, - universal: recognizer.NewDecoder(decoders...), - - accepts: accepts, - streamingAccepts: streamAccepts, - - legacySerializer: legacySerializer, - } -} - -var _ runtime.NegotiatedSerializer = &CodecFactory{} - -// SupportedMediaTypes returns the RFC2046 media types that this factory has serializers for. -func (f CodecFactory) SupportedMediaTypes() []string { - return f.accepts -} - -// SupportedStreamingMediaTypes returns the RFC2046 media types that this factory has stream serializers for. -func (f CodecFactory) SupportedStreamingMediaTypes() []string { - return f.streamingAccepts -} - -// LegacyCodec encodes output to a given API version, and decodes output into the internal form from -// any recognized source. The returned codec will always encode output to JSON. -// -// This method is deprecated - clients and servers should negotiate a serializer by mime-type and -// invoke CodecForVersions. Callers that need only to read data should use UniversalDecoder(). -func (f CodecFactory) LegacyCodec(version ...unversioned.GroupVersion) runtime.Codec { - return versioning.NewCodecForScheme(f.scheme, f.legacySerializer, f.universal, version, nil) -} - -// UniversalDeserializer can convert any stored data recognized by this factory into a Go object that satisfies -// runtime.Object. It does not perform conversion. It does not perform defaulting. -func (f CodecFactory) UniversalDeserializer() runtime.Decoder { - return f.universal -} - -// UniversalDecoder returns a runtime.Decoder capable of decoding all known API objects in all known formats. Used -// by clients that do not need to encode objects but want to deserialize API objects stored on disk. Only decodes -// objects in groups registered with the scheme. The GroupVersions passed may be used to select alternate -// versions of objects to return - by default, runtime.APIVersionInternal is used. If any versions are specified, -// unrecognized groups will be returned in the version they are encoded as (no conversion). This decoder performs -// defaulting. -// -// TODO: the decoder will eventually be removed in favor of dealing with objects in their versioned form -func (f CodecFactory) UniversalDecoder(versions ...unversioned.GroupVersion) runtime.Decoder { - return f.CodecForVersions(nil, f.universal, nil, versions) -} - -// CodecFor creates a codec with the provided serializer. If an object is decoded and its group is not in the list, -// it will default to runtime.APIVersionInternal. If encode is not specified for an object's group, the object is not -// converted. If encode or decode are nil, no conversion is performed. -func (f CodecFactory) CodecForVersions(encoder runtime.Encoder, decoder runtime.Decoder, encode []unversioned.GroupVersion, decode []unversioned.GroupVersion) runtime.Codec { - return versioning.NewCodecForScheme(f.scheme, encoder, decoder, encode, decode) -} - -// DecoderToVersion returns a decoder that targets the provided group version. -func (f CodecFactory) DecoderToVersion(decoder runtime.Decoder, gv unversioned.GroupVersion) runtime.Decoder { - return f.CodecForVersions(nil, decoder, nil, []unversioned.GroupVersion{gv}) -} - -// EncoderForVersion returns an encoder that targets the provided group version. -func (f CodecFactory) EncoderForVersion(encoder runtime.Encoder, gv unversioned.GroupVersion) runtime.Encoder { - return f.CodecForVersions(encoder, nil, []unversioned.GroupVersion{gv}, nil) -} - -// SerializerForMediaType returns a serializer that matches the provided RFC2046 mediaType, or false if no such -// serializer exists -func (f CodecFactory) SerializerForMediaType(mediaType string, params map[string]string) (runtime.SerializerInfo, bool) { - for _, s := range f.serializers { - for _, accepted := range s.AcceptContentTypes { - if accepted == mediaType { - // specialization abstracts variants to the content type - if s.Specialize != nil && len(params) > 0 { - serializer, ok := s.Specialize(params) - // TODO: return formatted mediaType+params - return runtime.SerializerInfo{Serializer: serializer, MediaType: s.ContentType, EncodesAsText: s.EncodesAsText}, ok - } - - // legacy support for ?pretty=1 continues, but this is more formally defined - if v, ok := params["pretty"]; ok && v == "1" && s.PrettySerializer != nil { - return runtime.SerializerInfo{Serializer: s.PrettySerializer, MediaType: s.ContentType, EncodesAsText: s.EncodesAsText}, true - } - - // return the base variant - return runtime.SerializerInfo{Serializer: s.Serializer, MediaType: s.ContentType, EncodesAsText: s.EncodesAsText}, true - } - } - } - return runtime.SerializerInfo{}, false -} - -// StreamingSerializerForMediaType returns a serializer that matches the provided RFC2046 mediaType, or false if no such -// serializer exists -func (f CodecFactory) StreamingSerializerForMediaType(mediaType string, params map[string]string) (runtime.StreamSerializerInfo, bool) { - for _, s := range f.serializers { - for _, accepted := range s.AcceptStreamContentTypes { - if accepted == mediaType { - // TODO: accept params - nested, ok := f.SerializerForMediaType(s.ContentType, nil) - if !ok { - panic("no serializer defined for internal content type") - } - - if s.StreamSpecialize != nil && len(params) > 0 { - serializer, ok := s.StreamSpecialize(params) - // TODO: return formatted mediaType+params - return runtime.StreamSerializerInfo{ - SerializerInfo: runtime.SerializerInfo{ - Serializer: serializer, - MediaType: s.StreamContentType, - EncodesAsText: s.EncodesAsText, - }, - Framer: s.Framer, - Embedded: nested, - }, ok - } - - return runtime.StreamSerializerInfo{ - SerializerInfo: runtime.SerializerInfo{ - Serializer: s.StreamSerializer, - MediaType: s.StreamContentType, - EncodesAsText: s.EncodesAsText, - }, - Framer: s.Framer, - Embedded: nested, - }, true - } - } - } - return runtime.StreamSerializerInfo{}, false -} - -// SerializerForFileExtension returns a serializer for the provided extension, or false if no serializer matches. -func (f CodecFactory) SerializerForFileExtension(extension string) (runtime.Serializer, bool) { - for _, s := range f.serializers { - for _, ext := range s.FileExtensions { - if extension == ext { - return s.Serializer, true - } - } - } - return nil, false -} - -// DirectCodecFactory provides methods for retrieving "DirectCodec"s, which do not do conversion. -type DirectCodecFactory struct { - CodecFactory -} - -// EncoderForVersion returns an encoder that does not do conversion. gv is ignored. -func (f DirectCodecFactory) EncoderForVersion(serializer runtime.Encoder, gv unversioned.GroupVersion) runtime.Encoder { - return DirectCodec{ - runtime.NewCodec(serializer, nil), - f.CodecFactory.scheme, - } -} - -// DecoderToVersion returns an decoder that does not do conversion. gv is ignored. -func (f DirectCodecFactory) DecoderToVersion(serializer runtime.Decoder, gv unversioned.GroupVersion) runtime.Decoder { - return DirectCodec{ - runtime.NewCodec(nil, serializer), - nil, - } -} - -// DirectCodec is a codec that does not do conversion. It sets the gvk during serialization, and removes the gvk during deserialization. -type DirectCodec struct { - runtime.Serializer - runtime.ObjectTyper -} - -// EncodeToStream does not do conversion. It sets the gvk during serialization. overrides are ignored. -func (c DirectCodec) Encode(obj runtime.Object, stream io.Writer) error { - gvks, _, err := c.ObjectTyper.ObjectKinds(obj) - if err != nil { - return err - } - kind := obj.GetObjectKind() - oldGVK := kind.GroupVersionKind() - kind.SetGroupVersionKind(gvks[0]) - err = c.Serializer.Encode(obj, stream) - kind.SetGroupVersionKind(oldGVK) - return err -} - -// Decode does not do conversion. It removes the gvk during deserialization. -func (c DirectCodec) Decode(data []byte, defaults *unversioned.GroupVersionKind, into runtime.Object) (runtime.Object, *unversioned.GroupVersionKind, error) { - obj, gvk, err := c.Serializer.Decode(data, defaults, into) - if obj != nil { - kind := obj.GetObjectKind() - // clearing the gvk is just a convention of a codec - kind.SetGroupVersionKind(unversioned.GroupVersionKind{}) - } - return obj, gvk, err -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/json/json.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/json/json.go deleted file mode 100644 index c26fa50..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/json/json.go +++ /dev/null @@ -1,243 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package json - -import ( - "encoding/json" - "io" - - "github.com/ghodss/yaml" - "github.com/ugorji/go/codec" - - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util/framer" - utilyaml "k8s.io/kubernetes/pkg/util/yaml" -) - -// NewSerializer creates a JSON serializer that handles encoding versioned objects into the proper JSON form. If typer -// is not nil, the object has the group, version, and kind fields set. -func NewSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.ObjectTyper, pretty bool) *Serializer { - return &Serializer{ - meta: meta, - creater: creater, - typer: typer, - yaml: false, - pretty: pretty, - } -} - -// NewYAMLSerializer creates a YAML serializer that handles encoding versioned objects into the proper YAML form. If typer -// is not nil, the object has the group, version, and kind fields set. This serializer supports only the subset of YAML that -// matches JSON, and will error if constructs are used that do not serialize to JSON. -func NewYAMLSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.ObjectTyper) *Serializer { - return &Serializer{ - meta: meta, - creater: creater, - typer: typer, - yaml: true, - } -} - -type Serializer struct { - meta MetaFactory - creater runtime.ObjectCreater - typer runtime.ObjectTyper - yaml bool - pretty bool -} - -// Serializer implements Serializer -var _ runtime.Serializer = &Serializer{} - -// 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. -func (s *Serializer) Decode(originalData []byte, gvk *unversioned.GroupVersionKind, into runtime.Object) (runtime.Object, *unversioned.GroupVersionKind, error) { - if versioned, ok := into.(*runtime.VersionedObjects); ok { - into = versioned.Last() - obj, actual, err := s.Decode(originalData, gvk, into) - if err != nil { - return nil, actual, err - } - versioned.Objects = []runtime.Object{obj} - return versioned, actual, nil - } - - data := originalData - if s.yaml { - altered, err := yaml.YAMLToJSON(data) - if err != nil { - return nil, nil, err - } - data = altered - } - - actual, err := s.meta.Interpret(data) - if err != nil { - return nil, nil, err - } - - 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 - } - } - - if unk, ok := into.(*runtime.Unknown); ok && unk != nil { - unk.Raw = originalData - unk.ContentType = runtime.ContentTypeJSON - unk.GetObjectKind().SetGroupVersionKind(*actual) - return unk, actual, nil - } - - if into != nil { - types, _, err := s.typer.ObjectKinds(into) - switch { - case runtime.IsNotRegisteredError(err): - if err := codec.NewDecoderBytes(data, new(codec.JsonHandle)).Decode(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 - } - } - } - - if len(actual.Kind) == 0 { - return nil, actual, runtime.NewMissingKindErr(string(originalData)) - } - if len(actual.Version) == 0 { - return nil, actual, runtime.NewMissingVersionErr(string(originalData)) - } - - // use the target if necessary - obj, err := runtime.UseOrCreateObject(s.typer, s.creater, *actual, into) - if err != nil { - return nil, actual, err - } - - if err := codec.NewDecoderBytes(data, new(codec.JsonHandle)).Decode(obj); err != nil { - return nil, actual, err - } - return obj, actual, nil -} - -// 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 := json.Marshal(obj) - if err != nil { - return err - } - data, err := yaml.JSONToYAML(json) - if err != nil { - return err - } - _, err = w.Write(data) - return err - } - - if s.pretty { - data, err := json.MarshalIndent(obj, "", " ") - if err != nil { - return err - } - _, err = w.Write(data) - return err - } - encoder := json.NewEncoder(w) - return encoder.Encode(obj) -} - -// RecognizesData implements the RecognizingDecoder interface. -func (s *Serializer) RecognizesData(peek io.Reader) (ok, unknown bool, err error) { - if s.yaml { - // we could potentially look for '---' - return false, true, nil - } - _, ok = utilyaml.GuessJSONStream(peek, 2048) - return ok, false, nil -} - -// Framer is the default JSON framing behavior, with newlines delimiting individual objects. -var Framer = jsonFramer{} - -type jsonFramer struct{} - -// NewFrameWriter implements stream framing for this serializer -func (jsonFramer) NewFrameWriter(w io.Writer) io.Writer { - // we can write JSON objects directly to the writer, because they are self-framing - return w -} - -// NewFrameReader implements stream framing for this serializer -func (jsonFramer) NewFrameReader(r io.ReadCloser) io.ReadCloser { - // we need to extract the JSON chunks of data to pass to Decode() - return framer.NewJSONFramedReader(r) -} - -// Framer is the default JSON framing behavior, with newlines delimiting individual objects. -var YAMLFramer = yamlFramer{} - -type yamlFramer struct{} - -// NewFrameWriter implements stream framing for this serializer -func (yamlFramer) NewFrameWriter(w io.Writer) io.Writer { - return yamlFrameWriter{w} -} - -// NewFrameReader implements stream framing for this serializer -func (yamlFramer) NewFrameReader(r io.ReadCloser) io.ReadCloser { - // extract the YAML document chunks directly - return utilyaml.NewDocumentDecoder(r) -} - -type yamlFrameWriter struct { - w io.Writer -} - -// Write separates each document with the YAML document separator (`---` followed by line -// break). Writers must write well formed YAML documents (include a final line break). -func (w yamlFrameWriter) Write(data []byte) (n int, err error) { - if _, err := w.w.Write([]byte("---\n")); err != nil { - return 0, err - } - return w.w.Write(data) -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/json/meta.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/json/meta.go deleted file mode 100644 index b9bea21..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/json/meta.go +++ /dev/null @@ -1,61 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package json - -import ( - "encoding/json" - "fmt" - - "k8s.io/kubernetes/pkg/api/unversioned" -) - -// MetaFactory is used to store and retrieve the version and kind -// information for JSON objects in a serializer. -type MetaFactory interface { - // Interpret should return the version and kind of the wire-format of - // the object. - Interpret(data []byte) (*unversioned.GroupVersionKind, error) -} - -// DefaultMetaFactory is a default factory for versioning objects in JSON. The object -// in memory and in the default JSON serialization will use the "kind" and "apiVersion" -// fields. -var DefaultMetaFactory = SimpleMetaFactory{} - -// SimpleMetaFactory provides default methods for retrieving the type and version of objects -// that are identified with an "apiVersion" and "kind" fields in their JSON -// serialization. It may be parameterized with the names of the fields in memory, or an -// optional list of base structs to search for those fields in memory. -type SimpleMetaFactory struct { -} - -// Interpret will return the APIVersion and Kind of the JSON wire-format -// encoding of an object, or an error. -func (SimpleMetaFactory) Interpret(data []byte) (*unversioned.GroupVersionKind, error) { - findKind := struct { - APIVersion string `json:"apiVersion,omitempty"` - Kind string `json:"kind,omitempty"` - }{} - if err := json.Unmarshal(data, &findKind); err != nil { - return nil, fmt.Errorf("couldn't get version/kind; json parse error: %v", err) - } - gv, err := unversioned.ParseGroupVersion(findKind.APIVersion) - if err != nil { - return nil, err - } - return &unversioned.GroupVersionKind{Group: gv.Group, Version: gv.Version, Kind: findKind.Kind}, nil -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/negotiated_codec.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/negotiated_codec.go deleted file mode 100644 index 59b078c..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/negotiated_codec.go +++ /dev/null @@ -1,57 +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 serializer - -import ( - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/runtime" -) - -// TODO: We should figure out what happens when someone asks -// encoder for version and it conflicts with the raw serializer. -type negotiatedSerializerWrapper struct { - info runtime.SerializerInfo - streamInfo runtime.StreamSerializerInfo -} - -func NegotiatedSerializerWrapper(info runtime.SerializerInfo, streamInfo runtime.StreamSerializerInfo) runtime.NegotiatedSerializer { - return &negotiatedSerializerWrapper{info, streamInfo} -} - -func (n *negotiatedSerializerWrapper) SupportedMediaTypes() []string { - return []string{} -} - -func (n *negotiatedSerializerWrapper) SerializerForMediaType(mediaType string, options map[string]string) (runtime.SerializerInfo, bool) { - return n.info, true -} - -func (n *negotiatedSerializerWrapper) SupportedStreamingMediaTypes() []string { - return []string{} -} - -func (n *negotiatedSerializerWrapper) StreamingSerializerForMediaType(mediaType string, options map[string]string) (runtime.StreamSerializerInfo, bool) { - return n.streamInfo, true -} - -func (n *negotiatedSerializerWrapper) EncoderForVersion(e runtime.Encoder, _ unversioned.GroupVersion) runtime.Encoder { - return e -} - -func (n *negotiatedSerializerWrapper) DecoderToVersion(d runtime.Decoder, _gv unversioned.GroupVersion) runtime.Decoder { - return d -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/protobuf/doc.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/protobuf/doc.go deleted file mode 100644 index 381748d..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/protobuf/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package protobuf provides a Kubernetes serializer for the protobuf format. -package protobuf diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/protobuf/protobuf.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/protobuf/protobuf.go deleted file mode 100644 index b9eb9e5..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/protobuf/protobuf.go +++ /dev/null @@ -1,433 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package protobuf - -import ( - "bytes" - "fmt" - "io" - "reflect" - - "github.com/gogo/protobuf/proto" - - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util/framer" -) - -var ( - // protoEncodingPrefix serves as a magic number for an encoded protobuf message on this serializer. All - // proto messages serialized by this schema will be preceded by the bytes 0x6b 0x38 0x73, with the fourth - // byte being reserved for the encoding style. The only encoding style defined is 0x00, which means that - // the rest of the byte stream is a message of type k8s.io.kubernetes.pkg.runtime.Unknown (proto2). - // - // See k8s.io/kubernetes/pkg/runtime/generated.proto for details of the runtime.Unknown message. - // - // This encoding scheme is experimental, and is subject to change at any time. - protoEncodingPrefix = []byte{0x6b, 0x38, 0x73, 0x00} -) - -type errNotMarshalable struct { - t reflect.Type -} - -func (e errNotMarshalable) Error() string { - return fmt.Sprintf("object %v does not implement the protobuf marshalling interface and cannot be encoded to a protobuf message", e.t) -} - -func IsNotMarshalable(err error) bool { - _, ok := err.(errNotMarshalable) - return err != nil && ok -} - -// NewSerializer creates a Protobuf serializer that handles encoding versioned objects into the proper wire form. If a typer -// is passed, the encoded object will have group, version, and kind fields set. If typer is nil, the objects will be written -// as-is (any type info passed with the object will be used). -// -// This encoding scheme is experimental, and is subject to change at any time. -func NewSerializer(creater runtime.ObjectCreater, typer runtime.ObjectTyper, defaultContentType string) *Serializer { - return &Serializer{ - prefix: protoEncodingPrefix, - creater: creater, - typer: typer, - contentType: defaultContentType, - } -} - -type Serializer struct { - prefix []byte - creater runtime.ObjectCreater - typer runtime.ObjectTyper - contentType string -} - -var _ runtime.Serializer = &Serializer{} - -// Decode attempts to convert the provided data into a protobuf message, 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 protobuf unmarshalling (the MarshalTo interface). 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. -func (s *Serializer) Decode(originalData []byte, gvk *unversioned.GroupVersionKind, into runtime.Object) (runtime.Object, *unversioned.GroupVersionKind, error) { - if versioned, ok := into.(*runtime.VersionedObjects); ok { - into = versioned.Last() - obj, actual, err := s.Decode(originalData, gvk, into) - if err != nil { - return nil, actual, err - } - // the last item in versioned becomes into, so if versioned was not originally empty we reset the object - // array so the first position is the decoded object and the second position is the outermost object. - // if there were no objects in the versioned list passed to us, only add ourselves. - if into != nil && into != obj { - versioned.Objects = []runtime.Object{obj, into} - } else { - versioned.Objects = []runtime.Object{obj} - } - return versioned, actual, err - } - - prefixLen := len(s.prefix) - switch { - case len(originalData) == 0: - // TODO: treat like decoding {} from JSON with defaulting - return nil, nil, fmt.Errorf("empty data") - case len(originalData) < prefixLen || !bytes.Equal(s.prefix, originalData[:prefixLen]): - return nil, nil, fmt.Errorf("provided data does not appear to be a protobuf message, expected prefix %v", s.prefix) - case len(originalData) == prefixLen: - // TODO: treat like decoding {} from JSON with defaulting - return nil, nil, fmt.Errorf("empty body") - } - - data := originalData[prefixLen:] - unk := runtime.Unknown{} - if err := unk.Unmarshal(data); err != nil { - return nil, nil, err - } - - actual := unk.GroupVersionKind() - copyKindDefaults(&actual, gvk) - - if intoUnknown, ok := into.(*runtime.Unknown); ok && intoUnknown != nil { - *intoUnknown = unk - if len(intoUnknown.ContentType) == 0 { - intoUnknown.ContentType = s.contentType - } - return intoUnknown, &actual, nil - } - - if into != nil { - types, _, err := s.typer.ObjectKinds(into) - switch { - case runtime.IsNotRegisteredError(err): - pb, ok := into.(proto.Message) - if !ok { - return nil, &actual, errNotMarshalable{reflect.TypeOf(into)} - } - if err := proto.Unmarshal(unk.Raw, pb); err != nil { - return nil, &actual, err - } - return into, &actual, nil - case err != nil: - return nil, &actual, err - default: - copyKindDefaults(&actual, &types[0]) - // if the result of defaulting did not set a version or group, ensure that at least group is set - // (copyKindDefaults will not assign Group if version is already set). This guarantees that the group - // of into is set if there is no better information from the caller or object. - if len(actual.Version) == 0 && len(actual.Group) == 0 { - actual.Group = types[0].Group - } - } - } - - if len(actual.Kind) == 0 { - return nil, &actual, runtime.NewMissingKindErr(fmt.Sprintf("%#v", unk.TypeMeta)) - } - if len(actual.Version) == 0 { - return nil, &actual, runtime.NewMissingVersionErr(fmt.Sprintf("%#v", unk.TypeMeta)) - } - - return unmarshalToObject(s.typer, s.creater, &actual, into, unk.Raw) -} - -// Encode serializes the provided object to the given writer. -func (s *Serializer) Encode(obj runtime.Object, w io.Writer) error { - var unk runtime.Unknown - kind := obj.GetObjectKind().GroupVersionKind() - unk = runtime.Unknown{ - TypeMeta: runtime.TypeMeta{ - Kind: kind.Kind, - APIVersion: kind.GroupVersion().String(), - }, - } - - prefixSize := uint64(len(s.prefix)) - - switch t := obj.(type) { - case bufferedMarshaller: - // this path performs a single allocation during write but requires the caller to implement - // the more efficient Size and MarshalTo methods - encodedSize := uint64(t.Size()) - estimatedSize := prefixSize + estimateUnknownSize(&unk, encodedSize) - data := make([]byte, estimatedSize) - - i, err := unk.NestedMarshalTo(data[prefixSize:], t, encodedSize) - if err != nil { - return err - } - - copy(data, s.prefix) - - _, err = w.Write(data[:prefixSize+uint64(i)]) - return err - - case proto.Marshaler: - // this path performs extra allocations - data, err := t.Marshal() - if err != nil { - return err - } - unk.Raw = data - - estimatedSize := prefixSize + uint64(unk.Size()) - data = make([]byte, estimatedSize) - - i, err := unk.MarshalTo(data[prefixSize:]) - if err != nil { - return err - } - - copy(data, s.prefix) - - _, err = w.Write(data[:prefixSize+uint64(i)]) - return err - - default: - // TODO: marshal with a different content type and serializer (JSON for third party objects) - return errNotMarshalable{reflect.TypeOf(obj)} - } -} - -// RecognizesData implements the RecognizingDecoder interface. -func (s *Serializer) RecognizesData(peek io.Reader) (bool, error) { - prefix := make([]byte, 4) - n, err := peek.Read(prefix) - if err != nil { - if err == io.EOF { - return false, nil - } - return false, err - } - if n != 4 { - return false, nil - } - return bytes.Equal(s.prefix, prefix), nil -} - -// copyKindDefaults defaults dst to the value in src if dst does not have a value set. -func copyKindDefaults(dst, src *unversioned.GroupVersionKind) { - if src == nil { - return - } - // apply kind and version defaulting from provided default - if len(dst.Kind) == 0 { - dst.Kind = src.Kind - } - if len(dst.Version) == 0 && len(src.Version) > 0 { - dst.Group = src.Group - dst.Version = src.Version - } -} - -// bufferedMarshaller describes a more efficient marshalling interface that can avoid allocating multiple -// byte buffers by pre-calculating the size of the final buffer needed. -type bufferedMarshaller interface { - proto.Sizer - runtime.ProtobufMarshaller -} - -// estimateUnknownSize returns the expected bytes consumed by a given runtime.Unknown -// object with a nil RawJSON struct and the expected size of the provided buffer. The -// returned size will not be correct if RawJSOn is set on unk. -func estimateUnknownSize(unk *runtime.Unknown, byteSize uint64) uint64 { - size := uint64(unk.Size()) - // protobuf uses 1 byte for the tag, a varint for the length of the array (at most 8 bytes - uint64 - here), - // and the size of the array. - size += 1 + 8 + byteSize - return size -} - -// NewRawSerializer creates a Protobuf serializer that handles encoding versioned objects into the proper wire form. If typer -// is not nil, the object has the group, version, and kind fields set. This serializer does not provide type information for the -// encoded object, and thus is not self describing (callers must know what type is being described in order to decode). -// -// This encoding scheme is experimental, and is subject to change at any time. -func NewRawSerializer(creater runtime.ObjectCreater, typer runtime.ObjectTyper, defaultContentType string) *RawSerializer { - return &RawSerializer{ - creater: creater, - typer: typer, - contentType: defaultContentType, - } -} - -// RawSerializer encodes and decodes objects without adding a runtime.Unknown wrapper (objects are encoded without identifying -// type). -type RawSerializer struct { - creater runtime.ObjectCreater - typer runtime.ObjectTyper - contentType string -} - -var _ runtime.Serializer = &RawSerializer{} - -// Decode attempts to convert the provided data into a protobuf message, 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 protobuf unmarshalling (the MarshalTo interface). 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. -func (s *RawSerializer) Decode(originalData []byte, gvk *unversioned.GroupVersionKind, into runtime.Object) (runtime.Object, *unversioned.GroupVersionKind, error) { - if into == nil { - return nil, nil, fmt.Errorf("this serializer requires an object to decode into: %#v", s) - } - - if versioned, ok := into.(*runtime.VersionedObjects); ok { - into = versioned.Last() - obj, actual, err := s.Decode(originalData, gvk, into) - if err != nil { - return nil, actual, err - } - if into != nil && into != obj { - versioned.Objects = []runtime.Object{obj, into} - } else { - versioned.Objects = []runtime.Object{obj} - } - return versioned, actual, err - } - - if len(originalData) == 0 { - // TODO: treat like decoding {} from JSON with defaulting - return nil, nil, fmt.Errorf("empty data") - } - data := originalData - - actual := &unversioned.GroupVersionKind{} - copyKindDefaults(actual, gvk) - - if intoUnknown, ok := into.(*runtime.Unknown); ok && intoUnknown != nil { - intoUnknown.Raw = data - intoUnknown.ContentEncoding = "" - intoUnknown.ContentType = s.contentType - intoUnknown.SetGroupVersionKind(*actual) - return intoUnknown, actual, nil - } - - types, _, err := s.typer.ObjectKinds(into) - switch { - case runtime.IsNotRegisteredError(err): - pb, ok := into.(proto.Message) - if !ok { - return nil, actual, errNotMarshalable{reflect.TypeOf(into)} - } - if err := proto.Unmarshal(data, pb); err != nil { - return nil, actual, err - } - return into, actual, nil - case err != nil: - return nil, actual, err - default: - copyKindDefaults(actual, &types[0]) - // if the result of defaulting did not set a version or group, ensure that at least group is set - // (copyKindDefaults will not assign Group if version is already set). This guarantees that the group - // of into is set if there is no better information from the caller or object. - if len(actual.Version) == 0 && len(actual.Group) == 0 { - actual.Group = types[0].Group - } - } - - if len(actual.Kind) == 0 { - return nil, actual, runtime.NewMissingKindErr("") - } - if len(actual.Version) == 0 { - return nil, actual, runtime.NewMissingVersionErr("") - } - - return unmarshalToObject(s.typer, s.creater, actual, into, data) -} - -// unmarshalToObject is the common code between decode in the raw and normal serializer. -func unmarshalToObject(typer runtime.ObjectTyper, creater runtime.ObjectCreater, actual *unversioned.GroupVersionKind, into runtime.Object, data []byte) (runtime.Object, *unversioned.GroupVersionKind, error) { - // use the target if necessary - obj, err := runtime.UseOrCreateObject(typer, creater, *actual, into) - if err != nil { - return nil, actual, err - } - - pb, ok := obj.(proto.Message) - if !ok { - return nil, actual, errNotMarshalable{reflect.TypeOf(obj)} - } - if err := proto.Unmarshal(data, pb); err != nil { - return nil, actual, err - } - return obj, actual, nil -} - -// Encode serializes the provided object to the given writer. Overrides is ignored. -func (s *RawSerializer) Encode(obj runtime.Object, w io.Writer) error { - switch t := obj.(type) { - case bufferedMarshaller: - // this path performs a single allocation during write but requires the caller to implement - // the more efficient Size and MarshalTo methods - encodedSize := uint64(t.Size()) - data := make([]byte, encodedSize) - - n, err := t.MarshalTo(data) - if err != nil { - return err - } - _, err = w.Write(data[:n]) - return err - - case proto.Marshaler: - // this path performs extra allocations - data, err := t.Marshal() - if err != nil { - return err - } - _, err = w.Write(data) - return err - - default: - return errNotMarshalable{reflect.TypeOf(obj)} - } -} - -var LengthDelimitedFramer = lengthDelimitedFramer{} - -type lengthDelimitedFramer struct{} - -// NewFrameWriter implements stream framing for this serializer -func (lengthDelimitedFramer) NewFrameWriter(w io.Writer) io.Writer { - return framer.NewLengthDelimitedFrameWriter(w) -} - -// NewFrameReader implements stream framing for this serializer -func (lengthDelimitedFramer) NewFrameReader(r io.ReadCloser) io.ReadCloser { - return framer.NewLengthDelimitedFrameReader(r) -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/protobuf_extension.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/protobuf_extension.go deleted file mode 100644 index 5846d94..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/protobuf_extension.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package serializer - -import ( - "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/runtime/serializer/protobuf" -) - -const ( - // contentTypeProtobuf is the protobuf type exposed for Kubernetes. It is private to prevent others from - // depending on it unintentionally. - // TODO: potentially move to pkg/api (since it's part of the Kube public API) and pass it in to the - // CodecFactory on initialization. - contentTypeProtobuf = "application/vnd.kubernetes.protobuf" - contentTypeProtobufWatch = contentTypeProtobuf + ";stream=watch" -) - -func protobufSerializer(scheme *runtime.Scheme) (serializerType, bool) { - serializer := protobuf.NewSerializer(scheme, scheme, contentTypeProtobuf) - raw := protobuf.NewRawSerializer(scheme, scheme, contentTypeProtobuf) - return serializerType{ - AcceptContentTypes: []string{contentTypeProtobuf}, - ContentType: contentTypeProtobuf, - FileExtensions: []string{"pb"}, - Serializer: serializer, - RawSerializer: raw, - - AcceptStreamContentTypes: []string{contentTypeProtobuf, contentTypeProtobufWatch}, - StreamContentType: contentTypeProtobufWatch, - Framer: protobuf.LengthDelimitedFramer, - StreamSerializer: raw, - }, true -} - -func init() { - serializerExtensions = append(serializerExtensions, protobufSerializer) -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/recognizer/recognizer.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/recognizer/recognizer.go deleted file mode 100644 index 310002a..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/recognizer/recognizer.go +++ /dev/null @@ -1,127 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package recognizer - -import ( - "bufio" - "bytes" - "fmt" - "io" - - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/runtime" -) - -type RecognizingDecoder interface { - runtime.Decoder - // RecognizesData should return true if the input provided in the provided reader - // belongs to this decoder, or an error if the data could not be read or is ambiguous. - // Unknown is true if the data could not be determined to match the decoder type. - // Decoders should assume that they can read as much of peek as they need (as the caller - // provides) and may return unknown if the data provided is not sufficient to make a - // a determination. When peek returns EOF that may mean the end of the input or the - // end of buffered input - recognizers should return the best guess at that time. - RecognizesData(peek io.Reader) (ok, unknown bool, err error) -} - -// NewDecoder creates a decoder that will attempt multiple decoders in an order defined -// by: -// -// 1. The decoder implements RecognizingDecoder and identifies the data -// 2. All other decoders, and any decoder that returned true for unknown. -// -// The order passed to the constructor is preserved within those priorities. -func NewDecoder(decoders ...runtime.Decoder) runtime.Decoder { - return &decoder{ - decoders: decoders, - } -} - -type decoder struct { - decoders []runtime.Decoder -} - -var _ RecognizingDecoder = &decoder{} - -func (d *decoder) RecognizesData(peek io.Reader) (bool, bool, error) { - var ( - lastErr error - anyUnknown bool - ) - data, _ := bufio.NewReaderSize(peek, 1024).Peek(1024) - for _, r := range d.decoders { - switch t := r.(type) { - case RecognizingDecoder: - ok, unknown, err := t.RecognizesData(bytes.NewBuffer(data)) - if err != nil { - lastErr = err - continue - } - anyUnknown = anyUnknown || unknown - if !ok { - continue - } - return true, false, nil - } - } - return false, anyUnknown, lastErr -} - -func (d *decoder) Decode(data []byte, gvk *unversioned.GroupVersionKind, into runtime.Object) (runtime.Object, *unversioned.GroupVersionKind, error) { - var ( - lastErr error - skipped []runtime.Decoder - ) - - // try recognizers, record any decoders we need to give a chance later - for _, r := range d.decoders { - switch t := r.(type) { - case RecognizingDecoder: - buf := bytes.NewBuffer(data) - ok, unknown, err := t.RecognizesData(buf) - if err != nil { - lastErr = err - continue - } - if unknown { - skipped = append(skipped, t) - continue - } - if !ok { - continue - } - return r.Decode(data, gvk, into) - default: - skipped = append(skipped, t) - } - } - - // try recognizers that returned unknown or didn't recognize their data - for _, r := range skipped { - out, actual, err := r.Decode(data, gvk, into) - if err != nil { - lastErr = err - continue - } - return out, actual, nil - } - - if lastErr == nil { - lastErr = fmt.Errorf("no serialization format matched the provided data") - } - return nil, nil, lastErr -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/streaming/streaming.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/streaming/streaming.go deleted file mode 100644 index ac17138..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/streaming/streaming.go +++ /dev/null @@ -1,137 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package streaming implements encoder and decoder for streams -// of runtime.Objects over io.Writer/Readers. -package streaming - -import ( - "bytes" - "fmt" - "io" - - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/runtime" -) - -// Encoder is a runtime.Encoder on a stream. -type Encoder interface { - // Encode will write the provided object to the stream or return an error. It obeys the same - // contract as runtime.VersionedEncoder. - Encode(obj runtime.Object) error -} - -// Decoder is a runtime.Decoder from a stream. -type Decoder interface { - // Decode will return io.EOF when no more objects are available. - Decode(defaults *unversioned.GroupVersionKind, into runtime.Object) (runtime.Object, *unversioned.GroupVersionKind, error) - // Close closes the underlying stream. - Close() error -} - -// Serializer is a factory for creating encoders and decoders that work over streams. -type Serializer interface { - NewEncoder(w io.Writer) Encoder - NewDecoder(r io.ReadCloser) Decoder -} - -type decoder struct { - reader io.ReadCloser - decoder runtime.Decoder - buf []byte - maxBytes int - resetRead bool -} - -// NewDecoder creates a streaming decoder that reads object chunks from r and decodes them with d. -// The reader is expected to return ErrShortRead if the provided buffer is not large enough to read -// an entire object. -func NewDecoder(r io.ReadCloser, d runtime.Decoder) Decoder { - return &decoder{ - reader: r, - decoder: d, - buf: make([]byte, 1024), - maxBytes: 1024 * 1024, - } -} - -var ErrObjectTooLarge = fmt.Errorf("object to decode was longer than maximum allowed size") - -// Decode reads the next object from the stream and decodes it. -func (d *decoder) Decode(defaults *unversioned.GroupVersionKind, into runtime.Object) (runtime.Object, *unversioned.GroupVersionKind, error) { - base := 0 - for { - n, err := d.reader.Read(d.buf[base:]) - if err == io.ErrShortBuffer { - if n == 0 { - return nil, nil, fmt.Errorf("got short buffer with n=0, base=%d, cap=%d", base, cap(d.buf)) - } - if d.resetRead { - continue - } - // double the buffer size up to maxBytes - if len(d.buf) < d.maxBytes { - base += n - d.buf = append(d.buf, make([]byte, len(d.buf))...) - continue - } - // must read the rest of the frame (until we stop getting ErrShortBuffer) - d.resetRead = true - base = 0 - return nil, nil, ErrObjectTooLarge - } - if err != nil { - return nil, nil, err - } - if d.resetRead { - // now that we have drained the large read, continue - d.resetRead = false - continue - } - base += n - break - } - return d.decoder.Decode(d.buf[:base], defaults, into) -} - -func (d *decoder) Close() error { - return d.reader.Close() -} - -type encoder struct { - writer io.Writer - encoder runtime.Encoder - buf *bytes.Buffer -} - -// NewEncoder returns a new streaming encoder. -func NewEncoder(w io.Writer, e runtime.Encoder) Encoder { - return &encoder{ - writer: w, - encoder: e, - buf: &bytes.Buffer{}, - } -} - -// Encode writes the provided object to the nested writer. -func (e *encoder) Encode(obj runtime.Object) error { - if err := e.encoder.Encode(obj, e.buf); err != nil { - return err - } - _, err := e.writer.Write(e.buf.Bytes()) - e.buf.Reset() - return err -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go deleted file mode 100644 index 6e67964..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go +++ /dev/null @@ -1,275 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package versioning - -import ( - "fmt" - "io" - - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/runtime" -) - -// EnableCrossGroupDecoding modifies the given decoder in place, if it is a codec -// from this package. It allows objects from one group to be auto-decoded into -// another group. 'destGroup' must already exist in the codec. -// TODO: this is an encapsulation violation and should be refactored -func EnableCrossGroupDecoding(d runtime.Decoder, sourceGroup, destGroup string) error { - internal, ok := d.(*codec) - if !ok { - return fmt.Errorf("unsupported decoder type") - } - - dest, ok := internal.decodeVersion[destGroup] - if !ok { - return fmt.Errorf("group %q is not a possible destination group in the given codec", destGroup) - } - internal.decodeVersion[sourceGroup] = dest - - return nil -} - -// EnableCrossGroupEncoding modifies the given encoder in place, if it is a codec -// from this package. It allows objects from one group to be auto-decoded into -// another group. 'destGroup' must already exist in the codec. -// TODO: this is an encapsulation violation and should be refactored -func EnableCrossGroupEncoding(e runtime.Encoder, sourceGroup, destGroup string) error { - internal, ok := e.(*codec) - if !ok { - return fmt.Errorf("unsupported encoder type") - } - - dest, ok := internal.encodeVersion[destGroup] - if !ok { - return fmt.Errorf("group %q is not a possible destination group in the given codec", destGroup) - } - internal.encodeVersion[sourceGroup] = dest - - return nil -} - -// NewCodecForScheme is a convenience method for callers that are using a scheme. -func NewCodecForScheme( - // TODO: I should be a scheme interface? - scheme *runtime.Scheme, - encoder runtime.Encoder, - decoder runtime.Decoder, - encodeVersion []unversioned.GroupVersion, - decodeVersion []unversioned.GroupVersion, -) runtime.Codec { - return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, scheme, encodeVersion, decodeVersion) -} - -// NewCodec takes objects in their internal versions and converts them to external versions before -// serializing them. It assumes the serializer provided to it only deals with external versions. -// This class is also a serializer, but is generally used with a specific version. -func NewCodec( - encoder runtime.Encoder, - decoder runtime.Decoder, - convertor runtime.ObjectConvertor, - creater runtime.ObjectCreater, - copier runtime.ObjectCopier, - typer runtime.ObjectTyper, - encodeVersion []unversioned.GroupVersion, - decodeVersion []unversioned.GroupVersion, -) runtime.Codec { - internal := &codec{ - encoder: encoder, - decoder: decoder, - convertor: convertor, - creater: creater, - copier: copier, - typer: typer, - } - if encodeVersion != nil { - internal.encodeVersion = make(map[string]unversioned.GroupVersion) - for _, v := range encodeVersion { - // first one for a group wins. This is consistent with best to worst order throughout the codebase - if _, ok := internal.encodeVersion[v.Group]; ok { - continue - } - internal.encodeVersion[v.Group] = v - } - if len(internal.encodeVersion) == 1 { - for _, v := range internal.encodeVersion { - internal.preferredEncodeVersion = []unversioned.GroupVersion{v} - } - } - } - if decodeVersion != nil { - internal.decodeVersion = make(map[string]unversioned.GroupVersion) - for _, v := range decodeVersion { - // first one for a group wins. This is consistent with best to worst order throughout the codebase - if _, ok := internal.decodeVersion[v.Group]; ok { - continue - } - internal.decodeVersion[v.Group] = v - } - } - - return internal -} - -type codec struct { - encoder runtime.Encoder - decoder runtime.Decoder - convertor runtime.ObjectConvertor - creater runtime.ObjectCreater - copier runtime.ObjectCopier - typer runtime.ObjectTyper - - encodeVersion map[string]unversioned.GroupVersion - decodeVersion map[string]unversioned.GroupVersion - - preferredEncodeVersion []unversioned.GroupVersion -} - -// Decode attempts a decode of the object, then tries to convert it to the internal version. If into is provided and the decoding is -// successful, the returned runtime.Object will be the value passed as into. Note that this may bypass conversion if you pass an -// into that matches the serialized version. -func (c *codec) Decode(data []byte, defaultGVK *unversioned.GroupVersionKind, into runtime.Object) (runtime.Object, *unversioned.GroupVersionKind, error) { - versioned, isVersioned := into.(*runtime.VersionedObjects) - if isVersioned { - into = versioned.Last() - } - - obj, gvk, err := c.decoder.Decode(data, defaultGVK, into) - if err != nil { - return nil, gvk, err - } - - // if we specify a target, use generic conversion. - if into != nil { - if into == obj { - if isVersioned { - return versioned, gvk, nil - } - return into, gvk, nil - } - if err := c.convertor.Convert(obj, into); err != nil { - return nil, gvk, err - } - if isVersioned { - versioned.Objects = []runtime.Object{obj, into} - return versioned, gvk, nil - } - return into, gvk, nil - } - - // invoke a version conversion - group := gvk.Group - if defaultGVK != nil { - group = defaultGVK.Group - } - var targetGV unversioned.GroupVersion - if c.decodeVersion == nil { - // convert to internal by default - targetGV.Group = group - targetGV.Version = runtime.APIVersionInternal - } else { - gv, ok := c.decodeVersion[group] - if !ok { - // unknown objects are left in their original version - if isVersioned { - versioned.Objects = []runtime.Object{obj} - return versioned, gvk, nil - } - return obj, gvk, nil - } - targetGV = gv - } - - if gvk.GroupVersion() == targetGV { - if isVersioned { - versioned.Objects = []runtime.Object{obj} - return versioned, gvk, nil - } - return obj, gvk, nil - } - - if isVersioned { - // create a copy, because ConvertToVersion does not guarantee non-mutation of objects - copied, err := c.copier.Copy(obj) - if err != nil { - copied = obj - } - versioned.Objects = []runtime.Object{copied} - } - - // Convert if needed. - out, err := c.convertor.ConvertToVersion(obj, targetGV) - if err != nil { - return nil, gvk, err - } - if isVersioned { - versioned.Objects = append(versioned.Objects, out) - return versioned, gvk, nil - } - return out, gvk, nil -} - -// 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 { - if _, ok := obj.(*runtime.Unknown); ok { - return c.encoder.Encode(obj, w) - } - gvks, isUnversioned, err := c.typer.ObjectKinds(obj) - if err != nil { - return err - } - gvk := gvks[0] - - if c.encodeVersion == nil || isUnversioned { - objectKind := obj.GetObjectKind() - old := objectKind.GroupVersionKind() - objectKind.SetGroupVersionKind(gvk) - err = c.encoder.Encode(obj, w) - objectKind.SetGroupVersionKind(old) - return err - } - - targetGV, ok := c.encodeVersion[gvk.Group] - - // attempt a conversion to the sole encode version - if !ok && c.preferredEncodeVersion != nil { - ok = true - targetGV = c.preferredEncodeVersion[0] - } - - // if no fallback is available, error - if !ok { - return fmt.Errorf("the codec does not recognize group %q for kind %q and cannot encode it", gvk.Group, gvk.Kind) - } - - // Perform a conversion if necessary - objectKind := obj.GetObjectKind() - old := objectKind.GroupVersionKind() - out, err := c.convertor.ConvertToVersion(obj, targetGV) - if err != nil { - if ok { - return err - } - } else { - obj = out - } - // Conversion is responsible for setting the proper group, version, and kind onto the outgoing object - err = c.encoder.Encode(obj, w) - // restore the old GVK, in case conversion returned the same object - objectKind.SetGroupVersionKind(old) - return err -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/swagger_doc_generator.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/swagger_doc_generator.go deleted file mode 100644 index 29722d5..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/swagger_doc_generator.go +++ /dev/null @@ -1,262 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package runtime - -import ( - "bytes" - "fmt" - "go/ast" - "go/doc" - "go/parser" - "go/token" - "io" - "reflect" - "strings" -) - -// Pair of strings. We keed the name of fields and the doc -type Pair struct { - Name, Doc string -} - -// KubeTypes is an array to represent all available types in a parsed file. [0] is for the type itself -type KubeTypes []Pair - -func astFrom(filePath string) *doc.Package { - fset := token.NewFileSet() - m := make(map[string]*ast.File) - - f, err := parser.ParseFile(fset, filePath, nil, parser.ParseComments) - if err != nil { - fmt.Println(err) - return nil - } - - m[filePath] = f - apkg, _ := ast.NewPackage(fset, m, nil, nil) - - return doc.New(apkg, "", 0) -} - -func fmtRawDoc(rawDoc string) string { - var buffer bytes.Buffer - delPrevChar := func() { - if buffer.Len() > 0 { - buffer.Truncate(buffer.Len() - 1) // Delete the last " " or "\n" - } - } - - // Ignore all lines after --- - rawDoc = strings.Split(rawDoc, "---")[0] - - for _, line := range strings.Split(rawDoc, "\n") { - line = strings.TrimRight(line, " ") - leading := strings.TrimLeft(line, " ") - switch { - case len(line) == 0: // Keep paragraphs - delPrevChar() - buffer.WriteString("\n\n") - case strings.HasPrefix(leading, "TODO"): // Ignore one line TODOs - case strings.HasPrefix(leading, "+"): // Ignore instructions to go2idl - default: - if strings.HasPrefix(line, " ") || strings.HasPrefix(line, "\t") { - delPrevChar() - line = "\n" + line + "\n" // Replace it with newline. This is useful when we have a line with: "Example:\n\tJSON-someting..." - } else { - line += " " - } - buffer.WriteString(line) - } - } - - postDoc := strings.TrimRight(buffer.String(), "\n") - postDoc = strings.Replace(postDoc, "\\\"", "\"", -1) // replace user's \" to " - postDoc = strings.Replace(postDoc, "\"", "\\\"", -1) // Escape " - postDoc = strings.Replace(postDoc, "\n", "\\n", -1) - postDoc = strings.Replace(postDoc, "\t", "\\t", -1) - - return postDoc -} - -// fieldName returns the name of the field as it should appear in JSON format -// "-" indicates that this field is not part of the JSON representation -func fieldName(field *ast.Field) string { - jsonTag := "" - if field.Tag != nil { - jsonTag = reflect.StructTag(field.Tag.Value[1 : len(field.Tag.Value)-1]).Get("json") // Delete first and last quotation - if strings.Contains(jsonTag, "inline") { - return "-" - } - } - - jsonTag = strings.Split(jsonTag, ",")[0] // This can return "-" - if jsonTag == "" { - if field.Names != nil { - return field.Names[0].Name - } - return field.Type.(*ast.Ident).Name - } - return jsonTag -} - -// A buffer of lines that will be written. -type bufferedLine struct { - line string - indentation int -} - -type buffer struct { - lines []bufferedLine -} - -func newBuffer() *buffer { - return &buffer{ - lines: make([]bufferedLine, 0), - } -} - -func (b *buffer) addLine(line string, indent int) { - b.lines = append(b.lines, bufferedLine{line, indent}) -} - -func (b *buffer) flushLines(w io.Writer) error { - for _, line := range b.lines { - indentation := strings.Repeat("\t", line.indentation) - fullLine := fmt.Sprintf("%s%s", indentation, line.line) - if _, err := io.WriteString(w, fullLine); err != nil { - return err - } - } - return nil -} - -func writeFuncHeader(b *buffer, structName string, indent int) { - s := fmt.Sprintf("var map_%s = map[string]string {\n", structName) - b.addLine(s, indent) -} - -func writeFuncFooter(b *buffer, structName string, indent int) { - b.addLine("}\n", indent) // Closes the map definition - - s := fmt.Sprintf("func (%s) SwaggerDoc() map[string]string {\n", structName) - b.addLine(s, indent) - s = fmt.Sprintf("return map_%s\n", structName) - b.addLine(s, indent+1) - b.addLine("}\n", indent) // Closes the function definition -} - -func writeMapBody(b *buffer, kubeType []Pair, indent int) { - format := "\"%s\": \"%s\",\n" - for _, pair := range kubeType { - s := fmt.Sprintf(format, pair.Name, pair.Doc) - b.addLine(s, indent+2) - } -} - -// ParseDocumentationFrom gets all types' documentation and returns them as an -// array. Each type is again represented as an array (we have to use arrays as we -// need to be sure for the order of the fields). This function returns fields and -// struct definitions that have no documentation as {name, ""}. -func ParseDocumentationFrom(src string) []KubeTypes { - var docForTypes []KubeTypes - - pkg := astFrom(src) - - for _, kubType := range pkg.Types { - if structType, ok := kubType.Decl.Specs[0].(*ast.TypeSpec).Type.(*ast.StructType); ok { - var ks KubeTypes - ks = append(ks, Pair{kubType.Name, fmtRawDoc(kubType.Doc)}) - - for _, field := range structType.Fields.List { - if n := fieldName(field); n != "-" { - fieldDoc := fmtRawDoc(field.Doc.Text()) - ks = append(ks, Pair{n, fieldDoc}) - } - } - docForTypes = append(docForTypes, ks) - } - } - - return docForTypes -} - -// WriteSwaggerDocFunc writes a declaration of a function as a string. This function is used in -// Swagger as a documentation source for structs and theirs fields -func WriteSwaggerDocFunc(kubeTypes []KubeTypes, w io.Writer) error { - for _, kubeType := range kubeTypes { - structName := kubeType[0].Name - kubeType[0].Name = "" - - // Ignore empty documentation - docfulTypes := make(KubeTypes, 0, len(kubeType)) - for _, pair := range kubeType { - if pair.Doc != "" { - docfulTypes = append(docfulTypes, pair) - } - } - - if len(docfulTypes) == 0 { - continue // If no fields and the struct have documentation, skip the function definition - } - - indent := 0 - buffer := newBuffer() - - writeFuncHeader(buffer, structName, indent) - writeMapBody(buffer, docfulTypes, indent) - writeFuncFooter(buffer, structName, indent) - buffer.addLine("\n", 0) - - if err := buffer.flushLines(w); err != nil { - return err - } - } - - return nil -} - -// VerifySwaggerDocsExist writes in a io.Writer a list of structs and fields that -// are missing of documentation. -func VerifySwaggerDocsExist(kubeTypes []KubeTypes, w io.Writer) (int, error) { - missingDocs := 0 - buffer := newBuffer() - - for _, kubeType := range kubeTypes { - structName := kubeType[0].Name - if kubeType[0].Doc == "" { - format := "Missing documentation for the struct itself: %s\n" - s := fmt.Sprintf(format, structName) - buffer.addLine(s, 0) - missingDocs++ - } - kubeType = kubeType[1:] // Skip struct definition - - for _, pair := range kubeType { // Iterate only the fields - if pair.Doc == "" { - format := "In struct: %s, field documentation is missing: %s\n" - s := fmt.Sprintf(format, structName, pair.Name) - buffer.addLine(s, 0) - missingDocs++ - } - } - } - - if err := buffer.flushLines(w); err != nil { - return -1, err - } - return missingDocs, nil -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/types.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/types.go deleted file mode 100644 index 5033c0d..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/types.go +++ /dev/null @@ -1,514 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package runtime - -import ( - "fmt" - - "github.com/golang/glog" - - "k8s.io/kubernetes/pkg/api/meta/metatypes" - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/types" -) - -// Note that the types provided in this file are not versioned and are intended to be -// safe to use from within all versions of every API object. - -// TypeMeta is shared by all top level objects. The proper way to use it is to inline it in your type, -// like this: -// type MyAwesomeAPIObject struct { -// runtime.TypeMeta `json:",inline"` -// ... // other fields -// } -// func (obj *MyAwesomeAPIObject) SetGroupVersionKind(gvk *unversioned.GroupVersionKind) { unversioned.UpdateTypeMeta(obj,gvk) }; GroupVersionKind() *GroupVersionKind -// -// TypeMeta is provided here for convenience. You may use it directly from this package or define -// your own with the same fields. -// -// +k8s:deepcopy-gen=true -// +protobuf=true -type TypeMeta struct { - APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty" protobuf:"bytes,1,opt,name=apiVersion"` - Kind string `json:"kind,omitempty" yaml:"kind,omitempty" protobuf:"bytes,2,opt,name=kind"` -} - -const ( - ContentTypeJSON string = "application/json" -) - -// RawExtension is used to hold extensions in external versions. -// -// To use this, make a field which has RawExtension as its type in your external, versioned -// struct, and Object in your internal struct. You also need to register your -// various plugin types. -// -// // Internal package: -// type MyAPIObject struct { -// runtime.TypeMeta `json:",inline"` -// MyPlugin runtime.Object `json:"myPlugin"` -// } -// type PluginA struct { -// AOption string `json:"aOption"` -// } -// -// // External package: -// type MyAPIObject struct { -// runtime.TypeMeta `json:",inline"` -// MyPlugin runtime.RawExtension `json:"myPlugin"` -// } -// type PluginA struct { -// AOption string `json:"aOption"` -// } -// -// // On the wire, the JSON will look something like this: -// { -// "kind":"MyAPIObject", -// "apiVersion":"v1", -// "myPlugin": { -// "kind":"PluginA", -// "aOption":"foo", -// }, -// } -// -// So what happens? Decode first uses json or yaml to unmarshal the serialized data into -// your external MyAPIObject. That causes the raw JSON to be stored, but not unpacked. -// The next step is to copy (using pkg/conversion) into the internal struct. The runtime -// package's DefaultScheme has conversion functions installed which will unpack the -// JSON stored in RawExtension, turning it into the correct object type, and storing it -// in the Object. (TODO: In the case where the object is of an unknown type, a -// runtime.Unknown object will be created and stored.) -// -// +k8s:deepcopy-gen=true -// +protobuf=true -type RawExtension struct { - // Raw is the underlying serialization of this object. - // - // TODO: Determine how to detect ContentType and ContentEncoding of 'Raw' data. - Raw []byte `protobuf:"bytes,1,opt,name=raw"` - // Object can hold a representation of this extension - useful for working with versioned - // structs. - Object Object `json:"-"` -} - -// Unknown allows api objects with unknown types to be passed-through. This can be used -// to deal with the API objects from a plug-in. Unknown objects still have functioning -// TypeMeta features-- kind, version, etc. -// TODO: Make this object have easy access to field based accessors and settors for -// metadata and field mutatation. -// -// +k8s:deepcopy-gen=true -// +protobuf=true -type Unknown struct { - TypeMeta `json:",inline" protobuf:"bytes,1,opt,name=typeMeta"` - // Raw will hold the complete serialized object which couldn't be matched - // with a registered type. Most likely, nothing should be done with this - // except for passing it through the system. - Raw []byte `protobuf:"bytes,2,opt,name=raw"` - // ContentEncoding is encoding used to encode 'Raw' data. - // Unspecified means no encoding. - ContentEncoding string `protobuf:"bytes,3,opt,name=contentEncoding"` - // ContentType is serialization method used to serialize 'Raw'. - // Unspecified means ContentTypeJSON. - ContentType string `protobuf:"bytes,4,opt,name=contentType"` -} - -// Unstructured allows objects that do not have Golang structs registered to be manipulated -// generically. This can be used to deal with the API objects from a plug-in. Unstructured -// objects still have functioning TypeMeta features-- kind, version, etc. -// TODO: Make this object have easy access to field based accessors and settors for -// metadata and field mutatation. -type Unstructured struct { - // Object is a JSON compatible map with string, float, int, []interface{}, or map[string]interface{} - // children. - Object map[string]interface{} -} - -func getNestedField(obj map[string]interface{}, fields ...string) interface{} { - var val interface{} = obj - for _, field := range fields { - if _, ok := val.(map[string]interface{}); !ok { - return nil - } - val = val.(map[string]interface{})[field] - } - return val -} - -func getNestedString(obj map[string]interface{}, fields ...string) string { - if str, ok := getNestedField(obj, fields...).(string); ok { - return str - } - return "" -} - -func getNestedSlice(obj map[string]interface{}, fields ...string) []string { - if m, ok := getNestedField(obj, fields...).([]interface{}); ok { - strSlice := make([]string, 0, len(m)) - for _, v := range m { - if str, ok := v.(string); ok { - strSlice = append(strSlice, str) - } - } - return strSlice - } - return nil -} - -func getNestedMap(obj map[string]interface{}, fields ...string) map[string]string { - if m, ok := getNestedField(obj, fields...).(map[string]interface{}); ok { - strMap := make(map[string]string, len(m)) - for k, v := range m { - if str, ok := v.(string); ok { - strMap[k] = str - } - } - return strMap - } - return nil -} - -func setNestedField(obj map[string]interface{}, value interface{}, fields ...string) { - m := obj - if len(fields) > 1 { - for _, field := range fields[0 : len(fields)-1] { - if _, ok := m[field].(map[string]interface{}); !ok { - m[field] = make(map[string]interface{}) - } - m = m[field].(map[string]interface{}) - } - } - m[fields[len(fields)-1]] = value -} - -func setNestedSlice(obj map[string]interface{}, value []string, fields ...string) { - m := make([]interface{}, 0, len(value)) - for _, v := range value { - m = append(m, v) - } - setNestedField(obj, m, fields...) -} - -func setNestedMap(obj map[string]interface{}, value map[string]string, fields ...string) { - m := make(map[string]interface{}, len(value)) - for k, v := range value { - m[k] = v - } - setNestedField(obj, m, fields...) -} - -func (u *Unstructured) setNestedField(value interface{}, fields ...string) { - if u.Object == nil { - u.Object = make(map[string]interface{}) - } - setNestedField(u.Object, value, fields...) -} - -func (u *Unstructured) setNestedSlice(value []string, fields ...string) { - if u.Object == nil { - u.Object = make(map[string]interface{}) - } - setNestedSlice(u.Object, value, fields...) -} - -func (u *Unstructured) setNestedMap(value map[string]string, fields ...string) { - if u.Object == nil { - u.Object = make(map[string]interface{}) - } - setNestedMap(u.Object, value, fields...) -} - -func extractOwnerReference(src interface{}) metatypes.OwnerReference { - v := src.(map[string]interface{}) - controllerPtr, ok := (getNestedField(v, "controller")).(*bool) - if !ok { - controllerPtr = nil - } else { - if controllerPtr != nil { - controller := *controllerPtr - controllerPtr = &controller - } - } - return metatypes.OwnerReference{ - Kind: getNestedString(v, "kind"), - Name: getNestedString(v, "name"), - APIVersion: getNestedString(v, "apiVersion"), - UID: (types.UID)(getNestedString(v, "uid")), - Controller: controllerPtr, - } -} - -func setOwnerReference(src metatypes.OwnerReference) map[string]interface{} { - ret := make(map[string]interface{}) - controllerPtr := src.Controller - if controllerPtr != nil { - controller := *controllerPtr - controllerPtr = &controller - } - setNestedField(ret, src.Kind, "kind") - setNestedField(ret, src.Name, "name") - setNestedField(ret, src.APIVersion, "apiVersion") - setNestedField(ret, string(src.UID), "uid") - setNestedField(ret, controllerPtr, "controller") - return ret -} - -func getOwnerReferences(object map[string]interface{}) ([]map[string]interface{}, error) { - field := getNestedField(object, "metadata", "ownerReferences") - if field == nil { - return nil, fmt.Errorf("cannot find field metadata.ownerReferences in %v", object) - } - ownerReferences, ok := field.([]map[string]interface{}) - if ok { - return ownerReferences, nil - } - // TODO: This is hacky... - interfaces, ok := field.([]interface{}) - if !ok { - return nil, fmt.Errorf("expect metadata.ownerReferences to be a slice in %#v", object) - } - ownerReferences = make([]map[string]interface{}, 0, len(interfaces)) - for i := 0; i < len(interfaces); i++ { - r, ok := interfaces[i].(map[string]interface{}) - if !ok { - return nil, fmt.Errorf("expect element metadata.ownerReferences to be a map[string]interface{} in %#v", object) - } - ownerReferences = append(ownerReferences, r) - } - return ownerReferences, nil -} - -func (u *Unstructured) GetOwnerReferences() []metatypes.OwnerReference { - original, err := getOwnerReferences(u.Object) - if err != nil { - glog.V(6).Info(err) - return nil - } - ret := make([]metatypes.OwnerReference, 0, len(original)) - for i := 0; i < len(original); i++ { - ret = append(ret, extractOwnerReference(original[i])) - } - return ret -} - -func (u *Unstructured) SetOwnerReferences(references []metatypes.OwnerReference) { - var newReferences = make([]map[string]interface{}, 0, len(references)) - for i := 0; i < len(references); i++ { - newReferences = append(newReferences, setOwnerReference(references[i])) - } - u.setNestedField(newReferences, "metadata", "ownerReferences") -} - -func (u *Unstructured) GetAPIVersion() string { - return getNestedString(u.Object, "apiVersion") -} - -func (u *Unstructured) SetAPIVersion(version string) { - u.setNestedField(version, "apiVersion") -} - -func (u *Unstructured) GetKind() string { - return getNestedString(u.Object, "kind") -} - -func (u *Unstructured) SetKind(kind string) { - u.setNestedField(kind, "kind") -} - -func (u *Unstructured) GetNamespace() string { - return getNestedString(u.Object, "metadata", "namespace") -} - -func (u *Unstructured) SetNamespace(namespace string) { - u.setNestedField(namespace, "metadata", "namespace") -} - -func (u *Unstructured) GetName() string { - return getNestedString(u.Object, "metadata", "name") -} - -func (u *Unstructured) SetName(name string) { - u.setNestedField(name, "metadata", "name") -} - -func (u *Unstructured) GetGenerateName() string { - return getNestedString(u.Object, "metadata", "generateName") -} - -func (u *Unstructured) SetGenerateName(name string) { - u.setNestedField(name, "metadata", "generateName") -} - -func (u *Unstructured) GetUID() types.UID { - return types.UID(getNestedString(u.Object, "metadata", "uid")) -} - -func (u *Unstructured) SetUID(uid types.UID) { - u.setNestedField(string(uid), "metadata", "uid") -} - -func (u *Unstructured) GetResourceVersion() string { - return getNestedString(u.Object, "metadata", "resourceVersion") -} - -func (u *Unstructured) SetResourceVersion(version string) { - u.setNestedField(version, "metadata", "resourceVersion") -} - -func (u *Unstructured) GetSelfLink() string { - return getNestedString(u.Object, "metadata", "selfLink") -} - -func (u *Unstructured) SetSelfLink(selfLink string) { - u.setNestedField(selfLink, "metadata", "selfLink") -} - -func (u *Unstructured) GetCreationTimestamp() unversioned.Time { - var timestamp unversioned.Time - timestamp.UnmarshalQueryParameter(getNestedString(u.Object, "metadata", "creationTimestamp")) - return timestamp -} - -func (u *Unstructured) SetCreationTimestamp(timestamp unversioned.Time) { - ts, _ := timestamp.MarshalQueryParameter() - u.setNestedField(ts, "metadata", "creationTimestamp") -} - -func (u *Unstructured) GetDeletionTimestamp() *unversioned.Time { - var timestamp unversioned.Time - timestamp.UnmarshalQueryParameter(getNestedString(u.Object, "metadata", "deletionTimestamp")) - if timestamp.IsZero() { - return nil - } - return ×tamp -} - -func (u *Unstructured) SetDeletionTimestamp(timestamp *unversioned.Time) { - ts, _ := timestamp.MarshalQueryParameter() - u.setNestedField(ts, "metadata", "deletionTimestamp") -} - -func (u *Unstructured) GetLabels() map[string]string { - return getNestedMap(u.Object, "metadata", "labels") -} - -func (u *Unstructured) SetLabels(labels map[string]string) { - u.setNestedMap(labels, "metadata", "labels") -} - -func (u *Unstructured) GetAnnotations() map[string]string { - return getNestedMap(u.Object, "metadata", "annotations") -} - -func (u *Unstructured) SetAnnotations(annotations map[string]string) { - u.setNestedMap(annotations, "metadata", "annotations") -} - -func (u *Unstructured) SetGroupVersionKind(gvk unversioned.GroupVersionKind) { - u.SetAPIVersion(gvk.GroupVersion().String()) - u.SetKind(gvk.Kind) -} - -func (u *Unstructured) GroupVersionKind() unversioned.GroupVersionKind { - gv, err := unversioned.ParseGroupVersion(u.GetAPIVersion()) - if err != nil { - return unversioned.GroupVersionKind{} - } - gvk := gv.WithKind(u.GetKind()) - return gvk -} - -func (u *Unstructured) GetFinalizers() []string { - return getNestedSlice(u.Object, "metadata", "finalizers") -} - -func (u *Unstructured) SetFinalizers(finalizers []string) { - u.setNestedSlice(finalizers, "metadata", "finalizers") -} - -// UnstructuredList allows lists that do not have Golang structs -// registered to be manipulated generically. This can be used to deal -// with the API lists from a plug-in. -type UnstructuredList struct { - Object map[string]interface{} - - // Items is a list of unstructured objects. - Items []*Unstructured `json:"items"` -} - -func (u *UnstructuredList) setNestedField(value interface{}, fields ...string) { - if u.Object == nil { - u.Object = make(map[string]interface{}) - } - setNestedField(u.Object, value, fields...) -} - -func (u *UnstructuredList) GetAPIVersion() string { - return getNestedString(u.Object, "apiVersion") -} - -func (u *UnstructuredList) SetAPIVersion(version string) { - u.setNestedField(version, "apiVersion") -} - -func (u *UnstructuredList) GetKind() string { - return getNestedString(u.Object, "kind") -} - -func (u *UnstructuredList) SetKind(kind string) { - u.setNestedField(kind, "kind") -} - -func (u *UnstructuredList) GetResourceVersion() string { - return getNestedString(u.Object, "metadata", "resourceVersion") -} - -func (u *UnstructuredList) SetResourceVersion(version string) { - u.setNestedField(version, "metadata", "resourceVersion") -} - -func (u *UnstructuredList) GetSelfLink() string { - return getNestedString(u.Object, "metadata", "selfLink") -} - -func (u *UnstructuredList) SetSelfLink(selfLink string) { - u.setNestedField(selfLink, "metadata", "selfLink") -} - -func (u *UnstructuredList) SetGroupVersionKind(gvk unversioned.GroupVersionKind) { - u.SetAPIVersion(gvk.GroupVersion().String()) - u.SetKind(gvk.Kind) -} - -func (u *UnstructuredList) GroupVersionKind() unversioned.GroupVersionKind { - gv, err := unversioned.ParseGroupVersion(u.GetAPIVersion()) - if err != nil { - return unversioned.GroupVersionKind{} - } - gvk := gv.WithKind(u.GetKind()) - return gvk -} - -// VersionedObjects is used by Decoders to give callers a way to access all versions -// of an object during the decoding process. -type VersionedObjects struct { - // Objects is the set of objects retrieved during decoding, in order of conversion. - // The 0 index is the object as serialized on the wire. If conversion has occurred, - // other objects may be present. The right most object is the same as would be returned - // by a normal Decode call. - Objects []Object -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/types_proto.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/types_proto.go deleted file mode 100644 index ead96ee..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/types_proto.go +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package runtime - -import ( - "fmt" -) - -type ProtobufMarshaller interface { - MarshalTo(data []byte) (int, error) -} - -// NestedMarshalTo allows a caller to avoid extra allocations during serialization of an Unknown -// that will contain an object that implements ProtobufMarshaller. -func (m *Unknown) NestedMarshalTo(data []byte, b ProtobufMarshaller, size uint64) (int, error) { - var i int - _ = i - var l int - _ = l - data[i] = 0xa - i++ - i = encodeVarintGenerated(data, i, uint64(m.TypeMeta.Size())) - n1, err := m.TypeMeta.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n1 - - if b != nil { - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, size) - n2, err := b.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - if uint64(n2) != size { - // programmer error: the Size() method for protobuf does not match the results of MarshalTo, which means the proto - // struct returned would be wrong. - return 0, fmt.Errorf("the Size() value of %T was %d, but NestedMarshalTo wrote %d bytes to data", b, size, n2) - } - i += n2 - } - - data[i] = 0x1a - i++ - i = encodeVarintGenerated(data, i, uint64(len(m.ContentEncoding))) - i += copy(data[i:], m.ContentEncoding) - - data[i] = 0x22 - i++ - i = encodeVarintGenerated(data, i, uint64(len(m.ContentType))) - i += copy(data[i:], m.ContentType) - return i, nil -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/unstructured.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/unstructured.go deleted file mode 100644 index 048e6dc..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/runtime/unstructured.go +++ /dev/null @@ -1,199 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package runtime - -import ( - gojson "encoding/json" - "errors" - "fmt" - "io" - "strings" - - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/util/json" -) - -// UnstructuredJSONScheme is capable of converting JSON data into the Unstructured -// type, which can be used for generic access to objects without a predefined scheme. -// TODO: move into serializer/json. -var UnstructuredJSONScheme Codec = unstructuredJSONScheme{} - -type unstructuredJSONScheme struct{} - -func (s unstructuredJSONScheme) Decode(data []byte, _ *unversioned.GroupVersionKind, obj Object) (Object, *unversioned.GroupVersionKind, error) { - var err error - if obj != nil { - err = s.decodeInto(data, obj) - } else { - obj, err = s.decode(data) - } - - if err != nil { - return nil, nil, err - } - - gvk := obj.GetObjectKind().GroupVersionKind() - if len(gvk.Kind) == 0 { - return nil, &gvk, NewMissingKindErr(string(data)) - } - - return obj, &gvk, nil -} - -func (unstructuredJSONScheme) Encode(obj Object, w io.Writer) error { - switch t := obj.(type) { - case *Unstructured: - return json.NewEncoder(w).Encode(t.Object) - case *UnstructuredList: - items := make([]map[string]interface{}, 0, len(t.Items)) - for _, i := range t.Items { - items = append(items, i.Object) - } - t.Object["items"] = items - defer func() { delete(t.Object, "items") }() - return json.NewEncoder(w).Encode(t.Object) - case *Unknown: - // TODO: Unstructured needs to deal with ContentType. - _, err := w.Write(t.Raw) - return err - default: - return json.NewEncoder(w).Encode(t) - } -} - -func (s unstructuredJSONScheme) decode(data []byte) (Object, error) { - type detector struct { - Items gojson.RawMessage - } - var det detector - if err := json.Unmarshal(data, &det); err != nil { - return nil, err - } - - if det.Items != nil { - list := &UnstructuredList{} - err := s.decodeToList(data, list) - return list, err - } - - // No Items field, so it wasn't a list. - unstruct := &Unstructured{} - err := s.decodeToUnstructured(data, unstruct) - return unstruct, err -} -func (s unstructuredJSONScheme) decodeInto(data []byte, obj Object) error { - switch x := obj.(type) { - case *Unstructured: - return s.decodeToUnstructured(data, x) - case *UnstructuredList: - return s.decodeToList(data, x) - case *VersionedObjects: - u := new(Unstructured) - err := s.decodeToUnstructured(data, u) - if err == nil { - x.Objects = []Object{u} - } - return err - default: - return json.Unmarshal(data, x) - } -} - -func (unstructuredJSONScheme) decodeToUnstructured(data []byte, unstruct *Unstructured) error { - m := make(map[string]interface{}) - if err := json.Unmarshal(data, &m); err != nil { - return err - } - - unstruct.Object = m - - return nil -} - -func (s unstructuredJSONScheme) decodeToList(data []byte, list *UnstructuredList) error { - type decodeList struct { - Items []gojson.RawMessage - } - - var dList decodeList - if err := json.Unmarshal(data, &dList); err != nil { - return err - } - - if err := json.Unmarshal(data, &list.Object); err != nil { - return err - } - - // For typed lists, e.g., a PodList, API server doesn't set each item's - // APIVersion and Kind. We need to set it. - listAPIVersion := list.GetAPIVersion() - listKind := list.GetKind() - itemKind := strings.TrimSuffix(listKind, "List") - - delete(list.Object, "items") - list.Items = nil - for _, i := range dList.Items { - unstruct := &Unstructured{} - if err := s.decodeToUnstructured([]byte(i), unstruct); err != nil { - return err - } - // This is hacky. Set the item's Kind and APIVersion to those inferred - // from the List. - if len(unstruct.GetKind()) == 0 && len(unstruct.GetAPIVersion()) == 0 { - unstruct.SetKind(itemKind) - unstruct.SetAPIVersion(listAPIVersion) - } - list.Items = append(list.Items, unstruct) - } - return nil -} - -// UnstructuredObjectConverter is an ObjectConverter for use with -// Unstructured objects. Since it has no schema or type information, -// it will only succeed for no-op conversions. This is provided as a -// sane implementation for APIs that require an object converter. -type UnstructuredObjectConverter struct{} - -func (UnstructuredObjectConverter) Convert(in, out interface{}) error { - unstructIn, ok := in.(*Unstructured) - if !ok { - return fmt.Errorf("input type %T in not valid for unstructured conversion", in) - } - - unstructOut, ok := out.(*Unstructured) - if !ok { - return fmt.Errorf("output type %T in not valid for unstructured conversion", out) - } - - // maybe deep copy the map? It is documented in the - // ObjectConverter interface that this function is not - // guaranteeed to not mutate the input. Or maybe set the input - // object to nil. - unstructOut.Object = unstructIn.Object - return nil -} - -func (UnstructuredObjectConverter) ConvertToVersion(in Object, outVersion unversioned.GroupVersion) (Object, error) { - if gvk := in.GetObjectKind().GroupVersionKind(); gvk.GroupVersion() != outVersion { - return nil, errors.New("unstructured converter cannot convert versions") - } - return in, nil -} - -func (UnstructuredObjectConverter) ConvertFieldLabel(version, kind, label, value string) (string, string, error) { - return "", "", errors.New("unstructured cannot convert field labels") -} -- cgit 1.2.3-korg