kubernetes: github.com/CyrusBiotechnology/kubernetes/pkg/runtime Index | Files | Directories

package runtime

import "github.com/CyrusBiotechnology/kubernetes/pkg/runtime"

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:

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 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

Index

Package Files

codec.go codec_check.go conversion.go deep_copy_generated.go doc.go embedded.go error.go extension.go generated.pb.go helper.go interfaces.go register.go scheme.go swagger_doc_generator.go types.go types_proto.go unstructured.go

Constants

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"
)
const (
    ContentTypeJSON string = "application/json"
)

Variables

var (
    ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling")
    ErrIntOverflowGenerated   = fmt.Errorf("proto: integer overflow")
)
var DefaultFramer = defaultFramer{}

DefaultFramer is valid for any stream that can read objects serially without any separation in the stream.

var DefaultStringConversions = []interface{}{
    Convert_Slice_string_To_string,
    Convert_Slice_string_To_int,
    Convert_Slice_string_To_bool,
    Convert_Slice_string_To_int64,
}

DefaultStringConversions are helpers for converting []string and string to real values.

func CheckCodec Uses

func CheckCodec(c Codec, internalType Object, externalTypes ...unversioned.GroupVersionKind) error

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 Convert_Slice_string_To_bool Uses

func Convert_Slice_string_To_bool(input *[]string, out *bool, s conversion.Scope) error

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_int Uses

func Convert_Slice_string_To_int(input *[]string, out *int, s conversion.Scope) error

func Convert_Slice_string_To_int64 Uses

func Convert_Slice_string_To_int64(input *[]string, out *int64, s conversion.Scope) error

func Convert_Slice_string_To_string Uses

func Convert_Slice_string_To_string(input *[]string, out *string, s conversion.Scope) error

func Convert_runtime_Object_To_runtime_RawExtension Uses

func Convert_runtime_Object_To_runtime_RawExtension(in *Object, out *RawExtension, s conversion.Scope) error

func Convert_runtime_RawExtension_To_runtime_Object Uses

func Convert_runtime_RawExtension_To_runtime_Object(in *RawExtension, out *Object, s conversion.Scope) error

func DecodeInto Uses

func DecodeInto(d Decoder, data []byte, into Object) error

DecodeInto performs a Decode into the provided object.

func DecodeList Uses

func DecodeList(objects []Object, decoders ...Decoder) []error

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 DeepCopy_runtime_RawExtension Uses

func DeepCopy_runtime_RawExtension(in RawExtension, out *RawExtension, c *conversion.Cloner) error

func DeepCopy_runtime_Scheme Uses

func DeepCopy_runtime_Scheme(in Scheme, out *Scheme, c *conversion.Cloner) error

func DeepCopy_runtime_SerializerInfo Uses

func DeepCopy_runtime_SerializerInfo(in SerializerInfo, out *SerializerInfo, c *conversion.Cloner) error

func DeepCopy_runtime_StreamSerializerInfo Uses

func DeepCopy_runtime_StreamSerializerInfo(in StreamSerializerInfo, out *StreamSerializerInfo, c *conversion.Cloner) error

func DefaultEmbeddedConversions Uses

func DefaultEmbeddedConversions() []interface{}

func Encode Uses

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 Uses

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 Uses

func EncodeOrDie(e Encoder, obj Object) string

EncodeOrDie is a version of Encode which will panic instead of returning an error. For tests.

func Field Uses

func Field(v reflect.Value, fieldName string, dest interface{}) error

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 FieldPtr Uses

func FieldPtr(v reflect.Value, fieldName string, dest interface{}) error

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 Uses

func IsMissingKind(err error) bool

IsMissingKind returns true if the error indicates that the provided object is missing a 'Kind' field.

func IsMissingVersion Uses

func IsMissingVersion(err error) bool

func IsNotRegisteredError Uses

func IsNotRegisteredError(err error) bool

IsNotRegisteredError returns true if the error indicates the provided object or input data is not registered.

func JSONKeyMapper Uses

func JSONKeyMapper(key string, sourceTag, destTag reflect.StructTag) (string, string)

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 NewEncodableList Uses

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 NewMissingKindErr Uses

func NewMissingKindErr(data string) error

func NewMissingVersionErr Uses

func NewMissingVersionErr(data string) error

IsMissingVersion returns true if the error indicates that the provided object is missing a 'Versioj' field.

func NewNotRegisteredErr Uses

func NewNotRegisteredErr(gvk unversioned.GroupVersionKind, t reflect.Type) error

