mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-09 21:21:14 +00:00
Remove unused YAML tags and GetYAML/SetYAML methods
Unneeded after move to ghodss/yaml.
This commit is contained in:
@@ -28,17 +28,17 @@ var scheme = runtime.NewScheme()
|
||||
var Codec = runtime.CodecFor(scheme, "v1test")
|
||||
|
||||
type EmbeddedTest struct {
|
||||
runtime.TypeMeta `yaml:",inline" json:",inline"`
|
||||
ID string `yaml:"id,omitempty" json:"id,omitempty"`
|
||||
Object runtime.EmbeddedObject `yaml:"object,omitempty" json:"object,omitempty"`
|
||||
EmptyObject runtime.EmbeddedObject `yaml:"emptyObject,omitempty" json:"emptyObject,omitempty"`
|
||||
runtime.TypeMeta `json:",inline"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Object runtime.EmbeddedObject `json:"object,omitempty"`
|
||||
EmptyObject runtime.EmbeddedObject `json:"emptyObject,omitempty"`
|
||||
}
|
||||
|
||||
type EmbeddedTestExternal struct {
|
||||
runtime.TypeMeta `yaml:",inline" json:",inline"`
|
||||
ID string `yaml:"id,omitempty" json:"id,omitempty"`
|
||||
Object runtime.RawExtension `yaml:"object,omitempty" json:"object,omitempty"`
|
||||
EmptyObject runtime.RawExtension `yaml:"emptyObject,omitempty" json:"emptyObject,omitempty"`
|
||||
runtime.TypeMeta `json:",inline"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Object runtime.RawExtension `json:"object,omitempty"`
|
||||
EmptyObject runtime.RawExtension `json:"emptyObject,omitempty"`
|
||||
}
|
||||
|
||||
func (*EmbeddedTest) IsAnAPIObject() {}
|
||||
|
@@ -16,11 +16,7 @@ limitations under the License.
|
||||
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
)
|
||||
import "errors"
|
||||
|
||||
func (re *RawExtension) UnmarshalJSON(in []byte) error {
|
||||
if re == nil {
|
||||
@@ -33,28 +29,3 @@ func (re *RawExtension) UnmarshalJSON(in []byte) error {
|
||||
func (re *RawExtension) MarshalJSON() ([]byte, error) {
|
||||
return re.RawJSON, nil
|
||||
}
|
||||
|
||||
// SetYAML implements the yaml.Setter interface.
|
||||
func (re *RawExtension) SetYAML(tag string, value interface{}) bool {
|
||||
if value == nil {
|
||||
re.RawJSON = []byte("null")
|
||||
return true
|
||||
}
|
||||
// Why does the yaml package send value as a map[interface{}]interface{}?
|
||||
// It's especially frustrating because encoding/json does the right thing
|
||||
// by giving a []byte. So here we do the embarrasing thing of re-encode and
|
||||
// de-encode the right way.
|
||||
// TODO: Write a version of Decode that uses reflect to turn this value
|
||||
// into an API object.
|
||||
b, err := yaml.Marshal(value)
|
||||
if err != nil {
|
||||
panic("yaml can't reverse its own object")
|
||||
}
|
||||
re.RawJSON = b
|
||||
return true
|
||||
}
|
||||
|
||||
// GetYAML implements the yaml.Getter interface.
|
||||
func (re *RawExtension) GetYAML() (tag string, value interface{}) {
|
||||
return tag, re.RawJSON
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ func (self *Scheme) fromScope(s conversion.Scope) (inVersion, outVersion string,
|
||||
|
||||
// emptyPlugin is used to copy the Kind field to and from plugin objects.
|
||||
type emptyPlugin struct {
|
||||
PluginBase `json:",inline" yaml:",inline"`
|
||||
PluginBase `json:",inline"`
|
||||
}
|
||||
|
||||
// embeddedObjectToRawExtension does the conversion you would expect from the name, using the information
|
||||
|
@@ -25,18 +25,18 @@ import (
|
||||
)
|
||||
|
||||
type TypeMeta struct {
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
APIVersion string `json:"apiVersion,omitempty"`
|
||||
}
|
||||
|
||||
type InternalSimple struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
TestString string `json:"testString" yaml:"testString"`
|
||||
TypeMeta `json:",inline"`
|
||||
TestString string `json:"testString"`
|
||||
}
|
||||
|
||||
type ExternalSimple struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
TestString string `json:"testString" yaml:"testString"`
|
||||
TypeMeta `json:",inline"`
|
||||
TestString string `json:"testString"`
|
||||
}
|
||||
|
||||
func (*InternalSimple) IsAnAPIObject() {}
|
||||
@@ -157,23 +157,23 @@ func TestBadJSONRejection(t *testing.T) {
|
||||
}
|
||||
|
||||
type ExtensionA struct {
|
||||
runtime.PluginBase `json:",inline" yaml:",inline"`
|
||||
TestString string `json:"testString" yaml:"testString"`
|
||||
runtime.PluginBase `json:",inline"`
|
||||
TestString string `json:"testString"`
|
||||
}
|
||||
|
||||
type ExtensionB struct {
|
||||
runtime.PluginBase `json:",inline" yaml:",inline"`
|
||||
TestString string `json:"testString" yaml:"testString"`
|
||||
runtime.PluginBase `json:",inline"`
|
||||
TestString string `json:"testString"`
|
||||
}
|
||||
|
||||
type ExternalExtensionType struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
Extension runtime.RawExtension `json:"extension" yaml:"extension"`
|
||||
TypeMeta `json:",inline"`
|
||||
Extension runtime.RawExtension `json:"extension"`
|
||||
}
|
||||
|
||||
type InternalExtensionType struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
Extension runtime.EmbeddedObject `json:"extension" yaml:"extension"`
|
||||
TypeMeta `json:",inline"`
|
||||
Extension runtime.EmbeddedObject `json:"extension"`
|
||||
}
|
||||
|
||||
func (*ExtensionA) IsAnAPIObject() {}
|
||||
|
@@ -26,7 +26,7 @@ import (
|
||||
// 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 `yaml:",inline" json:",inline"`
|
||||
// runtime.TypeMeta `json:",inline"`
|
||||
// ... // other fields
|
||||
// }
|
||||
// func (*MyAwesomeAPIObject) IsAnAPIObject() {}
|
||||
@@ -35,21 +35,21 @@ import (
|
||||
// your own with the same fields.
|
||||
//
|
||||
type TypeMeta struct {
|
||||
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
APIVersion string `json:"apiVersion,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
|
||||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
UID string `json:"uid,omitempty" yaml:"uid,omitempty"`
|
||||
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"`
|
||||
SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"`
|
||||
ResourceVersion string `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
UID string `json:"uid,omitempty"`
|
||||
CreationTimestamp util.Time `json:"creationTimestamp,omitempty"`
|
||||
SelfLink string `json:"selfLink,omitempty"`
|
||||
ResourceVersion string `json:"resourceVersion,omitempty"`
|
||||
}
|
||||
|
||||
// PluginBase is like TypeMeta, but it's intended for plugin objects that won't ever be encoded
|
||||
// except while embedded in other objects.
|
||||
type PluginBase struct {
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
}
|
||||
|
||||
// EmbeddedObject has appropriate encoder and decoder functions, such that on the wire, it's
|
||||
@@ -74,22 +74,22 @@ type EmbeddedObject struct {
|
||||
//
|
||||
// // Internal package:
|
||||
// type MyAPIObject struct {
|
||||
// runtime.TypeMeta `yaml:",inline" json:",inline"`
|
||||
// MyPlugin runtime.EmbeddedObject `json:"myPlugin" yaml:"myPlugin"`
|
||||
// runtime.TypeMeta `json:",inline"`
|
||||
// MyPlugin runtime.EmbeddedObject `json:"myPlugin"`
|
||||
// }
|
||||
// type PluginA struct {
|
||||
// runtime.PluginBase `yaml:",inline" json:",inline"`
|
||||
// AOption string `yaml:"aOption" json:"aOption"`
|
||||
// runtime.PluginBase `json:",inline"`
|
||||
// AOption string `json:"aOption"`
|
||||
// }
|
||||
//
|
||||
// // External package:
|
||||
// type MyAPIObject struct {
|
||||
// runtime.TypeMeta `yaml:",inline" json:",inline"`
|
||||
// MyPlugin runtime.RawExtension `json:"myPlugin" yaml:"myPlugin"`
|
||||
// runtime.TypeMeta `json:",inline"`
|
||||
// MyPlugin runtime.RawExtension `json:"myPlugin"`
|
||||
// }
|
||||
// type PluginA struct {
|
||||
// runtime.PluginBase `yaml:",inline" json:",inline"`
|
||||
// AOption string `yaml:"aOption" json:"aOption"`
|
||||
// runtime.PluginBase `json:",inline"`
|
||||
// AOption string `json:"aOption"`
|
||||
// }
|
||||
//
|
||||
// // On the wire, the JSON will look something like this:
|
||||
@@ -118,7 +118,7 @@ type RawExtension struct {
|
||||
// TypeMeta features-- kind, version, resourceVersion, etc.
|
||||
// TODO: Not implemented yet!
|
||||
type Unknown struct {
|
||||
TypeMeta `yaml:",inline" json:",inline"`
|
||||
TypeMeta `json:",inline"`
|
||||
// RawJSON will hold the complete JSON of the 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.
|
||||
|
Reference in New Issue
Block a user