Documentation ¶
Overview ¶
Defines conversions between generic types and structs to map query strings to struct objects.
Package runtime includes helper functions for working with API objects that follow the kubernetes API object conventions, which are:
- Your API objects have a common metadata struct member, TypeMeta.
- Your code refers to an internal set of API objects.
- In a separate package, you have an external set of API objects.
- 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).
- As your api evolves, you'll make an additional versioned package with every major change.
- Versioned packages have conversion functions which convert to and from the internal version.
- 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.
- 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.
Index ¶
- Constants
- Variables
- func DecodeInto(d Decoder, data []byte, into Object) error
- func DecodeList(objects []Object, decoders ...Decoder) []error
- func DefaultEmbeddedConversions() []interface{}
- func Encode(e Encoder, obj Object, overrides ...unversioned.GroupVersion) ([]byte, error)
- func EncodeList(e Encoder, objects []Object, overrides ...unversioned.GroupVersion) error
- func EncodeOrDie(e Encoder, obj Object) string
- func FieldPtr(v reflect.Value, fieldName string, dest interface{}) error
- func IsMissingKind(err error) bool
- func IsMissingVersion(err error) bool
- func IsNotRegisteredError(err error) bool
- func JSONKeyMapper(key string, sourceTag, destTag reflect.StructTag) (string, string)
- func NewMissingKindErr(data string) error
- func NewMissingVersionErr(data string) error
- func VerifySwaggerDocsExist(kubeTypes []KubeTypes, w io.Writer) (int, error)
- func WriteSwaggerDocFunc(kubeTypes []KubeTypes, w io.Writer) error
- type Codec
- type ConversionGenerator
- type Decoder
- type DeepCopyGenerator
- type Encoder
- type FieldLabelConversionFunc
- type KubeTypes
- type MultiObjectTyper
- func (m MultiObjectTyper) IsUnversioned(obj Object) (bool, bool)
- func (m MultiObjectTyper) ObjectKind(obj Object) (gvk unversioned.GroupVersionKind, err error)
- func (m MultiObjectTyper) ObjectKinds(obj Object) (gvks []unversioned.GroupVersionKind, err error)
- func (m MultiObjectTyper) Recognizes(gvk unversioned.GroupVersionKind) bool
- type NegotiatedSerializer
- type NoopDecoder
- type NoopEncoder
- type Object
- func Decode(d Decoder, data []byte) (Object, error)
- func NewEncodable(e Encoder, obj Object, versions ...unversioned.GroupVersion) Object
- func NewEncodableList(e Encoder, objects []Object, versions ...unversioned.GroupVersion) []Object
- func UseOrCreateObject(t Typer, c ObjectCreater, gvk unversioned.GroupVersionKind, obj Object) (Object, error)
- type ObjectConvertor
- type ObjectCopier
- type ObjectCreater
- type ObjectTyper
- type ObjectVersioner
- type Pair
- type ParameterCodec
- type RawExtension
- type ResourceVersioner
- type Scheme
- func (s *Scheme) AddConversionFuncs(conversionFuncs ...interface{}) error
- func (s *Scheme) AddDeepCopyFuncs(deepCopyFuncs ...interface{}) error
- func (s *Scheme) AddDefaultingFuncs(defaultingFuncs ...interface{}) error
- func (s *Scheme) AddFieldLabelConversionFunc(version, kind string, conversionFunc FieldLabelConversionFunc) error
- func (s *Scheme) AddGeneratedConversionFuncs(conversionFuncs ...interface{}) error
- func (s *Scheme) AddGeneratedDeepCopyFuncs(deepCopyFuncs ...interface{}) error
- func (s *Scheme) AddIgnoredConversionType(from, to interface{}) error
- func (s *Scheme) AddKnownTypeWithName(gvk unversioned.GroupVersionKind, obj Object)
- func (s *Scheme) AddKnownTypes(gv unversioned.GroupVersion, types ...Object)
- func (s *Scheme) AddStructFieldConversion(srcFieldType interface{}, srcFieldName string, destFieldType interface{}, ...) error
- func (s *Scheme) AddUnversionedTypes(gv unversioned.GroupVersion, types ...Object)
- func (s *Scheme) Convert(in, out interface{}) error
- func (s *Scheme) ConvertFieldLabel(version, kind, label, value string) (string, string, error)
- func (s *Scheme) ConvertToVersion(in Object, outVersion string) (Object, error)
- func (s *Scheme) Copy(src Object) (Object, error)
- func (s *Scheme) DeepCopy(src interface{}) (interface{}, error)
- func (s *Scheme) IsUnversioned(obj Object) (bool, bool)
- func (s *Scheme) KnownTypes(gv unversioned.GroupVersion) map[string]reflect.Type
- func (s *Scheme) Log(l conversion.DebugLogger)
- func (s *Scheme) New(kind unversioned.GroupVersionKind) (Object, error)
- func (s *Scheme) ObjectKind(obj Object) (unversioned.GroupVersionKind, error)
- func (s *Scheme) ObjectKinds(obj Object) ([]unversioned.GroupVersionKind, error)
- func (self *Scheme) Raw() *conversion.Scheme
- func (s *Scheme) Recognizes(gvk unversioned.GroupVersionKind) bool
- func (s *Scheme) WithConversions(fns *conversion.ConversionFuncs) ObjectConvertor
- type SelfLinker
- type Serializer
- type TypeMeta
- type Typer
- type Unknown
- type Unstructured
- type VersionedObjects
Constants ¶
const ( APIVersionInternal = "__internal" APIVersionUnversioned = "__unversioned" )
Variables ¶
var DefaultStringConversions = []interface{}{
convertStringSliceToString,
convertStringSliceToInt,
convertStringSliceToBool,
convertStringSliceToInt64,
}
DefaultStringConversions are helpers for converting []string and string to real values.
Functions ¶
func DecodeInto ¶ added in v1.1.2
DecodeInto performs a Decode into the provided object.
func DecodeList ¶
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 DefaultEmbeddedConversions ¶ added in v1.1.3
func DefaultEmbeddedConversions() []interface{}
func Encode ¶ added in v1.1.2
func Encode(e Encoder, obj Object, overrides ...unversioned.GroupVersion) ([]byte, error)
Encode is a convenience wrapper for encoding to a []byte from an Encoder
func EncodeList ¶ added in v1.1.3
func EncodeList(e Encoder, objects []Object, overrides ...unversioned.GroupVersion) error
EncodeList ensures that each object in an array is converted to a Unknown{} in serialized form. TODO: accept a content type.
func EncodeOrDie ¶
EncodeOrDie is a version of Encode which will panic instead of returning an error. For tests.
func FieldPtr ¶
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 IsMissingKind ¶
IsMissingKind returns true if the error indicates that the provided object is missing a 'Kind' field.
func IsMissingVersion ¶
IsMissingVersion returns true if the error indicates that the provided object is missing a 'Versioj' field.
func IsNotRegisteredError ¶
IsNotRegisteredError returns true if the error indicates the provided object or input data is not registered.
func JSONKeyMapper ¶
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 NewMissingKindErr ¶ added in v1.1.3
func NewMissingVersionErr ¶ added in v1.1.3
func VerifySwaggerDocsExist ¶ added in v1.0.7
VerifySwaggerDocsExist writes in a io.Writer a list of structs and fields that are missing of documentation.
Types ¶
type Codec ¶
type Codec Serializer
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.
var UnstructuredJSONScheme Codec = unstructuredJSONScheme{}
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.
type ConversionGenerator ¶
type ConversionGenerator interface { GenerateConversionsForType(groupVersion unversioned.GroupVersion, reflection reflect.Type) error WriteConversionFunctions(w io.Writer) error RegisterConversionFunctions(w io.Writer, pkg string) error AddImport(pkg string) string RepackImports(exclude sets.String) WriteImports(w io.Writer) error OverwritePackage(pkg, overwrite string) AssumePrivateConversions() }
func NewConversionGenerator ¶
func NewConversionGenerator(scheme *conversion.Scheme, targetPkg string) ConversionGenerator
type Decoder ¶
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) }
type DeepCopyGenerator ¶
type DeepCopyGenerator interface { // Adds a type to a generator. // If the type is non-struct, it will return an error, otherwise deep-copy // functions for this type and all nested types will be generated. AddType(inType reflect.Type) error // ReplaceType registers a type that should be used instead of the type // with the provided pkgPath and name. ReplaceType(pkgPath, name string, in interface{}) // AddImport registers a package name with the generator and returns its // short name. AddImport(pkgPath string) string // RepackImports creates a stable ordering of import short names RepackImports() // Writes all imports that are necessary for deep-copy function and // their registration. WriteImports(w io.Writer) error // Writes deel-copy functions for all types added via AddType() method // and their nested types. WriteDeepCopyFunctions(w io.Writer) error // Writes an init() function that registers all the generated deep-copy // functions. RegisterDeepCopyFunctions(w io.Writer, pkg string) error // When generating code, all references to "pkg" package name will be // replaced with "overwrite". It is used mainly to replace references // to name of the package in which the code will be created with empty // string. OverwritePackage(pkg, overwrite string) }
TODO(wojtek-t): As suggested in #8320, we should consider the strategy to first do the shallow copy and then recurse into things that need a deep copy (maps, pointers, slices). That sort of copy function would need one parameter - a pointer to the thing it's supposed to expand, and it would involve a lot less memory copying.
func NewDeepCopyGenerator ¶
func NewDeepCopyGenerator(scheme *conversion.Scheme, targetPkg string, include sets.String) DeepCopyGenerator
type Encoder ¶
type Encoder interface { // EncodeToStream writes an object to a stream. Override versions may be provided for each group // that enforce a certain versioning. Implementations may return errors if the versions are incompatible, // or if no conversion is defined. EncodeToStream(obj Object, stream io.Writer, overrides ...unversioned.GroupVersion) error }
type FieldLabelConversionFunc ¶
type FieldLabelConversionFunc func(label, value string) (internalLabel, internalValue string, err error)
Function to convert a field selector to internal representation.
type KubeTypes ¶ added in v1.0.7
type KubeTypes []Pair
KubeTypes is an array to represent all available types in a parsed file. [0] is for the type itself
func ParseDocumentationFrom ¶ added in v1.0.7
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, ""}.
type MultiObjectTyper ¶
type MultiObjectTyper []ObjectTyper
MultiObjectTyper returns the types of objects across multiple schemes in order.
func (MultiObjectTyper) IsUnversioned ¶ added in v1.1.3
func (m MultiObjectTyper) IsUnversioned(obj Object) (bool, bool)
func (MultiObjectTyper) ObjectKind ¶ added in v1.1.2
func (m MultiObjectTyper) ObjectKind(obj Object) (gvk unversioned.GroupVersionKind, err error)
func (MultiObjectTyper) ObjectKinds ¶ added in v1.1.2
func (m MultiObjectTyper) ObjectKinds(obj Object) (gvks []unversioned.GroupVersionKind, err error)
func (MultiObjectTyper) Recognizes ¶
func (m MultiObjectTyper) Recognizes(gvk unversioned.GroupVersionKind) bool
type NegotiatedSerializer ¶ added in v1.1.3
type NegotiatedSerializer interface { SupportedMediaTypes() []string SerializerForMediaType(mediaType string, options map[string]string) (Serializer, bool) EncoderForVersion(serializer Serializer, gv unversioned.GroupVersion) Encoder DecoderToVersion(serializer Serializer, gv unversioned.GroupVersion) Decoder }
NegotiatedSerializer is an interface used for obtaining encoders, decoders, and serializers for multiple supported media types.
type NoopDecoder ¶ added in v1.1.3
type NoopDecoder struct {
Encoder
}
NoopDecoder converts an Encoder to a Serializer or Codec for code that expects them but only uses encoding.
func (NoopDecoder) Decode ¶ added in v1.1.3
func (n NoopDecoder) Decode(data []byte, gvk *unversioned.GroupVersionKind, into Object) (Object, *unversioned.GroupVersionKind, error)
type NoopEncoder ¶ added in v1.1.3
type NoopEncoder struct {
Decoder
}
NoopEncoder converts an Decoder to a Serializer or Codec for code that expects them but only uses decoding.
func (NoopEncoder) EncodeToStream ¶ added in v1.1.3
func (n NoopEncoder) EncodeToStream(obj Object, w io.Writer, overrides ...unversioned.GroupVersion) error
type Object ¶
type Object interface {
GetObjectKind() unversioned.ObjectKind
}
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.
func NewEncodable ¶ added in v1.1.3
func NewEncodable(e Encoder, obj Object, versions ...unversioned.GroupVersion) Object
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 NewEncodableList ¶ added in v1.1.3
func NewEncodableList(e Encoder, objects []Object, versions ...unversioned.GroupVersion) []Object
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 UseOrCreateObject ¶ added in v1.1.3
func UseOrCreateObject(t Typer, c ObjectCreater, gvk unversioned.GroupVersionKind, obj Object) (Object, error)
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.
type ObjectConvertor ¶
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 string) (out Object, err error) ConvertFieldLabel(version, kind, label, value string) (string, string, error) }
ObjectConvertor converts an object to a different version.
type ObjectCopier ¶
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) }
ObjectCopier duplicates an object.
type ObjectCreater ¶
type ObjectCreater interface {
New(kind unversioned.GroupVersionKind) (out Object, err error)
}
ObjectCreater contains methods for instantiating an object by kind and version.
type ObjectTyper ¶
type ObjectTyper interface { // ObjectKind returns the default group,version,kind of the provided object, or an // error if the object is not recognized (IsNotRegisteredError will return true). ObjectKind(Object) (unversioned.GroupVersionKind, error) // ObjectKinds returns the all possible group,version,kind of the provided object, or an // error if the object is not recognized (IsNotRegisteredError will return true). ObjectKinds(Object) ([]unversioned.GroupVersionKind, 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 // IsUnversioned returns true if the provided object is considered unversioned and thus // should have Version and Group suppressed in the output. If the object is not recognized // in the scheme, ok is false. IsUnversioned(Object) (unversioned bool, ok bool) }
ObjectTyper contains methods for extracting the APIVersion and Kind of objects.
type ObjectVersioner ¶ added in v1.1.3
type Pair ¶ added in v1.0.7
type Pair struct {
Name, Doc string
}
Pair of strings. We keed the name of fields and the doc
type ParameterCodec ¶ added in v1.1.3
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) }
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.
func NewParameterCodec ¶ added in v1.1.3
func NewParameterCodec(scheme *Scheme) ParameterCodec
NewParameterCodec creates a ParameterCodec capable of transforming url values into versioned objects and back.
type RawExtension ¶
type RawExtension struct { // RawJSON is the underlying serialization of this object. RawJSON []byte // Object can hold a representation of this extension - useful for working with versioned // structs. Object Object `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.)
+protobuf=true
func (RawExtension) MarshalJSON ¶
func (re RawExtension) MarshalJSON() ([]byte, error)
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 (*RawExtension) UnmarshalJSON ¶
func (re *RawExtension) UnmarshalJSON(in []byte) error
type ResourceVersioner ¶
type ResourceVersioner interface { SetResourceVersion(obj Object, version string) error ResourceVersion(obj Object) (string, error) }
ResourceVersioner provides methods for setting and retrieving the resource version from an API object.
type Scheme ¶
type Scheme struct {
// contains filtered or unexported fields
}
Scheme defines methods for serializing and deserializing API objects. It is an adaptation of conversion's Scheme for our API objects.
func NewScheme ¶
func NewScheme() *Scheme
NewScheme creates a new Scheme. This scheme is pluggable by default.
func (*Scheme) AddConversionFuncs ¶
AddConversionFuncs adds a function to the list of conversion functions. The given function should know how to convert between two API objects. We deduce how to call it from the types of its two parameters; see the comment for Converter.RegisterConversionFunction.
Note that, if you need to copy sub-objects that didn't change, it's safe to call Convert() inside your conversionFuncs, as long as you don't start a conversion chain that's infinitely recursive.
Also note that the default behavior, if you don't add a conversion function, is to sanely copy fields that have the same names. It's OK if the destination type has extra fields, but it must not remove any. So you only need to add a conversion function for things with changed/removed fields.
func (*Scheme) AddDeepCopyFuncs ¶
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 (*Scheme) AddDefaultingFuncs ¶
AddDefaultingFuncs adds a function to the list of value-defaulting functions. We deduce how to call it from the types of its two parameters; see the comment for Converter.RegisterDefaultingFunction.
func (*Scheme) AddFieldLabelConversionFunc ¶
func (s *Scheme) AddFieldLabelConversionFunc(version, kind string, conversionFunc FieldLabelConversionFunc) error
AddFieldLabelConversionFunc adds a conversion function to convert field selectors of the given kind from the given version to internal version representation.
func (*Scheme) AddGeneratedConversionFuncs ¶
Similar to AddConversionFuncs, but registers conversion functions that were automatically generated.
func (*Scheme) AddGeneratedDeepCopyFuncs ¶
Similar to AddDeepCopyFuncs, but registers deep-copy functions that were automatically generated.
func (*Scheme) AddIgnoredConversionType ¶ added in v1.1.3
AddIgnoredConversionType declares a particular conversion that should be ignored - during conversion this method is not invoked.
func (*Scheme) AddKnownTypeWithName ¶
func (s *Scheme) AddKnownTypeWithName(gvk unversioned.GroupVersionKind, obj Object)
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.
func (*Scheme) AddKnownTypes ¶
func (s *Scheme) AddKnownTypes(gv unversioned.GroupVersion, types ...Object)
AddKnownTypes registers the types of the arguments to the marshaller of the package api.
func (*Scheme) AddStructFieldConversion ¶
func (s *Scheme) AddStructFieldConversion(srcFieldType interface{}, srcFieldName string, destFieldType interface{}, destFieldName string) error
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 (*Scheme) AddUnversionedTypes ¶ added in v1.1.3
func (s *Scheme) AddUnversionedTypes(gv unversioned.GroupVersion, types ...Object)
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 tihs method at that point.
func (*Scheme) Convert ¶
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.
func (*Scheme) ConvertFieldLabel ¶
Converts the given field label and value for an kind field selector from versioned representation to an unversioned one.
func (*Scheme) ConvertToVersion ¶
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 (*Scheme) IsUnversioned ¶ added in v1.1.3
func (*Scheme) KnownTypes ¶
func (s *Scheme) KnownTypes(gv unversioned.GroupVersion) map[string]reflect.Type
KnownTypes returns the types known for the given version. Return value must be treated as read-only.
func (*Scheme) Log ¶
func (s *Scheme) Log(l conversion.DebugLogger)
Log sets a logger on the scheme. For test purposes only
func (*Scheme) New ¶
func (s *Scheme) New(kind unversioned.GroupVersionKind) (Object, error)
New returns a new API object of the given version ("" for internal representation) and name, or an error if it hasn't been registered.
func (*Scheme) ObjectKind ¶ added in v1.1.2
func (s *Scheme) ObjectKind(obj Object) (unversioned.GroupVersionKind, error)
ObjectKind returns the default group,version,kind of the given Object.
func (*Scheme) ObjectKinds ¶ added in v1.1.2
func (s *Scheme) ObjectKinds(obj Object) ([]unversioned.GroupVersionKind, error)
ObjectKinds returns the all possible group,version,kind of the given Object.
func (*Scheme) Raw ¶
func (self *Scheme) Raw() *conversion.Scheme
func (*Scheme) Recognizes ¶
func (s *Scheme) Recognizes(gvk unversioned.GroupVersionKind) bool
Recognizes returns true if the scheme is able to handle the provided group,version,kind of an object.
func (*Scheme) WithConversions ¶ added in v1.1.3
func (s *Scheme) WithConversions(fns *conversion.ConversionFuncs) ObjectConvertor
WithConversions returns an ObjectConvertor that has the additional conversion functions defined in fns. The current scheme is not altered.
type SelfLinker ¶
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) }
SelfLinker provides methods for setting and retrieving the SelfLink field of an API object.
type Serializer ¶ added in v1.1.3
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 TypeMeta ¶
type TypeMeta struct { APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` }
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.
+protobuf=true
func (*TypeMeta) GroupVersionKind ¶ added in v1.1.3
func (obj *TypeMeta) GroupVersionKind() *unversioned.GroupVersionKind
GroupVersionKind satisfies the ObjectKind interface for all objects that embed TypeMeta
func (*TypeMeta) SetGroupVersionKind ¶ added in v1.1.3
func (obj *TypeMeta) SetGroupVersionKind(gvk *unversioned.GroupVersionKind)
SetGroupVersionKind satisfies the ObjectKind interface for all objects that embed TypeMeta
type Typer ¶ added in v1.1.3
type Typer interface { // ObjectKind returns the version and kind of the provided object, or an // error if the object is not recognized (IsNotRegisteredError will return true). // It returns whether the object is considered unversioned at the same time. // TODO: align the signature of ObjectTyper with this interface ObjectKind(Object) (*unversioned.GroupVersionKind, bool, error) }
Typer retrieves information about an object's group, version, and kind.
func ObjectTyperToTyper ¶ added in v1.1.3
func ObjectTyperToTyper(typer ObjectTyper) Typer
type Unknown ¶
type Unknown struct { 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. RawJSON []byte }
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.
+protobuf=true
func (*Unknown) GetObjectKind ¶ added in v1.1.3
func (obj *Unknown) GetObjectKind() unversioned.ObjectKind
func (Unknown) MarshalJSON ¶ added in v1.1.3
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 (*Unknown) UnmarshalJSON ¶ added in v1.1.3
type Unstructured ¶
type Unstructured struct { TypeMeta `json:",inline"` // Object is a JSON compatible map with string, float, int, []interface{}, or map[string]interface{} // children. Object map[string]interface{} }
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.
func (*Unstructured) GetObjectKind ¶ added in v1.1.3
func (obj *Unstructured) GetObjectKind() unversioned.ObjectKind
type VersionedObjects ¶ added in v1.1.3
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 occured, // other objects may be present. The right most object is the same as would be returned // by a normal Decode call. Objects []Object }
VersionedObjects is used by Decoders to give callers a way to access all versions of an object during the decoding process.
func (*VersionedObjects) First ¶ added in v1.1.3
func (obj *VersionedObjects) First() Object
First returns the leftmost object in the VersionedObjects array, which is usually the object as serialized on the wire.
func (*VersionedObjects) GetObjectKind ¶ added in v1.1.3
func (obj *VersionedObjects) GetObjectKind() unversioned.ObjectKind
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 (*VersionedObjects) Last ¶ added in v1.1.3
func (obj *VersionedObjects) Last() Object
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).
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package protobuf implements ProtoBuf serialization and deserialization.
|
Package protobuf implements ProtoBuf serialization and deserialization. |