app

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: 26 Imported by: 30

Documentation

Index

Constants

View Source
const (
	OpenAPIExtensionPrefix                   = "x-grafana-app"
	OpenAPIExtensionUsesKubernetesObjectMeta = OpenAPIExtensionPrefix + "-uses-kubernetes-object-metadata"
	OpenAPIExtensionUsesKubernetesListMeta   = OpenAPIExtensionPrefix + "-uses-kubernetes-list-metadata"
)
View Source
const (
	ManifestLocationFilePath          = ManifestLocationType("filepath")
	ManifestLocationAPIServerResource = ManifestLocationType("apiserver")
	ManifestLocationEmbedded          = ManifestLocationType("embedded")
)

Variables

View Source
var (
	// ErrNotImplemented is an error that indicates that an App method is not implemented by the App implementation,
	// or the App method is not implemented for the provided Kind.
	// Typically, the App's ManifestData should indicate this as well.
	ErrNotImplemented = errors.New("not implemented")

	ErrCustomRouteNotFound = errors.New("custom route not found")
)
View Source
var (
	ErrOtherRunStopped = errors.New("run stopped by another run call")
)
View Source
var ErrRunnerExitTimeout = fmt.Errorf("exit wait time exceeded waiting for Runners to complete")
View Source
var RunnableCollectorDefaultErrorHandler = func(ctx context.Context, err error) bool {
	logging.FromContext(ctx).Error("runner exited with error", "error", err)
	return true
}

Functions

func GetCRDOpenAPISchema added in v0.43.2

func GetCRDOpenAPISchema(components *openapi3.Components, schemaName string) (*openapi3.Schema, error)

GetCRDOpenAPISchema takes a Components object and a schema name, resolves all $ref references and handles recursive references by converting them to objects with x-kubernetes-preserve-unknown-fields set to true. It returns the resolved schema and any error encountered.

Types

type AdmissionCapabilities

type AdmissionCapabilities struct {
	// Validation contains the validation capability details. If nil, the kind does not have a validation capability.
	Validation *ValidationCapability `json:"validation,omitempty" yaml:"validation,omitempty"`
	// Mutation contains the mutation capability details. If nil, the kind does not have a mutation capability.
	Mutation *MutationCapability `json:"mutation,omitempty" yaml:"mutation,omitempty"`
}

AdmissionCapabilities is the collection of admission capabilities of a kind

func (AdmissionCapabilities) SupportsAnyMutation

func (c AdmissionCapabilities) SupportsAnyMutation() bool

SupportsAnyMutation returns true if the list of operations for mutation is not empty. This is a convenience method to avoid having to make several nil and length checks.

func (AdmissionCapabilities) SupportsAnyValidation

func (c AdmissionCapabilities) SupportsAnyValidation() bool

SupportsAnyValidation returns true if the list of operations for validation is not empty. This is a convenience method to avoid having to make several nil and length checks.

type AdmissionOperation

type AdmissionOperation string
const (
	AdmissionOperationAny     AdmissionOperation = "*"
	AdmissionOperationCreate  AdmissionOperation = "CREATE"
	AdmissionOperationUpdate  AdmissionOperation = "UPDATE"
	AdmissionOperationDelete  AdmissionOperation = "DELETE"
	AdmissionOperationConnect AdmissionOperation = "CONNECT"
)

type AdmissionRequest added in v0.22.0

type AdmissionRequest resource.AdmissionRequest

type App added in v0.22.0

