builder

package
v0.0.0-...-7077a58 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOpenAPIDefinitions

func GetOpenAPIDefinitions(builders []APIGroupBuilder) common.GetOpenAPIDefinitions

This should eventually live in grafana-app-sdk

func GetPathOperations

func GetPathOperations(path *spec3.Path) []*spec3.Operation

func InstallAPIs

func InstallAPIs(
	scheme *runtime.Scheme,
	codecs serializer.CodecFactory,
	server *genericapiserver.GenericAPIServer,
	optsGetter generic.RESTOptionsGetter,
	builders []APIGroupBuilder,
	dualWrite bool,
) error

func SetupConfig

func SetupConfig(
	scheme *runtime.Scheme,
	serverConfig *genericapiserver.RecommendedConfig,
	builders []APIGroupBuilder,
	buildTimestamp int64,
	buildVersion string,
	buildCommit string,
	buildBranch string,
) error

Types

type APIGroupBuilder

type APIGroupBuilder interface {
	// Get the main group name
	GetGroupVersion() schema.GroupVersion

	// Add the kinds to the server scheme
	InstallSchema(scheme *runtime.Scheme) error

	// Build the group+version behavior
	GetAPIGroupInfo(
		scheme *runtime.Scheme,
		codecs serializer.CodecFactory,
		optsGetter generic.RESTOptionsGetter,
		dualWrite bool,
	) (*genericapiserver.APIGroupInfo, error)

	// Get OpenAPI definitions
	GetOpenAPIDefinitions() common.GetOpenAPIDefinitions

	// Get the API routes for each version
	GetAPIRoutes() *APIRoutes

	// Optionally add an authorization hook
	// Standard namespace checking will happen before this is called, specifically
	// the namespace must matches an org|stack that the user belongs to
	GetAuthorizer() authorizer.Authorizer
}

TODO: this (or something like it) belongs in grafana-app-sdk, but lets keep it here while we iterate on a few simple examples

type APIRegistrar

type APIRegistrar interface {
	RegisterAPI(builder APIGroupBuilder)
}

type APIRouteHandler

type APIRouteHandler struct {
	Path    string           // added to the appropriate level
	Spec    *spec3.PathProps // Exposed in the open api service discovery
	Handler http.HandlerFunc // when Level = resource, the resource will be available in context
}

This is used to implement dynamic sub-resources like pods/x/logs

type APIRoutes

type APIRoutes struct {
	// Root handlers are registered directly after the apiVersion identifier
	Root []APIRouteHandler

	// Namespace handlers are mounted under the namespace
	Namespace []APIRouteHandler
}

APIRoutes define explicit HTTP handlers in an apiserver TBD: is this actually necessary -- there may be more k8s native options for this

type OpenAPIPostProcessor

type OpenAPIPostProcessor interface {
	PostProcessOpenAPI(*spec3.OpenAPI) (*spec3.OpenAPI, error)
}

Builders that implement OpenAPIPostProcessor are given a chance to modify the schema directly

Jump to

Keyboard shortcuts

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