apiserverk8s.io/apiserver/pkg/cel/openapi/resolver Index | Files

package resolver

import "k8s.io/apiserver/pkg/cel/openapi/resolver"

Index

Variables

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

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

Functions

func PopulateRefs

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

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

Source Files

combined.go definitions.go discovery.go refs.go resolver.go

Version
v0.33.0 (latest)
Published
Apr 23, 2025
Platform
linux/amd64
Imports
10 packages
Last checked
1 hour ago

Tools for package owners.