resolver

package
v0.29.9 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 10 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSchemaNotFound = fmt.Errorf("schema not found")

ErrSchemaNotFound is wrapped and returned if the schema cannot be located by the resolver.

Functions

func PopulateRefs added in v0.29.0

func PopulateRefs(schemaOf func(ref string) (*spec.Schema, bool), rootRef string) (*spec.Schema, error)

PopulateRefs recursively replaces Refs in the schema with the referred one. schemaOf is the callback to find the corresponding schema by the ref. This function will not mutate the original schema. If the schema needs to be mutated, a copy will be returned, otherwise it returns the original schema.

Types

type ClientDiscoveryResolver

type ClientDiscoveryResolver struct {
	Discovery discovery.DiscoveryInterface
}

ClientDiscoveryResolver uses client-go discovery to resolve schemas at run time.

func (*ClientDiscoveryResolver) ResolveSchema

func (r *ClientDiscoveryResolver) ResolveSchema(gvk schema.GroupVersionKind) (*spec.Schema, error)

type DefinitionsSchemaResolver

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

DefinitionsSchemaResolver resolves the schema of a built-in type by looking up the OpenAPI definitions.

func NewDefinitionsSchemaResolver

func NewDefinitionsSchemaResolver(getDefinitions common.GetOpenAPIDefinitions, schemes ...*runtime.Scheme) *DefinitionsSchemaResolver

NewDefinitionsSchemaResolver creates a new DefinitionsSchemaResolver. An example working setup: getDefinitions = "k8s.io/kubernetes/pkg/generated/openapi".GetOpenAPIDefinitions scheme = "k8s.io/client-go/kubernetes/scheme".Scheme

func (*DefinitionsSchemaResolver) Combine added in v0.29.0

Combine combines the DefinitionsSchemaResolver with a secondary schema resolver. The resulting schema resolver uses the DefinitionsSchemaResolver for a GVK that DefinitionsSchemaResolver knows, and the secondary otherwise.

func (*DefinitionsSchemaResolver) ResolveSchema

type SchemaResolver

type SchemaResolver interface {
	// ResolveSchema takes a GroupVersionKind (GVK) and returns the OpenAPI schema
	// identified by the GVK.
	// The function returns a non-nil error if the schema cannot be found or fail
	// to resolve. The returned error wraps ErrSchemaNotFound if the resolution is
	// attempted but the corresponding schema cannot be found.
	ResolveSchema(gvk schema.GroupVersionKind) (*spec.Schema, error)
}

SchemaResolver finds the OpenAPI schema for the given GroupVersionKind. This interface uses the type defined by k8s.io/kube-openapi

Jump to

Keyboard shortcuts

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