type App interface {
	metrics.Provider
	health.Checker
	// Validate validates the incoming request, and returns an error if validation fails
	Validate(ctx context.Context, request *AdmissionRequest) error
	// Mutate runs mutation on the incoming request, responding with a MutatingResponse on success, or an error on failure
	Mutate(ctx context.Context, request *AdmissionRequest) (*MutatingResponse, error)
	// Convert converts the object based on the ConversionRequest, returning a RawObject which MUST contain
	// the converted bytes and encoding (Raw and Encoding respectively), and MAY contain the Object representation of those bytes.
	// It returns an error if the conversion fails, or if the functionality is not supported by the app.
	Convert(ctx context.Context, req ConversionRequest) (*RawObject, error)
	// CallCustomRoute handles the call to a custom route, and the caller provides a CustomRouteResponseWriter for the App
	// to write the status code and response object(s) to.
	// If the route doesn't exist, the implementer MAY return ErrCustomRouteNotFound to signal to the runner,
	// or may choose to write a not found status code and custom body.
	// It returns an error if the functionality is not supported by the app.
	CallCustomRoute(ctx context.Context, responseWriter CustomRouteResponseWriter, request *CustomRouteRequest) error
	// ManagedKinds returns a slice of Kinds which are managed by this App.
	// If there are multiple versions of a Kind, each one SHOULD be returned by this method,
	// as app runners may depend on having access to all kinds.
	ManagedKinds() []resource.Kind
	// Runner returns a Runnable with an app main loop. Any business logic that is not/can not be exposed
	// via other App interfaces should be contained within this method.
	// Runnable MAY be nil, in which case, the app has no main loop business logic.
	Runner() Runnable
}

App represents an app platform application logical structure. An App is typically run with a wrapper, such as simple.NewStandaloneOperator, which will present a runtime layer (such as kubernetes webhooks in the case of an operator), and translate those into calls to the App. The wrapper is typically also responsible for lifecycle management and running the Runnable provided by Runner(). Pre-built implementations of App exist in the simple package, but any type which implements App should be capable of being run by an app wrapper.

type Config added in v0.22.0

type Config struct {
	// KubeConfig is a kubernetes rest.Config used to communicate with the API server where the App's Kinds are stored.
	KubeConfig rest.Config
	// ManifestData is the fetched ManifestData the runner is using for determining app kinds and capabilities.
	ManifestData ManifestData
	// SpecificConfig is app-specific config (as opposed to generic config)
	SpecificConfig SpecificConfig
}

Config is the app configuration used in a Provider for instantiating a new App. It contains kubernetes configuration for communicating with an API server, the App's ManifestData as fetched by the runner, and additional arbitrary configuration details that may be app-specific.

type ConversionRequest added in v0.22.0

type ConversionRequest struct {
	SourceGVK schema.GroupVersionKind
	TargetGVK schema.GroupVersionKind
	Raw       RawObject
}

ConversionRequest is a request to convert a Kind from one version to another

type CustomRouteRequest added in v0.39.0

type CustomRouteRequest struct {
	// ResourceIdentifier is the full identifier of the resource.
	// If the request is not a subresource route request, ResourceIdentifier will contain only group,
	// version, and namespace (if applicable).
	// ResourceIdentifier will contain all information the runner is able to provide.
	// In practical terms, this often means that either Kind or Plural will be included, but both may not be present.
	// For a non-subresource route, only Group, Version, and optionally Namespace (for namespaced routes) will be included.
	ResourceIdentifier resource.FullIdentifier
	// Path contains path information past the identifier information.
	// For a subresource route, this is the subresource (for example, `bar` in the case of `test.grafana.app/v1/foos/foo/bar`).
	// In the case of a non-subresource route, this will be the path section past the namespace (or version if the route is not namespaced).
	Path string
	// URL is the full URL object of the request, which can be used to extract query parameters, or host/protocol for redirects
	URL *url.URL
	// Method is the HTTP request method
	Method string
	// Headers contains the HTTP headers of the original request. Runners MAY remove or sanitize some headers.
	Headers http.Header
	// Body contains the payload of the request. Body may contain incomplete data if the request is streamed and not yet complete.
	// Body data is considered complete once a call to Read results in zero bytes read and an error such as io.EOF
	// (see godoc for io.Reader). A consumer SHOULD call Body.Close() when they are finished consuming the body,
	// especially in the case of incomplete data, to signal to the runner that the handler has finished consuming the payload.
	Body io.ReadCloser
}

CustomRouteRequest is a request to a custom subresource or resource route

type CustomRouteResponseWriter added in v0.39.0

type CustomRouteResponseWriter interface {
	http.ResponseWriter
}

CustomRouteResponseWriter is a ResponseWriter for CustomRouteResponse objects. It mirrors http.ResponseWriter, but exact implementation is runner-dependent.

type DynamicMultiRunner added in v0.28.0

