apiserver

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAppNotInitialized is returned if the app.App has not been initialized
	ErrAppNotInitialized = errors.New("app not initialized")
	// ErrAppAlreadyInitialized is returned if the app.App has already been initialized and cannot be initialized again
	ErrAppAlreadyInitialized = errors.New("app already initialized")
)

Functions

func CovertURLValuesToResourceCallOptions

func CovertURLValuesToResourceCallOptions(in *url.Values, out *ResourceCallOptions, s conversion.Scope) error

CovertURLValuesToResourceCallOptions reads from the input *url.Values and assigns fields in the out *ResourceCallOptions

func GetCommonOpenAPIDefinitions

func GetCommonOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition

GetCommonOpenAPIDefinitions returns a map of the kubernetes common OpenAPI definitions copied from https://raw.githubusercontent.com/kubernetes/sample-apiserver/refs/heads/master/pkg/generated/openapi/zz_generated.openapi.go TODO: can we automate this and use the kube-codegen tooling to make this function?

func GetResourceCallOptionsOpenAPIDefinition

func GetResourceCallOptionsOpenAPIDefinition() map[string]common.OpenAPIDefinition

func NewDefaultAppInstaller

func NewDefaultAppInstaller(appProvider app.Provider, appConfig app.Config, resolver GoTypeResolver) (*defaultInstaller, error)

NewDefaultAppInstaller creates a new AppInstaller with default behavior for an app.Provider and app.Config.

func NewDefaultScheme

func NewDefaultScheme() *runtime.Scheme

Types

type AppInstaller

type AppInstaller interface {
	// AddToScheme registers all the kinds provided by the App to the runtime.Scheme.
	// Other functionality which relies on a runtime.Scheme may use the last scheme provided in AddToScheme for this purpose.
	AddToScheme(scheme *runtime.Scheme) error
	// GetOpenAPIDefinitions gets a map of OpenAPI definitions for use with kubernetes OpenAPI
	GetOpenAPIDefinitions(callback common.ReferenceCallback) map[string]common.OpenAPIDefinition
	// InstallAPIs installs the API endpoints to an API server
	InstallAPIs(server GenericAPIServer, optsGetter genericregistry.RESTOptionsGetter) error
	// AdmissionPlugin returns an admission.Factory to use for the Admission Plugin.
	// If the App does not provide admission control, it should return nil
	AdmissionPlugin() admission.Factory
	// InitializeApp initializes the underlying App for the AppInstaller using the provided kube config.
	// This should only be called once, if the App is already initialized the method should return ErrAppAlreadyInitialized.
	// App initialization should only be done once the final kube config is ready, as it cannot be changed after initialization.
	InitializeApp(clientrest.Config) error
	// App returns the underlying App, if initialized, or ErrAppNotInitialized if not.
	// Callers which depend on the App should account for the App not yet being initialized and do lazy loading or delayed retries.
	App() (app.App, error)
	// GroupVersions returns the list of all GroupVersions supported by this AppInstaller
	GroupVersions() []schema.GroupVersion
	// ManifestData returns the App's ManifestData
	ManifestData() *app.ManifestData
}

AppInstaller represents an App which can be installed on a kubernetes API server. It provides all the methods needed to configure and install an App onto an API server.

type Config