NewNotRegisteredErr is exposed for testing.

func ParseDocumentationFrom Uses

func ParseDocumentationFrom(src string) []KubeTypes

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 SetField Uses

func SetField(src interface{}, v reflect.Value, fieldName string) error

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 SetZeroValue Uses

func SetZeroValue(objPtr Object) error

SetZeroValue would set the object of objPtr to zero value of its type.

func VerifySwaggerDocsExist Uses

func VerifySwaggerDocsExist(kubeTypes []KubeTypes, w io.Writer) (int, error)

VerifySwaggerDocsExist writes in a io.Writer a list of structs and fields that are missing of documentation.

func WriteSwaggerDocFunc Uses

func WriteSwaggerDocFunc(kubeTypes []KubeTypes, w io.Writer) error

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

type Codec Uses

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.

func NewCodec Uses

func NewCodec(e Encoder, d Decoder) Codec

NewCodec creates a Codec from an Encoder and Decoder.

type Decoder Uses

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 Encoder Uses

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 Uses

type FieldLabelConversionFunc func(label, value string) (internalLabel, internalValue string, err error)

Function to convert a field selector to internal representation.

type Framer Uses

type Framer interface {
    NewFrameReader(r io.ReadCloser) io.ReadCloser
    NewFrameWriter(w io.Writer) io.Writer
}

Framer is a factory for creating readers and writers that obey a particular framing pattern.

type KubeTypes Uses

type KubeTypes []Pair

KubeTypes is an array to represent all available types in a parsed file. [0] is for the type itself

type MultiObjectTyper Uses

type MultiObjectTyper []ObjectTyper

MultiObjectTyper returns the types of objects across multiple schemes in order.

func (MultiObjectTyper) IsUnversioned Uses

func (m MultiObjectTyper) IsUnversioned(obj Object) (bool, bool)

func (MultiObjectTyper) ObjectKind Uses

func (m MultiObjectTyper) ObjectKind(obj Object) (gvk unversioned.GroupVersionKind, err error)

func (MultiObjectTyper) ObjectKinds Uses

func (m MultiObjectTyper) ObjectKinds(obj Object) (gvks []unversioned.GroupVersionKind, err error)

func (MultiObjectTyper) Recognizes Uses

func (m MultiObjectTyper) Recognizes(gvk unversioned.GroupVersionKind) bool

type NegotiatedSerializer Uses

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
}

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 NoopDecoder Uses

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 Uses

func (n NoopDecoder) Decode(data []byte, gvk *unversioned.GroupVersionKind, into Object) (Object, *unversioned.GroupVersionKind, error)

type NoopEncoder Uses

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 Uses

func (n NoopEncoder) EncodeToStream(obj Object, w io.Writer, overrides ...unversioned.GroupVersion) error

type Object Uses

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 Decode Uses

func Decode(d Decoder, data []byte) (Object, error)

Decode is a convenience wrapper for decoding data into an Object.

func NewEncodable Uses

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 UseOrCreateObject Uses

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 Uses

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)
}

ObjectConvertor converts an object to a different version.

func UnsafeObjectConvertor Uses

func UnsafeObjectConvertor(scheme *Scheme) ObjectConvertor

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.

type ObjectCopier Uses

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 Uses

type ObjectCreater interface {
    New(kind unversioned.GroupVersionKind) (out Object, err error)
}

ObjectCreater contains methods for instantiating an object by kind and version.

type ObjectTyper Uses

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 Uses

type ObjectVersioner interface {
    ConvertToVersion(in Object, outVersion unversioned.GroupVersion) (out Object, err error)
}

type Pair Uses

type Pair struct {
    Name, Doc string
}

Pair of strings. We keed the name of fields and the doc

type ParameterCodec Uses

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 Uses

func NewParameterCodec(scheme *Scheme) ParameterCodec

NewParameterCodec creates a ParameterCodec capable of transforming url values into versioned objects and back.

type ProtobufMarshaller Uses

type ProtobufMarshaller interface {
    MarshalTo(data []byte) (int, error)
}