type DynamicMultiRunner struct {
	// ErrorHandler is called if one of the Runners returns an error. If the function call returns true,
	// the context will be canceled and all other Runners will also be prompted to exit.
	// If ErrorHandler is nil, RunnableCollectorDefaultErrorHandler is used.
	ErrorHandler func(context.Context, error) bool
	// ExitWait is how long to wait for Runners to exit after ErrorHandler returns true or the context is canceled
	// before stopping execution and returning a timeout error instead of exiting gracefully.
	// If ExitWait is nil, Run execution will always block until all Runners have exited.
	ExitWait *time.Duration
	// contains filtered or unexported fields
}

DynamicMultiRunner is a MultiRunner that allows for adding and removing Runnable instances after Run is called. Only one concurrent Run call is allowed at a time.

func NewDynamicMultiRunner added in v0.28.0

func NewDynamicMultiRunner() *DynamicMultiRunner

NewDynamicMultiRunner creates a new properly-initialized DynamicMultiRunner.

func (*DynamicMultiRunner) AddRunnable added in v0.28.0

func (d *DynamicMultiRunner) AddRunnable(runnable Runnable)

AddRunnable adds the provided Runnable to the list of runners which gets run by Run. If the DynamicMultiRunner is already running, the Runnable will be started immediately.

func (*DynamicMultiRunner) HealthChecks added in v0.36.0

func (d *DynamicMultiRunner) HealthChecks() []health.Check

HealthChecks implements health.Checker

func (*DynamicMultiRunner) PrometheusCollectors added in v0.28.0

func (d *DynamicMultiRunner) PrometheusCollectors() []prometheus.Collector

PrometheusCollectors implements metrics.Provider by returning prometheus collectors for all Runners that also implement metrics.Provider.

func (*DynamicMultiRunner) RemoveRunnable added in v0.28.0

func (d *DynamicMultiRunner) RemoveRunnable(runnable Runnable)

RemoveRunnable removes the provided Runnable from the list of runners, provided that it exists in the current list. If the DynamicMultiRunner is already running, the context provided to the Runnable's Run method will be canceled.

func (*DynamicMultiRunner) Run added in v0.28.0

Run runs all the current runners, and will dynamically run any runners added with AddRunnable.

type KindPermission added in v0.27.0

type KindPermission struct {
	Group    string                 `json:"group" yaml:"group"`
	Resource string                 `json:"resource" yaml:"resource"`
	Actions  []KindPermissionAction `json:"actions,omitempty" yaml:"actions,omitempty"`
}

type KindPermissionAction added in v0.27.0

type KindPermissionAction string

type Manifest

type Manifest struct {
	// ManifestData must be present if Location.Type == "embedded"
	ManifestData *ManifestData
	// Location indicates the place where the ManifestData should be loaded from
	Location ManifestLocation
}

Manifest is a type which represents the Location and Data in an App Manifest.

func NewAPIServerManifest

func NewAPIServerManifest(resourceName string) Manifest

NewAPIServerManifest returns a Manifest which points to a resource in an API server to load the ManifestData from

func NewEmbeddedManifest

func NewEmbeddedManifest(manifestData ManifestData) Manifest

NewEmbeddedManifest returns a Manifest which has the ManifestData embedded in it

func NewOnDiskManifest

func NewOnDiskManifest(path string) Manifest

NewOnDiskManifest returns a Manifest which points to a path on-disk to load ManifestData from

type ManifestData

type ManifestData struct {
	// AppName is the unique identifier for the App
	AppName string `json:"appName" yaml:"appName"`
	// Group is the group used for all kinds maintained by this app.
	// This is usually "<AppName>.ext.grafana.com"
	Group string `json:"group" yaml:"group"`
	// Versions is a list of versions supported by this App
	Versions []ManifestVersion `json:"versions" yaml:"versions"`
	// PreferredVersion is the preferred version for API use. If empty, it will use the latest from versions.
	// For CRDs, this also dictates which version is used for storage.
	PreferredVersion string `json:"preferredVersion" yaml:"preferredVersion"`
	// Permissions is the extra permissions for non-owned kinds this app needs to operate its backend.
	// It may be nil if no extra permissions are required.
	ExtraPermissions *Permissions `json:"extraPermissions,omitempty" yaml:"extraPermissions,omitempty"`
	// Operator has information about the operator being run for the app, if there is one.
	// When present, it can indicate to the API server the URL and paths for webhooks, if applicable.
	// This is only required if you run your app as an operator and any of your kinds support webhooks for validation,
	// mutation, or conversion.
	Operator *ManifestOperatorInfo `json:"operator,omitempty" yaml:"operator,omitempty"`
}

