type Scheme … type FieldLabelConversionFunc … // NewScheme creates a new Scheme. This scheme is pluggable by default. func NewScheme() *Scheme { … } // Converter allows access to the converter for the scheme func (s *Scheme) Converter() *conversion.Converter { … } // AddUnversionedTypes registers the provided types as "unversioned", which means that they follow special rules. // Whenever an object of this type is serialized, it is serialized with the provided group version and is not // converted. Thus unversioned objects are expected to remain backwards compatible forever, as if they were in an // API group and version that would never be updated. // // TODO: there is discussion about removing unversioned and replacing it with objects that are manifest into // every version with particular schemas. Resolve this method at that point. func (s *Scheme) AddUnversionedTypes(version schema.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 (s *Scheme) AddKnownTypes(gv schema.GroupVersion, types ...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 (s *Scheme) AddKnownTypeWithName(gvk schema.GroupVersionKind, obj Object) { … } // KnownTypes returns the types known for the given version. func (s *Scheme) KnownTypes(gv schema.GroupVersion) map[string]reflect.Type { … } // VersionsForGroupKind returns the versions that a particular GroupKind can be converted to within the given group. // A GroupKind might be converted to a different group. That information is available in EquivalentResourceMapper. func (s *Scheme) VersionsForGroupKind(gk schema.GroupKind) []schema.GroupVersion { … } // AllKnownTypes returns the all known types. func (s *Scheme) AllKnownTypes() map[schema.GroupVersionKind]reflect.Type { … } // ObjectKinds returns all possible group,version,kind of the go object, true if the // object is considered unversioned, or an error if it's not a pointer or is unregistered. func (s *Scheme) ObjectKinds(obj Object) ([]schema.GroupVersionKind, bool, error) { … } // Recognizes returns true if the scheme is able to handle the provided group,version,kind // of an object. func (s *Scheme) Recognizes(gvk schema.GroupVersionKind) bool { … } func (s *Scheme) IsUnversioned(obj Object) (bool, bool) { … } // New returns a new API object of the given version and name, or an error if it hasn't // been registered. The version and kind fields must be specified. func (s *Scheme) New(kind schema.GroupVersionKind) (Object, error) { … } // AddIgnoredConversionType identifies a pair of types that should be skipped by // conversion (because the data inside them is explicitly dropped during // conversion). func (s *Scheme) AddIgnoredConversionType(from, to interface{ … } // AddConversionFunc registers a function that converts between a and b by passing objects of those // types to the provided function. The function *must* accept objects of a and b - this machinery will not enforce // any other guarantee. func (s *Scheme) AddConversionFunc(a, b interface{ … } // AddGeneratedConversionFunc registers a function that converts between a and b by passing objects of those // types to the provided function. The function *must* accept objects of a and b - this machinery will not enforce // any other guarantee. func (s *Scheme) AddGeneratedConversionFunc(a, b interface{ … } // AddFieldLabelConversionFunc adds a conversion function to convert field selectors // of the given kind from the given version to internal version representation. func (s *Scheme) AddFieldLabelConversionFunc(gvk schema.GroupVersionKind, conversionFunc FieldLabelConversionFunc) error { … } // AddTypeDefaultingFunc registers a function that is passed a pointer to an // object and can default fields on the object. These functions will be invoked // when Default() is called. The function will never be called unless the // defaulted object matches srcType. If this function is invoked twice with the // same srcType, the fn passed to the later call will be used instead. func (s *Scheme) AddTypeDefaultingFunc(srcType Object, fn func(interface{ … } // Default sets defaults on the provided Object. func (s *Scheme) Default(src Object) { … } // 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). The // context interface is passed to the convertor. Convert also supports Unstructured // types and will convert them intelligently. func (s *Scheme) Convert(in, out interface{ … } // ConvertFieldLabel alters the given field label and value for an kind field selector from // versioned representation to an unversioned one or returns an error. func (s *Scheme) ConvertFieldLabel(gvk schema.GroupVersionKind, label, value string) (string, string, 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. Passes target down to the conversion methods as the Context on the scope. func (s *Scheme) ConvertToVersion(in Object, target GroupVersioner) (Object, error) { … } // UnsafeConvertToVersion will convert in to the provided target if such a conversion is possible, // but does not guarantee the output object does not share fields with the input object. It attempts to be as // efficient as possible when doing conversion. func (s *Scheme) UnsafeConvertToVersion(in Object, target GroupVersioner) (Object, error) { … } // convertToVersion handles conversion with an optional copy. func (s *Scheme) convertToVersion(copy bool, in Object, target GroupVersioner) (Object, error) { … } // unstructuredToTyped attempts to transform an unstructured object to a typed // object if possible. It will return an error if conversion is not possible, or the versioned // Go form of the object. Note that this conversion will lose fields. func (s *Scheme) unstructuredToTyped(in Unstructured) (Object, error) { … } // generateConvertMeta constructs the meta value we pass to Convert. func (s *Scheme) generateConvertMeta(in interface{ … } // copyAndSetTargetKind performs a conditional copy before returning the object, or an error if copy was not successful. func copyAndSetTargetKind(copy bool, obj Object, kind schema.GroupVersionKind) (Object, error) { … } // setTargetKind sets the kind on an object, taking into account whether the target kind is the internal version. func setTargetKind(obj Object, kind schema.GroupVersionKind) { … } // SetVersionPriority allows specifying a precise order of priority. All specified versions must be in the same group, // and the specified order overwrites any previously specified order for this group func (s *Scheme) SetVersionPriority(versions ...schema.GroupVersion) error { … } // PrioritizedVersionsForGroup returns versions for a single group in priority order func (s *Scheme) PrioritizedVersionsForGroup(group string) []schema.GroupVersion { … } // PrioritizedVersionsAllGroups returns all known versions in their priority order. Groups are random, but // versions for a single group are prioritized func (s *Scheme) PrioritizedVersionsAllGroups() []schema.GroupVersion { … } // PreferredVersionAllGroups returns the most preferred version for every group. // group ordering is random. func (s *Scheme) PreferredVersionAllGroups() []schema.GroupVersion { … } // IsGroupRegistered returns true if types for the group have been registered with the scheme func (s *Scheme) IsGroupRegistered(group string) bool { … } // IsVersionRegistered returns true if types for the version have been registered with the scheme func (s *Scheme) IsVersionRegistered(version schema.GroupVersion) bool { … } func (s *Scheme) addObservedVersion(version schema.GroupVersion) { … } func (s *Scheme) Name() string { … } var internalPackages …