type Config struct {
	Generic *genericapiserver.RecommendedConfig
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(installers []AppInstaller) (*Config, error)

NewConfig returns a new Config for the provided installers

func NewConfigWithScheme

func NewConfigWithScheme(installers []AppInstaller, scheme *runtime.Scheme, codecs serializer.CodecFactory) (*Config, error)

NewConfigWithScheme creates a new Config with a provided runtime.Scheme and serializer.CodecFactory. This can be used for more fine-grained control of the scheme.

func (*Config) NewServer

func (*Config) UpdateOpenAPIConfig

func (c *Config) UpdateOpenAPIConfig()

type CustomRoute

type CustomRoute struct {
	Path    string
	Handler func(context.Context, app.CustomRouteResponseWriter, *app.CustomRouteRequest) error
}

type CustomRouteResponseResolver

type CustomRouteResponseResolver func(kind, ver, routePath, method string) (any, bool)

CustomRouteResponseResolver resolves the kind, version, path, and method into a go type which is returned from that custom route call. kind may be empty for resource routes. group is not provided as a CustomRouteResponseResolver function is expected to exist on a per-group basis.

type EmptyObject added in v0.46.0

type EmptyObject struct{}

type GenericAPIServer

type GenericAPIServer interface {
	// InstallAPIGroup installs the provided APIGroupInfo onto the API Server
	InstallAPIGroup(apiGroupInfo *genericapiserver.APIGroupInfo) error
	// RegisteredWebServices returns a list of pointers to currently-installed restful.WebService instances
	RegisteredWebServices() []*restful.WebService
}

GenericAPIServer describes a generic API server which can have an API Group installed onto it

type GoTypeResolver added in v0.42.0

type GoTypeResolver interface {
	// KindToGoType resolves a kind and version into a resource.Kind instance.
	// group is not provided as a KindToGoType function is expected to exist on a per-group basis.
	//nolint:revive
	KindToGoType(kind, version string) (goType resource.Kind, exists bool)
	// CustomRouteReturnGoType resolves the kind, version, path, and method into a go type which is returned
	// from that custom route call. kind may be empty for resource routes.
	// group is not provided as a CustomRouteReturnGoType function is expected to exist on a per-group basis.
	//nolint:revive
	CustomRouteReturnGoType(kind, version, path, verb string) (goType any, exists bool)
	// CustomRouteQueryGoType resolves the kind, version, path, and method into a go type which is returned
	// used for the query parameters of the route.
	// group is not provided as a CustomRouteQueryGoType function is expected to exist on a per-group basis.
	//nolint:revive
	CustomRouteQueryGoType(kind, version, path, verb string) (goType runtime.Object, exists bool)
	// CustomRouteRequestBodyGoType resolves the kind, version, path, and method into a go type which is
	// the accepted body type for the request.
	// group is not provided as a CustomRouteRequestBodyGoType function is expected to exist on a per-group basis.
	//nolint:revive
	CustomRouteRequestBodyGoType(kind, version, path, verb string) (goType any, exists bool)
}

GoTypeResolver is an interface which describes an object which catalogs the relationship between different aspects of an app and its go types which need to be used by the API server.

type KindAndManifestKind

type KindAndManifestKind struct {
	Kind         resource.Kind
	ManifestKind app.ManifestVersionKind
}

type KubernetesGenericAPIServer added in v0.46.0

type KubernetesGenericAPIServer struct {
	*genericapiserver.GenericAPIServer
}

KubernetesGenericAPIServer implements GenericAPIServer for a kubernetes *server.GenericAPIServer

func NewKubernetesGenericAPIServer added in v0.46.0

func NewKubernetesGenericAPIServer(apiserver *genericapiserver.GenericAPIServer) *KubernetesGenericAPIServer

NewKubernetesGenericAPIServer creates a new KubernetesGenericAPIServer wrapping the provided *server.GenericAPIServer

func (*KubernetesGenericAPIServer) RegisteredWebServices added in v0.46.0

func (k *KubernetesGenericAPIServer) RegisteredWebServices() []*restful.WebService

RegisteredWebServices returns the result of the underlying apiserver's Handler.GoRestfulContainer.RegisteredWebServices(), or nil if either Handler or Handler.GoRestfulContainer is nil

type ManagedKindResolver

type ManagedKindResolver func(kind, ver string) (resource.Kind, bool)

ManagedKindResolver resolves a kind and version into a resource.Kind instance. group is not provided as a ManagedKindResolver function is expected to exist on a per-group basis.

type Options

type Options struct {
	RecommendedOptions *genericoptions.RecommendedOptions
	// contains filtered or unexported fields
}

func NewOptions

func NewOptions(installers []AppInstaller) *Options

func (*Options) AddFlags

func (o *Options) AddFlags(fs *pflag.FlagSet)

func (*Options) ApplyTo

func (o *Options) ApplyTo(cfg *Config) error

func (*Options) Config

func (o *Options) Config() (*Config, error)

Config creates a config

func (*Options) Validate

func (o *Options) Validate() error

type ResourceCallOptions

type ResourceCallOptions struct {
	metav1.TypeMeta

	// Path is the URL path to use for the current proxy request
	Path string
}

func (*ResourceCallOptions) DeepCopy

func (in *ResourceCallOptions) DeepCopy() *ResourceCallOptions

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceCallOptions.

func (*ResourceCallOptions) DeepCopyInto

func (in *ResourceCallOptions) DeepCopyInto(out *ResourceCallOptions)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*ResourceCallOptions) DeepCopyObject