ManifestData is the data in a Manifest, representing the Kinds and Capabilities of an App. NOTE: ManifestData is still experimental and subject to change

func (*ManifestData) IsEmpty added in v0.40.0

func (m *ManifestData) IsEmpty() bool

func (*ManifestData) Kinds

func (m *ManifestData) Kinds() []ManifestKind

Kinds returns a list of ManifestKinds parsed from Versions, for compatibility with kind-centric usage Deprecated: this exists to support current workflows, and should not be used for new ones.

func (*ManifestData) Validate added in v0.40.0

func (m *ManifestData) Validate() error

Validate validates the ManifestData to ensure that the kind data across all Versions is consistent

type ManifestKind

type ManifestKind struct {
	// Kind is the name of the kind
	Kind string `json:"kind" yaml:"kind"`
	// Scope if the scope of the kind, typically restricted to "Namespaced" or "Cluster"
	Scope string `json:"scope" yaml:"scope"`
	// Plural is the plural of the kind
	Plural string `json:"plural" yaml:"plural"`
	// Versions is the set of versions for the kind. This list should be ordered as a series of progressively later versions.
	Versions []ManifestKindVersion `json:"versions" yaml:"versions"`
	// Conversion is true if the app has a conversion capability for this kind
	Conversion bool `json:"conversion" yaml:"conversion"`
}

ManifestKind is the manifest for a particular kind, including its Kind, Scope, and Versions. The values for Kind, Plural, Scope, and Conversion are hoisted up from their namesakes in Versions entries Deprecated: this is used only for the deprecated method ManifestData.Kinds()

type ManifestKindVersion

type ManifestKindVersion struct {
	ManifestVersionKind `json:",inline" yaml:",inline"`
	VersionName         string `json:"versionName" yaml:"versionName"`
}

ManifestKindVersion is an extension on ManifestVersionKind that adds the version name Deprecated: this type if used only as part of the deprecated method ManifestData.Kinds()

type ManifestLocation

type ManifestLocation struct {
	Type ManifestLocationType
	// Path is the path to the manifest, based on location.
	// For "filepath", it is the path on disk. For "apiserver", it is the NamespacedName. For "embedded", it is empty.
	Path string
}

ManifestLocation contains information of where a Manifest's ManifestData can be found.

type ManifestLocationType

type ManifestLocationType string

type ManifestOperatorInfo added in v0.36.3

type ManifestOperatorInfo struct {
	URL      string                             `json:"url" yaml:"url"`
	Webhooks *ManifestOperatorWebhookProperties `json:"webhooks,omitempty" yaml:"webhooks,omitempty"`
}

ManifestOperatorInfo contains information on the app's Operator deployment (if a deployment exists). This is primarily used to specify the location of webhook endpoints for the app.

type ManifestOperatorWebhookProperties added in v0.36.3

type ManifestOperatorWebhookProperties struct {
	ConversionPath string `json:"conversionPath" yaml:"conversionPath"`
	ValidationPath string `json:"validationPath" yaml:"validationPath"`
	MutationPath   string `json:"mutationPath" yaml:"mutationPath"`
}

ManifestOperatorWebhookProperties contains information on webhook paths for an app's operator deployment.

type ManifestVersion added in v0.40.0

type ManifestVersion struct {
	// Name is the version name string, such as "v1" or "v1alpha1"
	Name string `json:"name" yaml:"name"`
	// Served dictates whether this version is served by the API server.
	// A version cannot be removed from a manifest until it is no longer served.
	Served bool `json:"served" yaml:"served"`
	// Kinds is a list of all the kinds served in this version.
	// Generally, kinds should exist in each version unless they have been deprecated (and no longer exist in a newer version)
	// or newly added (and didn't exist for older versions).
	Kinds []ManifestVersionKind `json:"kinds" yaml:"kinds"`
	// Routes is a map of path patterns to custom routes for this version.
	// Routes should not conflict with the plural name of any kinds for this version.
	Routes ManifestVersionRoutes `json:"routes,omitempty" yaml:"routes,omitempty"`
}

