builder

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: Apache-2.0 Imports: 30 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIServer = &Server{
	storageProvider: map[schema.GroupResource]*singletonProvider{},
}

APIServer builds an apiserver to server Kubernetes resources and sub resources.

Functions

This section is empty.

Types

type Command

type Command = cobra.Command

Command is an alias for cobra.Command and is used to start the apiserver.

type GenericAPIServer

type GenericAPIServer = server.GenericAPIServer

GenericAPIServer is an alias for pkgserver.GenericAPIServer

type OpenAPIDefinition

type OpenAPIDefinition = common.OpenAPIDefinition

OpenAPIDefinition is an alias for common.OpenAPIDefinition

type Server

type Server struct {
	ServerName string
	EtcdPath   string
	// contains filtered or unexported fields
}

Server builds a new apiserver for a single API group

func (*Server) Build

func (r *Server) Build(ctx context.Context) (*Command, error)

Build returns a Command used to run the apiserver

func (*Server) Execute

func (r *Server) Execute(ctx context.Context) error

Execute builds and executes the apiserver Command.

func (*Server) WithConfigFns

func (r *Server) WithConfigFns(fns ...func(config *server.RecommendedConfig) *server.RecommendedConfig) *Server

WithConfigFns sets functions to customize the RecommendedConfig

func (*Server) WithEtcdPath

func (r *Server) WithEtcdPath(etcdPath string) *Server

func (*Server) WithFlagFns

func (r *Server) WithFlagFns(fns ...func(set *pflag.FlagSet) *pflag.FlagSet) *Server

WithFlagFns sets functions to customize the flags for the compiled binary.

func (*Server) WithLocalDebugExtension

func (a *Server) WithLocalDebugExtension(ctx context.Context) *Server

WithLocalDebugExtension adds an optional local-debug mode to the apiserver so that it can be tested locally without involving a complete kubernetes cluster. A flag named "--standalone-debug-mode" will also be added the binary which forcily requires "--bind-address" to be "127.0.0.1" in order to avoid security issues.

func (*Server) WithOpenAPIDefinitions

func (r *Server) WithOpenAPIDefinitions(
	name, version string,
	defs openapicommon.GetOpenAPIDefinitions) *Server

func (*Server) WithOptionsFns

func (r *Server) WithOptionsFns(fns ...func(*ServerOptions) *ServerOptions) *Server

WithOptionsFns sets functions to customize the ServerOptions used to create the apiserver

func (*Server) WithResource

func (a *Server) WithResource(ctx context.Context, obj resource.Object) *Server

WithResource registers the resource with the apiserver.

If no versions of this GroupResource have already been registered, a new default handler will be registered. If the object implements rest.Getter, rest.Updater or rest.Creator then the provided object itself will be used as the rest handler for the resource type.

If no versions of this GroupResource have already been registered and the object does NOT implement the rest interfaces, then a new etcd backed storage will be created for the object and used as the handler. The storage will use a DefaultStrategy, which delegates functions to the object if the object implements interfaces defined in the rest package. Otherwise it will provide a default behavior.

WithResource will automatically register the "status" subresource if the object implements the resource.StatusGetSetter interface.

WithResource will automatically register version-specific defaulting for this GroupVersionResource if the object implements the resource.Defaulter interface.

WithResource automatically adds the object and its list type to the known types. If the object also declares itself as the storage version, the object and its list type will be added as storage versions to the SchemeBuilder as well. The storage version is the version accepted by the handler.

If another version of the object's GroupResource has already been registered, then the resource will use the handler already registered for that version of the GroupResource. Objects for this version will be converted to the object version which the handler accepts before the handler is invoked.

func (*Server) WithResourceAndHandler

func (r *Server) WithResourceAndHandler(ctx context.Context, obj resource.Object, sp rest.ResourceHandlerProvider) *Server

WithResourceAndHandler registers a request handler for the resource rather than the default etcd backed storage.

Note: WithResourceAndHandler should never be called after the GroupResource has already been registered with another version.

Note: WithResourceAndHandler will NOT register the "status" subresource for the resource object.

func (*Server) WithServerFns

func (r *Server) WithServerFns(fns ...func(server *GenericAPIServer) *GenericAPIServer) *Server

WithServerFns sets functions to customize the GenericAPIServer

func (*Server) WithServerName

func (r *Server) WithServerName(serverName string) *Server

func (*Server) WithoutEtcd

func (r *Server) WithoutEtcd() *Server

WithoutEtcd removes etcd related settings from apiserver.

type ServerOptions

type ServerOptions = apiserverbuilder.ServerOptions

ServerOptions is an alias for apiserverbuilder.ServerOptions

type Storage

type Storage = rest.Storage

Storage is an alias for rest.Storage. Storage implements the interfaces defined in the rest package to expose new REST endpoints for a Kubernetes resource.

Directories

Path Synopsis
resourcerest
Package resourcerest defines interfaces for resource REST implementations.
Package resourcerest defines interfaces for resource REST implementations.
resourcestrategy
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