type RawExtension Uses

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:"-"`
}

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) Marshal Uses

func (m *RawExtension) Marshal() (data []byte, err error)

func (RawExtension) MarshalJSON Uses

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) MarshalTo Uses

func (m *RawExtension) MarshalTo(data []byte) (int, error)

func (*RawExtension) ProtoMessage Uses

func (*RawExtension) ProtoMessage()

func (*RawExtension) Reset Uses

func (m *RawExtension) Reset()

func (*RawExtension) Size Uses

func (m *RawExtension) Size() (n int)

func (*RawExtension) String Uses

func (m *RawExtension) String() string

func (*RawExtension) Unmarshal Uses

func (m *RawExtension) Unmarshal(data []byte) error

func (*RawExtension) UnmarshalJSON Uses

func (re *RawExtension) UnmarshalJSON(in []byte) error

type ResourceVersioner Uses

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 Uses

type Scheme struct {
    // contains filtered or unexported fields
}

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.

func NewScheme Uses

func NewScheme() *Scheme

NewScheme creates a new Scheme. This scheme is pluggable by default.

func (*Scheme) AddConversionFuncs Uses

func (s *Scheme) AddConversionFuncs(conversionFuncs ...interface{}) error

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 (*Scheme) AddDeepCopyFuncs Uses

func (s *Scheme) AddDeepCopyFuncs(deepCopyFuncs ...interface{}) error

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 Uses

func (s *Scheme) AddDefaultingFuncs(defaultingFuncs ...interface{}) error

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 (*Scheme) AddFieldLabelConversionFunc Uses

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 Uses

func (s *Scheme) AddGeneratedConversionFuncs(conversionFuncs ...interface{}) error

Similar to AddConversionFuncs, but registers conversion functions that were automatically generated.

func (*Scheme) AddGeneratedDeepCopyFuncs Uses

func (s *Scheme) AddGeneratedDeepCopyFuncs(deepCopyFuncs ...interface{}) error

Similar to AddDeepCopyFuncs, but registers deep-copy functions that were automatically generated.

func (*Scheme) AddGenericConversionFunc Uses

func (s *Scheme) AddGenericConversionFunc(fn conversion.GenericConversionFunc)

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 (*Scheme) AddIgnoredConversionType Uses

func (s *Scheme) AddIgnoredConversionType(from, to interface{}) error

AddIgnoredConversionType identifies a pair of types that should be skipped by conversion (because the data inside them is explicitly dropped during conversion).

func (*Scheme) AddKnownTypeWithName Uses

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. Version may not be empty - use the APIVersionInternal constant if you have a type that does not have a formal version.

func (*Scheme) AddKnownTypes Uses

func (s *Scheme) AddKnownTypes(gv unversioned.GroupVersion, types ...Object)

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 (*Scheme) AddStructFieldConversion Uses

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 Uses

func (s *Scheme) AddUnversionedTypes(version 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 this method at that point.

func (*Scheme) Convert Uses

func (s *Scheme) Convert(in, out interface{}) error

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 (*Scheme) ConvertFieldLabel Uses

func (s *Scheme) ConvertFieldLabel(version, kind, label, value string) (string, string, error)

Converts the given field label and value for an kind field selector from versioned representation to an unversioned one.

func (*Scheme) ConvertToVersion Uses

func (s *Scheme) ConvertToVersion(in Object, outVersion unversioned.GroupVersion) (Object, error)

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) Converter Uses

func (s *Scheme) Converter() *conversion.Converter

Converter allows access to the converter for the scheme

func (*Scheme) Copy Uses

func (s *Scheme) Copy(src Object) (Object, error)

Copy does a deep copy of an API object.

func (*Scheme) DeepCopy Uses

func (s *Scheme) DeepCopy(src interface{}) (interface{}, error)

Performs a deep copy of the given object.

func (*Scheme) IsUnversioned Uses

func (s *Scheme) IsUnversioned(obj Object) (bool, bool)

func (*Scheme) KnownTypes Uses

func (s *Scheme) KnownTypes(gv unversioned.GroupVersion) map[string]reflect.Type

KnownTypes returns the types known for the given version.

func (*Scheme) Log Uses

func (s *Scheme) Log(l conversion.DebugLogger)

Log sets a logger on the scheme. For test purposes only

func (*Scheme) New Uses

func (s *Scheme) New(kind unversioned.GroupVersionKind) (Object, error)

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 (*Scheme) ObjectKind Uses

func (s *Scheme) ObjectKind(obj Object) (unversioned.GroupVersionKind, error)

ObjectKind returns the group,version,kind of the go object, or an error if it's not a pointer or is unregistered.

func (*Scheme) ObjectKinds Uses

func (s *Scheme) ObjectKinds(obj Object) ([]unversioned.GroupVersionKind, error)

ObjectKinds returns all possible group,version,kind of the go object, or an error if it's not a pointer or is unregistered.

func (*Scheme) Recognizes Uses

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) RegisterInputDefaults Uses

func (s *Scheme) RegisterInputDefaults(in interface{}, fn conversion.FieldMappingFunc, defaultFlags conversion.FieldMatchingFlags) error

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 (*Scheme) UnsafeConvertToVersion Uses

func (s *Scheme) UnsafeConvertToVersion(in Object, outVersion unversioned.GroupVersion) (Object, error)

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.

type SelfLinker Uses

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 Uses

type Serializer interface {
    Encoder
    Decoder
}

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.

func NewBase64Serializer Uses

func NewBase64Serializer(s Serializer) Serializer

type SerializerInfo Uses

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
}

SerializerInfo contains information about a specific serialization format

type StorageSerializer Uses

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
}

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 StreamSerializerInfo Uses

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
}

StreamSerializerInfo contains information about a specific stream serialization format

type TypeMeta Uses

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"`
}

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 Uses

