Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (29 sloc) 1.29 KB

Adding resources

Important: Read this doc first to understand how resources are added

Create a resource with custom rest

You can implement your own REST implementation instead of using the standard storage by providing the rest=KindREST parameter and providing a newKindREST(generic.RESTOptionsGetter) rest.Storage {} function to return the storage.

For more information on custom REST implementations, see the subresources doc

// +genclient=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// +resource:path=foos,rest=FooREST
// +k8s:openapi-gen=true
// Foo defines some thing
type Foo struct {
    // Your resource definition here
}

// Initialize custom REST storage
func NewFooREST(restOptionsGetter generic.RESTOptionsGetter) rest.Storage {
    // Initialize fields of custom REST implementation
}

// Your rest.Storage implementation below
// ...

Warning: NewFooREST() should not contain any non-trivial logic, besides simply initializing the fields of the struct, that represents the custom REST. See this issue for details.

You can’t perform that action at this time.