builder

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StandardStorageProvider

func StandardStorageProvider(obj builderresource.Object, fn StoreFn, trackGeneration bool) serverapiserver.StorageProvider

StandardStorageProvider returns the same kine/etcd-backed genericregistry.Store provider that WithResourceAndStorage would install, for callers that need to wrap or share it (e.g. a main resource plus a custom subresource over one logical store).

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server builds an API server without going through apiserver-runtime's sample-apiserver command wiring.

func NewServerBuilder

func NewServerBuilder() *Server

func (*Server) Build

func (s *Server) Build() (*start.ApoxyServerOptions, error)

func (*Server) DisableAuthorization

func (s *Server) DisableAuthorization() *Server

func (*Server) WithAdditionalSchemeInstallers

func (s *Server) WithAdditionalSchemeInstallers(fns ...func(*runtime.Scheme) error) *Server

func (*Server) WithConfigFns

func (*Server) WithEvents

func (s *Server) WithEvents(store StoreFn) *Server

WithEvents serves the upstream events.k8s.io/v1 Events API from this server, backed by store (which must be persistent + watchable, e.g. kine, via the same StoreFn seam as WithResourceAndStorage). Callers get LIST/GET/WATCH/CREATE/UPDATE/DELETE and the client-go events broadcaster works against it unchanged.

Events is an upstream k8s type, not a builderresource.Object, so it can't go through WithResourceAndStorage. Everything specific to Events is baked in here -- the GroupVersionResource, the namespaced scope, the "event" singular, the eventsv1 scheme install, and the {group, __internal} storage-version alias the generic store's codec needs -- so the call site is just WithEvents(store) with no room to get those wrong.

It is a deliberate opt-in, not a server default, for two reasons:

  • The store carries no TTL, so the CALLER owns Event GC (a pruner). Serving Events does not bound their growth; defaulting it on would hand every consumer an unbounded Events table.
  • Serving Events here is a LOCAL surface: direct/loopback clients see it. It is never aggregated into a host kube-apiserver -- the host owns the built-in events.k8s.io group and an APIService cannot override it -- so a host cluster's `kubectl get events` shows the host's Events, not these. Reach these through this server's own (loopback) endpoint.

func (*Server) WithGenerationTracking

func (s *Server) WithGenerationTracking() *Server

WithGenerationTracking enables CRD-style metadata.generation handling on every resource subsequently registered with WithResourceAndStorage: PrepareForCreate sets generation=1, and PrepareForUpdate bumps it when the object's Spec field has changed (compared via apiequality.Semantic.DeepEqual). Off by default — opt-in so existing consumers (apoxy-cloud's project apiserver, etc.) keep their current behavior until they're independently audited for the change.

Resources without a Spec field are unaffected (no field to compare, no generation bump). Per-type PrepareForUpdater hooks continue to fire after the generation bump.

func (*Server) WithOpenAPIDefinitions

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

func (*Server) WithOptionsFns

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

func (*Server) WithResourceAndStorage

func (s *Server) WithResourceAndStorage(obj builderresource.Object, fn StoreFn) *Server

func (*Server) WithResourceAndStorageProvider

func (s *Server) WithResourceAndStorageProvider(obj builderresource.Object, sp serverapiserver.StorageProvider) *Server

WithResourceAndStorageProvider registers a kind in the scheme and mounts an arbitrary StorageProvider at its GVR — like WithResourceAndStorage, but the caller supplies the finished provider instead of a StoreFn, and the status subresource is NOT wired (providers that shape responses, e.g. redaction, would otherwise be bypassed by the status route's raw parent reads). Compose the provider from StandardStorageProvider to reuse the default genericregistry.Store construction.

func (*Server) WithSchemeKinds

func (s *Server) WithSchemeKinds(gv schema.GroupVersion, objs ...runtime.Object) *Server

WithSchemeKinds registers additional kinds in both the API and OpenAPI schemes — needed for custom subresource payload kinds (a WithStorage subresource whose storage News a type no resource.Object registers).

func (*Server) WithStorage

WithStorage registers a StorageProvider at an arbitrary GVR. If the Resource contains "/", it is mounted as a subresource; otherwise as a top-level resource. The returned rest.Storage's implemented rest.* interfaces drive method routing (GET/LIST/WATCH/POST/...); methods not implemented yield 405 from the generic apiserver handler.

Unlike WithResourceAndStorage, this does NOT register the kind in the API scheme. Callers wire the scheme themselves via WithAdditionalSchemeInstallers; intentional for cases where one Go type is mounted at multiple GVRs (e.g. a top-level resource shared with per-parent subresources) and the scheme registration should not be duplicated.

func (*Server) WithoutEtcd

func (s *Server) WithoutEtcd() *Server

type ServerOptions

type ServerOptions = start.ServerOptions

Jump to

Keyboard shortcuts

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