func (obj *TypeMeta) GroupVersionKind() unversioned.GroupVersionKind

GroupVersionKind satisfies the ObjectKind interface for all objects that embed TypeMeta

func (*TypeMeta) Marshal Uses

func (m *TypeMeta) Marshal() (data []byte, err error)

func (*TypeMeta) MarshalTo Uses

func (m *TypeMeta) MarshalTo(data []byte) (int, error)

func (*TypeMeta) ProtoMessage Uses

func (*TypeMeta) ProtoMessage()

func (*TypeMeta) Reset Uses

func (m *TypeMeta) Reset()

func (*TypeMeta) SetGroupVersionKind Uses

func (obj *TypeMeta) SetGroupVersionKind(gvk unversioned.GroupVersionKind)

SetGroupVersionKind satisfies the ObjectKind interface for all objects that embed TypeMeta

func (*TypeMeta) Size Uses

func (m *TypeMeta) Size() (n int)

func (*TypeMeta) String Uses

func (m *TypeMeta) String() string

func (*TypeMeta) Unmarshal Uses

func (m *TypeMeta) Unmarshal(data []byte) error

type Typer Uses

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 Uses

func ObjectTyperToTyper(typer ObjectTyper) Typer

ObjectTyperToTyper casts the old typer interface to the new typer interface

type Unknown Uses

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"`
}

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 Uses

func (obj *Unknown) GetObjectKind() unversioned.ObjectKind

func (*Unknown) Marshal Uses

func (m *Unknown) Marshal() (data []byte, err error)

func (Unknown) MarshalJSON Uses

func (re Unknown) 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 (*Unknown) MarshalTo Uses

func (m *Unknown) MarshalTo(data []byte) (int, error)

func (*Unknown) NestedMarshalTo Uses

func (m *Unknown) NestedMarshalTo(data []byte, b ProtobufMarshaller, size uint64) (int, error)

NestedMarshalTo allows a caller to avoid extra allocations during serialization of an Unknown that will contain an object that implements ProtobufMarshaller.

func (*Unknown) ProtoMessage Uses

func (*Unknown) ProtoMessage()

func (*Unknown) Reset Uses

func (m *Unknown) Reset()

func (*Unknown) Size Uses

func (m *Unknown) Size() (n int)

func (*Unknown) String Uses

func (m *Unknown) String() string

func (*Unknown) Unmarshal Uses

func (m *Unknown) Unmarshal(data []byte) error

func (*Unknown) UnmarshalJSON Uses

func (re *Unknown) UnmarshalJSON(in []byte) error

type Unstructured Uses