type ManifestVersionKind added in v0.40.0

type ManifestVersionKind struct {
	// Kind is the name of the kind. This should begin with a capital letter and be CamelCased
	Kind string `json:"kind" yaml:"kind"`
	// Plural is the plural version of `kind`. This is optional and defaults to the kind + "s" if not present.
	Plural string `json:"plural,omitempty" yaml:"plural,omitempty"`
	// Scope dictates the scope of the kind. This field must be the same for all versions of the kind.
	// Different values will result in an error or undefined behavior.
	Scope string `json:"scope" yaml:"scope"`
	// Admission is the collection of admission capabilities for this version.
	// If nil, no admission capabilities exist for the version.
	Admission *AdmissionCapabilities `json:"admission,omitempty" yaml:"admission,omitempty"`
	// Schema is the schema of this version, as an OpenAPI document.
	// This is currently an `any` type as implementation is incomplete.
	Schema *VersionSchema `json:"schema,omitempty" yaml:"schema,omitempty"`
	// SelectableFields are the set of JSON paths in the schema which can be used as field selectors
	SelectableFields []string `json:"selectableFields,omitempty" yaml:"selectableFields,omitempty"`
	// Routes is a map of path patterns to custom routes for this kind to be used as custom subresource routes.
	Routes map[string]spec3.PathProps `json:"routes,omitempty" yaml:"routes,omitempty"`
	// Conversion indicates whether this kind supports custom conversion behavior exposed by the Convert method in the App.
	// It may not prevent automatic conversion behavior between versions of the kind when set to false
	// (for example, CRDs will always support simple conversion, and this flag enables webhook conversion).
	// This field should be the same for all versions of the kind. Different values will result in an error or undefined behavior.
	Conversion bool `json:"conversion" yaml:"conversion"`

	AdditionalPrinterColumns []ManifestVersionKindAdditionalPrinterColumn `json:"additionalPrinterColumns,omitempty" yaml:"additionalPrinterColumns,omitempty"`
}

ManifestVersionKind contains details for a version of a kind in a Manifest

type ManifestVersionKindAdditionalPrinterColumn added in v0.43.2

type ManifestVersionKindAdditionalPrinterColumn struct {
	// name is a human readable name for the column.
	Name string `json:"name"`
	// type is an OpenAPI type definition for this column.
	// See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details.
	Type string `json:"type"`
	// format is an optional OpenAPI type definition for this column. The 'name' format is applied
	// to the primary identifier column to assist in clients identifying column is the resource name.
	// See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details.
	Format string `json:"format,omitempty"`
	// description is a human readable description of this column.
	Description string `json:"description,omitempty"`
	// priority is an integer defining the relative importance of this column compared to others. Lower
	// numbers are considered higher priority. Columns that may be omitted in limited space scenarios
	// should be given a priority greater than 0.
	Priority *int32 `json:"priority,omitempty"`
	// jsonPath is a simple JSON path (i.e. with array notation) which is evaluated against
	// each custom resource to produce the value for this column.
	JSONPath string `json:"jsonPath"`
}

type ManifestVersionRoutes added in v0.46.0

type ManifestVersionRoutes struct {
	Namespaced map[string]spec3.PathProps `json:"namespaced,omitempty" yaml:"namespaced,omitempty"`
	Cluster    map[string]spec3.PathProps `json:"cluster,omitempty" yaml:"cluster,omitempty"`
}

type MultiRunner added in v0.22.0

type MultiRunner struct {
	Runners []Runnable
	// ErrorHandler is called if one of the Runners returns an error. If the function call returns true,
	// the context will be canceled and all other Runners will also be prompted to exit.
	// If ErrorHandler is nil, RunnableCollectorDefaultErrorHandler is used.
	ErrorHandler func(context.Context, error) bool
	// ExitWait is how long to wait for Runners to exit after ErrorHandler returns true or the context is canceled
	// before stopping execution and returning a timeout error instead of exiting gracefully.
	// If ExitWait is nil, Run execution will always block until all Runners have exited.
	ExitWait *time.Duration
}

MultiRunner implements Runnable for running multiple Runnable instances.

func NewMultiRunner added in v0.22.0

func NewMultiRunner() *MultiRunner

NewMultiRunner creates a new MultiRunner with Runners as an empty slice and ErrorHandler set to RunnableCollectorDefaultErrorHandler