func (in *ResourceCallOptions) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type StatusREST added in v0.40.2

type StatusREST struct {
	Store *genericregistry.Store
}

StatusREST implements the REST endpoint for changing the status of a resource.

func (*StatusREST) Destroy added in v0.40.2

func (*StatusREST) Destroy()

Destroy cleans up resources on shutdown.

func (*StatusREST) Get added in v0.40.2

func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error)

Get retrieves the object from the storage. It is required to support Patch.

func (*StatusREST) GetResetFields added in v0.40.2

func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set

GetResetFields implements rest.ResetFieldsStrategy

func (*StatusREST) New added in v0.40.2

func (r *StatusREST) New() runtime.Object

New creates a new runtime.Object.

func (*StatusREST) Update added in v0.40.2

func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, _ bool, options *metav1.UpdateOptions) (runtime.Object, bool, error)

Update alters the status subset of an object.

type SubresourceConnector

type SubresourceConnector struct {
	Route CustomRoute
	Kind  resource.Kind
	// Methods is a map of uppercase HTTP methods (ex. GET, PUT) to their response types
	Methods map[string]SubresourceConnectorResponseObject
}

func (*SubresourceConnector) Connect

func (*SubresourceConnector) ConnectMethods

func (r *SubresourceConnector) ConnectMethods() []string

func (*SubresourceConnector) Destroy

func (*SubresourceConnector) Destroy()

func (*SubresourceConnector) New

func (*SubresourceConnector) NewConnectOptions

func (*SubresourceConnector) NewConnectOptions() (runtime.Object, bool, string)

func (*SubresourceConnector) ProducesMIMETypes

func (r *SubresourceConnector) ProducesMIMETypes(verb string) []string

func (*SubresourceConnector) ProducesObject

func (r *SubresourceConnector) ProducesObject(verb string) any

type SubresourceConnectorResponseObject

type SubresourceConnectorResponseObject struct {
	Object    any
	MIMETypes []string
}

type SubresourceREST added in v0.46.0

type SubresourceREST struct {
	Store *genericregistry.Store
}

SubresourceREST implements the REST endpoint for changing the status of a resource.

func (*SubresourceREST) Destroy added in v0.46.0

func (*SubresourceREST) Destroy()

Destroy cleans up resources on shutdown.

func (*SubresourceREST) Get added in v0.46.0

func (r *SubresourceREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error)

Get retrieves the object from the storage. It is required to support Patch.

func (*SubresourceREST) GetResetFields added in v0.46.0

func (r *SubresourceREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set

GetResetFields implements rest.ResetFieldsStrategy

func (*SubresourceREST) New added in v0.46.0

func (r *SubresourceREST) New() runtime.Object

New creates a new runtime.Object.

func (*SubresourceREST) Update added in v0.46.0

func (r *SubresourceREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, _ bool, options *metav1.UpdateOptions) (runtime.Object, bool, error)

Update alters the status subset of an object.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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