type Unstructured struct {
    // 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) GetAPIVersion Uses

func (u *Unstructured) GetAPIVersion() string

func (*Unstructured) GetAnnotations Uses

func (u *Unstructured) GetAnnotations() map[string]string

func (*Unstructured) GetCreationTimestamp Uses

func (u *Unstructured) GetCreationTimestamp() unversioned.Time

func (*Unstructured) GetDeletionTimestamp Uses

func (u *Unstructured) GetDeletionTimestamp() *unversioned.Time

func (*Unstructured) GetGenerateName Uses

func (u *Unstructured) GetGenerateName() string

func (*Unstructured) GetKind Uses

func (u *Unstructured) GetKind() string

func (*Unstructured) GetLabels Uses

func (u *Unstructured) GetLabels() map[string]string

func (*Unstructured) GetName Uses

func (u *Unstructured) GetName() string

func (*Unstructured) GetNamespace Uses

func (u *Unstructured) GetNamespace() string

func (*Unstructured) GetObjectKind Uses

func (obj *Unstructured) GetObjectKind() unversioned.ObjectKind

func (*Unstructured) GetOwnerReferences Uses

func (u *Unstructured) GetOwnerReferences() []metatypes.OwnerReference

func (*Unstructured) GetResourceVersion Uses

func (u *Unstructured) GetResourceVersion() string
func (u *Unstructured) GetSelfLink() string

func (*Unstructured) GetUID Uses

func (u *Unstructured) GetUID() types.UID

func (*Unstructured) GroupVersionKind Uses

func (u *Unstructured) GroupVersionKind() unversioned.GroupVersionKind

func (*Unstructured) SetAPIVersion Uses

func (u *Unstructured) SetAPIVersion(version string)

func (*Unstructured) SetAnnotations Uses

func (u *Unstructured) SetAnnotations(annotations map[string]string)

func (*Unstructured) SetCreationTimestamp Uses

func (u *Unstructured) SetCreationTimestamp(timestamp unversioned.Time)

func (*Unstructured) SetDeletionTimestamp Uses

func (u *Unstructured) SetDeletionTimestamp(timestamp *unversioned.Time)

func (*Unstructured) SetGenerateName Uses

func (u *Unstructured) SetGenerateName(name string)

func (*Unstructured) SetGroupVersionKind Uses

func (u *Unstructured) SetGroupVersionKind(gvk unversioned.GroupVersionKind)

func (*Unstructured) SetKind Uses

func (u *Unstructured) SetKind(kind string)

func (*Unstructured) SetLabels Uses

func (u *Unstructured) SetLabels(labels map[string]string)

func (*Unstructured) SetName Uses

func (u *Unstructured) SetName(name string)

func (*Unstructured) SetNamespace Uses

func (u *Unstructured) SetNamespace(namespace string)

func (*Unstructured) SetOwnerReferences Uses

func (u *Unstructured) SetOwnerReferences(references []metatypes.OwnerReference)

func (*Unstructured) SetResourceVersion Uses

func (u *Unstructured) SetResourceVersion(version string)
func (u *Unstructured) SetSelfLink(selfLink string)

func (*Unstructured) SetUID Uses

func (u *Unstructured) SetUID(uid types.UID)

type UnstructuredList Uses

type UnstructuredList struct {
    Object map[string]interface{}

    // Items is a list of unstructured objects.
    Items []*Unstructured `json:"items"`
}

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.

func (*UnstructuredList) GetAPIVersion Uses

func (u *UnstructuredList) GetAPIVersion() string

func (*UnstructuredList) GetKind Uses

func (u *UnstructuredList) GetKind() string

func (*UnstructuredList) GetObjectKind Uses

func (obj *UnstructuredList) GetObjectKind() unversioned.ObjectKind

func (*UnstructuredList) GetResourceVersion Uses

func (u *UnstructuredList) GetResourceVersion() string
func (u *UnstructuredList) GetSelfLink() string

func (*UnstructuredList) GroupVersionKind Uses

func (u *UnstructuredList) GroupVersionKind() unversioned.GroupVersionKind

func (*UnstructuredList) SetAPIVersion Uses

func (u *UnstructuredList) SetAPIVersion(version string)

func (*UnstructuredList) SetGroupVersionKind Uses

func (u *UnstructuredList) SetGroupVersionKind(gvk unversioned.GroupVersionKind)

func (*UnstructuredList) SetKind Uses

func (u *UnstructuredList) SetKind(kind string)

func (*UnstructuredList) SetResourceVersion Uses

func (u *UnstructuredList) SetResourceVersion(version string)
func (u *UnstructuredList) SetSelfLink(selfLink string)

type VersionedObjects Uses

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
}

VersionedObjects is used by Decoders to give callers a way to access all versions of an object during the decoding process.

func (*VersionedObjects) First Uses

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 Uses

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 Uses

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).

Directories

PathSynopsis
serializer
serializer/json
serializer/protobufPackage protobuf provides a Kubernetes serializer for the protobuf format.
serializer/recognizer
serializer/streamingPackage streaming implements encoder and decoder for streams of runtime.Objects over io.Writer/Readers.
serializer/versioning
serializer/yaml

Package runtime imports 24 packages (graph). Updated 2017-04-15. Refresh now. Tools for package owners. This is a quick bug-fix fork (has fewer than three commits, and only during the week it was created).