func (*MultiRunner) AddRunnable added in v0.22.0

func (m *MultiRunner) AddRunnable(runnable Runnable)

AddRunnable adds the provided Runnable to the Runners slice. If the slice is nil, it will create it.

func (*MultiRunner) HealthChecks added in v0.36.0

func (m *MultiRunner) HealthChecks() []health.Check

HealthChecks implements health.Checker

func (*MultiRunner) PrometheusCollectors added in v0.22.0

func (m *MultiRunner) PrometheusCollectors() []prometheus.Collector

PrometheusCollectors implements metrics.Provider by returning prometheus collectors for all Runners that also implement metrics.Provider.

func (*MultiRunner) Run added in v0.22.0

func (m *MultiRunner) Run(ctx context.Context) error

Run runs all Runners in separate goroutines, and calls ErrorHandler if any of them exits early with an error. If ErrorHandler returns true (or if there is no ErrorHandler), the other Runners are canceled and the error is returned.

type MutatingResponse added in v0.22.0

type MutatingResponse resource.MutatingResponse

type MutationCapability

type MutationCapability struct {
	// Operations is the list of operations that the mutation capability is used for.
	// If this list if empty or nil, this is equivalent to the app having no mutation capability.
	Operations []AdmissionOperation `json:"operations,omitempty" yaml:"operations,omitempty"`
}

MutationCapability is the details of a mutation capability for a kind's admission control

type Permissions added in v0.27.0

type Permissions struct {
	AccessKinds []KindPermission `json:"accessKinds,omitempty" yaml:"accessKinds,omitempty"`
}

type Provider added in v0.22.0

type Provider interface {
	// Manifest returns a Manifest, which may contain ManifestData or may point to a location where ManifestData can be fetched from.
	// The runner should use the ManifestData to determine app capabilities.
	Manifest() Manifest
	// SpecificConfig is any app-specific config that cannot be loaded by the runner that should be provided in NewApp
	SpecificConfig() SpecificConfig
	// NewApp creates a new App instance using the provided config, or returns an error if an App cannot be instantiated.
	NewApp(Config) (App, error)
}

Provider represents a type which can provide an app manifest, and create a new App when given a configuration. It should be used by runners to determine an app's capabilities and create an instance of the app to run.

type RawObject added in v0.22.0

type RawObject struct {
	Raw      []byte                `json:",inline"`
	Object   resource.Object       `json:"-"`
	Encoding resource.KindEncoding `json:"-"`
}

RawObject represents the raw bytes of the object and its encoding, optionally with a decoded version of the object, which may be any valid resource.Object implementation.

type Runnable added in v0.22.0

type Runnable interface {
	// Run runs the process and blocks until one of the following conditions are met:
	// * An unrecoverable error occurs, in which case it returns the error
	// * The provided context completes
	// * The process completes and does not need to run again
	Run(context.Context) error
}

Runnable represents a type which can be run until it errors or the provided channel is stopped (or receives a message)

type SingletonRunner added in v0.22.0

type SingletonRunner struct {
	Wrapped Runnable
	// StopOnAny tells the SingletonRunner to stop all Run() calls if any one of them is stopped
	StopOnAny bool
	// contains filtered or unexported fields
}

SingletonRunner runs a single Runnable but allows for multiple distinct calls to Run() which cn have independent lifecycles

func NewSingletonRunner added in v0.22.0

func NewSingletonRunner(runnable Runnable, stopOnAny bool) *SingletonRunner

func (*SingletonRunner) HealthChecks added in v0.36.0

func (s *SingletonRunner) HealthChecks() []health.Check

HealthChecks

func (*SingletonRunner) PrometheusCollectors added in v0.22.0

func (s *SingletonRunner) PrometheusCollectors() []prometheus.Collector

PrometheusCollectors implements metrics.Provider by returning prometheus collectors for the wrapped Runnable if it implements metrics.Provider.

func (*SingletonRunner) Run added in v0.22.0

func (s *SingletonRunner) Run(ctx context.Context) error

Run runs until the provided context.Context is closed, the underlying Runnable completes, or another call to Run is stopped and StopOnAny is set to true (in which case ErrOtherRunStopped is returned)

type SpecificConfig added in v0.22.0

