resource

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToScheme

func AddToScheme(objs ...Object) func(s *runtime.Scheme) error

AddToScheme returns a function to add the Objects to the scheme.

AddToScheme will register the objects returned by New and NewList under the GroupVersion for each object. AddToScheme will also register the objects under the "__internal" group version for each object that returns true for IsStorageVersion. AddToScheme will register the defaulting function if it implements the Defaulter inteface.

Types

type ArbitrarySubResource

type ArbitrarySubResource interface {
	SubResource
}

ArbitrarySubResource defines required methods for extending a new custom subresource.

type Filter added in v0.0.2

type Filter interface {
	Filter(ctx context.Context, obj runtime.Object) bool
}

type InternalObject added in v0.0.2

type InternalObject interface {
	Object

	// GetSingularName return the singular name of the resource
	GetSingularName() string

	// GetShortNames retruns the short names for the resource
	GetShortNames() []string

	// GetCategories returns the categories of the resource
	GetCategories() []string

	// NamespaceScoped returns if the resource is namespaced or not
	NamespaceScoped() bool

	// TableConvertor return the table convertor interface
	TableConvertor() func(gr schema.GroupResource) rest.TableConvertor

	// FieldLabelConversion returns the field conversion function
	FieldLabelConversion() runtime.FieldLabelConversionFunc

	// FieldSelector returns a function that is used to filter resources based on field selectors
	FieldSelector() func(ctx context.Context, fieldSelector fields.Selector) (Filter, error)

	// PrepareForCreate prepares the resource for creation.
	// e.g. sets status empty status
	PrepareForCreate(ctx context.Context, obj runtime.Object)

	// ValidateCreate return field errors on specific validation of the resource upon create
	ValidateCreate(ctx context.Context, obj runtime.Object) field.ErrorList

	// PrepareForUpdate prepares the resource for update.
	// e.g. sets status empty status
	PrepareForUpdate(ctx context.Context, obj, old runtime.Object)

	// ValidateUpdate return field errors on specific validation of the resource upon update
	ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList

	// Is Equal compares the specification of the various objects
	IsEqual(ctx context.Context, obj, old runtime.Object) bool
}

type MultiVersionObject

type MultiVersionObject interface {
	RegisterConversions() func(s *runtime.Scheme) error
}

MultiVersionObject should be implemented if the resource is not storage version and has multiple versions serving at the server.

type Object

type Object interface {
	// Object allows the apiserver libraries to operate on the Object
	runtime.Object

	// GetObjectMeta returns the object meta reference.
	GetObjectMeta() *metav1.ObjectMeta

	// Scoper is used to qualify the resource as either namespace scoped or non-namespace scoped.
	rest.Scoper

	// New returns a new instance of the resource -- e.g. &v1.Deployment{}
	New() runtime.Object

	// NewList return a new list instance of the resource -- e.g. &v1.DeploymentList{}
	NewList() runtime.Object

	// GetGroupVersionResource returns the GroupVersionResource for this resource.  The resource should
	// be the all lowercase and pluralized kind.s
	GetGroupVersionResource() schema.GroupVersionResource

	// IsStorageVersion returns true if the object is also the internal version -- i.e. is the type defined
	// for the API group an alias to this object.
	// If false, the resource is expected to implement MultiVersionObject interface.
	IsStorageVersion() bool
}

Object must be implemented by all resources served by the apiserver.

type ObjectList

type ObjectList interface {
	// Object allows the apiserver libraries to operate on the Object
	runtime.Object

	// GetListMeta returns the list meta reference.
	GetListMeta() *metav1.ListMeta
}

ObjectList must be implemented by all resources' list object.

type ObjectWithArbitrarySubResource

type ObjectWithArbitrarySubResource interface {
	Object
	GetArbitrarySubResources() []ArbitrarySubResource
}

ObjectWithArbitrarySubResource defines an interface for plumbing arbitrary sub-resources for a resource.

type ObjectWithScaleSubResource

type ObjectWithScaleSubResource interface {
	Object
	SetScale(scaleSubResource *autoscalingv1.Scale)
	GetScale() (scaleSubResource *autoscalingv1.Scale)
}

ObjectWithScaleSubResource defines an interface for getting and setting the scale sub-resource for a resource.

type ObjectWithStatusSubResource

type ObjectWithStatusSubResource interface {
	InternalObject
	// GetStatus returns the status subresource
	GetStatus() (statusSubResource StatusSubResource)

	// IsEqual validates if status subresources are equal
	IsStatusEqual(ctx context.Context, obj, old runtime.Object) bool

	// PrepareForUpdate prepares the resource for update.
	// e.g. sets status empty status
	PrepareForStatusUpdate(ctx context.Context, obj, old runtime.Object)

	// ValidateStatusUpdate return field errors on specific validation of the resource upon update
	ValidateStatusUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList
}

ObjectWithStatusSubResource defines an interface for getting and setting the status sub-resource for a resource.

type StatusSubResource

type StatusSubResource interface {
	SubResource
	// CopyTo copies the content of the status subresource to a parent resource.
	CopyTo(parent ObjectWithStatusSubResource)
}

StatusSubResource defines required methods for implementing a status subresource.

type SubResource

type SubResource interface {
	SubResourceName() string
}

SubResource defines interface for registering arbitrary subresource to the parent resource.

Directories

Path Synopsis
Package resourcerest defines interfaces for resource REST implementations.
Package resourcerest defines interfaces for resource REST implementations.
Package resourcestrategy defines interfaces for customizing how resources are converted and stored.
Package resourcestrategy defines interfaces for customizing how resources are converted and stored.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL