Remove unused code
This commit is contained in:
parent
13992837ea
commit
485106e270
@ -21,7 +21,6 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/conversion"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/conversion"
|
||||||
"gopkg.in/v1/yaml"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Scheme defines methods for serializing and deserializing API objects. It
|
// Scheme defines methods for serializing and deserializing API objects. It
|
||||||
@ -274,33 +273,6 @@ func (s *Scheme) EncodeToVersion(obj Object, destVersion string) (data []byte, e
|
|||||||
return s.raw.EncodeToVersion(obj, destVersion)
|
return s.raw.EncodeToVersion(obj, destVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
// enforcePtr ensures that obj is a pointer of some sort. Returns a reflect.Value of the
|
|
||||||
// dereferenced pointer, ensuring that it is settable/addressable.
|
|
||||||
// Returns an error if this is not possible.
|
|
||||||
func enforcePtr(obj Object) (reflect.Value, error) {
|
|
||||||
v := reflect.ValueOf(obj)
|
|
||||||
if v.Kind() != reflect.Ptr {
|
|
||||||
return reflect.Value{}, fmt.Errorf("expected pointer, but got %v", v.Type().Name())
|
|
||||||
}
|
|
||||||
return v.Elem(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// VersionAndKind will return the APIVersion and Kind of the given wire-format
|
|
||||||
// enconding of an APIObject, or an error.
|
|
||||||
func VersionAndKind(data []byte) (version, kind string, err error) {
|
|
||||||
findKind := struct {
|
|
||||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
|
||||||
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
|
|
||||||
}{}
|
|
||||||
// yaml is a superset of json, so we use it to decode here. That way,
|
|
||||||
// we understand both.
|
|
||||||
err = yaml.Unmarshal(data, &findKind)
|
|
||||||
if err != nil {
|
|
||||||
return "", "", fmt.Errorf("couldn't get version/kind: %v", err)
|
|
||||||
}
|
|
||||||
return findKind.APIVersion, findKind.Kind, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode converts a YAML or JSON string back into a pointer to an api object.
|
// Decode converts a YAML or JSON string back into a pointer to an api object.
|
||||||
// Deduces the type based upon the APIVersion and Kind fields, which are set
|
// Deduces the type based upon the APIVersion and Kind fields, which are set
|
||||||
// by Encode. Only versioned objects (APIVersion != "") are accepted. The object
|
// by Encode. Only versioned objects (APIVersion != "") are accepted. The object
|
||||||
|
Loading…
Reference in New Issue
Block a user