type SpecificConfig any

SpecificConfig is app-specific configuration which can vary from app to app TODO: better type than any

type ValidationCapability

type ValidationCapability struct {
	// Operations is the list of operations that the validation capability is used for.
	// If this list if empty or nil, this is equivalent to the app having no validation capability.
	Operations []AdmissionOperation `json:"operations,omitempty" yaml:"operations,omitempty"`
}

ValidationCapability is the details of a validation capability for a kind's admission control

type VersionSchema added in v0.23.0

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

VersionSchema represents the schema of a KindVersion in a Manifest. It allows retrieval of the schema in a variety of ways, and can be unmarshaled from a CRD's version schema, an OpenAPI document for a kind, or from just the schemas component of an openAPI document. It marshals to the schemas component of an openAPI document. A Manifest VersionSchema does not contain a metadata object, as that is consistent between every app platform kind. This is modeled after kubernetes' behavior for describing a CRD schema.

func VersionSchemaFromMap added in v0.23.0

func VersionSchemaFromMap(openAPISchema map[string]any, kindName string) (*VersionSchema, error)

VersionSchemaFromMap accepts an OpenAPI-shaped map[string]any, where the contents of the map are either a full openAPI document with a components.schemas section, or just the components.schemas section of an openAPI document. The schemas must contain a schema with a name which matches the kindName provided.

func (*VersionSchema) AsCRDMap added in v0.43.2

func (v *VersionSchema) AsCRDMap(kindObjectName string) (map[string]any, error)

AsCRDMap returns the schema as a map[string]any where each key is a top-level resource (ex. 'spec', 'status') if the kindObjectName provided doesn't exist in the underlying raw openAPI schemas, or the schema's references cannot be resolved into a single object, an error will be returned.

func (*VersionSchema) AsCRDOpenAPI3 added in v0.43.2

func (v *VersionSchema) AsCRDOpenAPI3(kindObjectName string) (*openapi3.Schema, error)

AsCRDOpenAPI3 returns an openapi3.Schema instances for a CRD for the kind. References in the schema will be resolved and embedded, and recursive references will be converted into empty objects with `x-kubernetes-preserve-unknown-fields: true`. The root object for the CRD in the version components is specified by kindObjectName. If kindObjectName does not exist in the list of schemas, an error will be returned.

func (*VersionSchema) AsKubeOpenAPI added in v0.38.1

AsKubeOpenAPI converts the schema into a map of reference string to common.OpenAPIDefinition objects, suitable for use with kubernetes API server code. It uses the provided schema.GroupVersionKind and pkgPrefix for naming of the kind and for reference naming. The map output will look something like:

"<pkgPrefix>.<kind>": {...},
"<pkgPrefix>.<kind>List": {...},
"<pkgPrefix>.<kind>Spec": {...}, // ...etc. for all other resources

If you wish to exclude a field from your kind's object, ensure that the field name begins with a `#`, which will be treated as a definition. Definitions are included in the returned map as types, but are not included as fields (alongside "spec","status", etc.) in the kind object.

It will error if the underlying schema cannot be parsed as valid openAPI.

func (*VersionSchema) AsOpenAPI3 added in v0.23.0

func (v *VersionSchema) AsOpenAPI3() (*openapi3.Components, error)

AsOpenAPI3 returns an openapi3.Components instance which contains the schema elements

func (*VersionSchema) AsOpenAPI3SchemasMap added in v0.43.2

func (v *VersionSchema) AsOpenAPI3SchemasMap() map[string]any

AsOpenAPI3SchemasMap returns the schema as a map[string]any version of an openAPI components.schemas section

func (*VersionSchema) MarshalJSON added in v0.23.0

func (v *VersionSchema) MarshalJSON() ([]byte, error)

func (*VersionSchema) MarshalYAML added in v0.23.0

func (v *VersionSchema) MarshalYAML() (any, error)

func (*VersionSchema) UnmarshalJSON added in v0.23.0

func (v *VersionSchema) UnmarshalJSON(data []byte) error

func (*VersionSchema) UnmarshalYAML added in v0.23.0

func (v *VersionSchema) UnmarshalYAML(unmarshal func(any) error) error

Directories

Path Synopsis
appmanifest

Jump to

Keyboard shortcuts

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