apischema

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGetOpenAPIPaths      = errors.New("failed to get OpenAPI paths")
	ErrGetCRDGVK            = errors.New("failed to get CRD GVK")
	ErrParseGroupVersion    = errors.New("failed to parse groupVersion")
	ErrMarshalOpenAPISchema = errors.New("failed to marshal openAPI v3 runtimeSchema")
	ErrConvertOpenAPISchema = errors.New("failed to convert openAPI v3 runtimeSchema to v2")
	ErrCRDNoVersions        = errors.New("CRD has no versions defined")
	ErrMarshalGVK           = errors.New("failed to marshal GVK extension")
	ErrUnmarshalGVK         = errors.New("failed to unmarshal GVK extension")
	ErrBuildKindRegistry    = errors.New("failed to build kind registry")
)
View Source
var (
	ErrInvalidPath              = errors.New("path doesn't contain the / separator")
	ErrNotPreferred             = errors.New("path ApiGroup does not belong to the server preferred APIs")
	ErrGVKNotPreferred          = errors.New("failed to find CRD GVK in API preferred resources")
	ErrGetServerPreferred       = errors.New("failed to get server preferred resources")
	ErrFilterPreferredResources = errors.New("failed to filter server preferred resources")
	ErrGetSchemaForPath         = errors.New("failed to get schema for path")
	ErrUnmarshalSchemaForPath   = errors.New("failed to unmarshal schema for path")
)
View Source
var (
	ErrFailedToValidateConvertedJson = errors.New("failed to validate converted JSON")
	ErrUnmarshalJSON                 = errors.New("failed to unmarshal JSON")
	ErrEncodeJSON                    = errors.New("failed to encode JSON")
)

Functions

func ConvertJSON

func ConvertJSON(v3JSON []byte) ([]byte, error)

Types

type CRDResolver

type CRDResolver struct {
	discovery.DiscoveryInterface
	meta.RESTMapper
	// contains filtered or unexported fields
}

func NewCRDResolver

func NewCRDResolver(discovery discovery.DiscoveryInterface, restMapper meta.RESTMapper, log *logger.Logger) *CRDResolver

NewCRDResolver creates a new CRDResolver with proper logger setup

func (*CRDResolver) Resolve

func (*CRDResolver) ResolveApiSchema

func (cr *CRDResolver) ResolveApiSchema(crd *apiextensionsv1.CustomResourceDefinition) ([]byte, error)

type GroupKindVersions

type GroupKindVersions struct {
	*metav1.GroupKind
	Versions []string
}

type GroupVersionKind

type GroupVersionKind struct {
	Group   string `json:"group"`
	Version string `json:"version"`
	Kind    string `json:"kind"`
}

type Resolver

type Resolver interface {
	Resolve(dc discovery.DiscoveryInterface, rm meta.RESTMapper) ([]byte, error)
}

type ResolverProvider

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

func NewResolver

func NewResolver(log *logger.Logger) *ResolverProvider

func (*ResolverProvider) Resolve

type ResourceInfo

type ResourceInfo struct {
	Group     string
	Version   string
	Kind      string
	SchemaKey string
}

ResourceInfo holds information about a resource for relationship resolution

type SchemaBuilder

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

func NewSchemaBuilder

func NewSchemaBuilder(oc openapi.Client, preferredApiGroups []string, log *logger.Logger) *SchemaBuilder

func (*SchemaBuilder) Complete

func (b *SchemaBuilder) Complete() ([]byte, error)

func (*SchemaBuilder) WithApiResourceCategories

func (b *SchemaBuilder) WithApiResourceCategories(list []*metav1.APIResourceList) *SchemaBuilder

func (*SchemaBuilder) WithCRDCategories

func (*SchemaBuilder) WithPreferredVersions

func (b *SchemaBuilder) WithPreferredVersions(apiResLists []*metav1.APIResourceList) *SchemaBuilder

WithPreferredVersions populates preferred version information from API discovery

func (*SchemaBuilder) WithRelationships

func (b *SchemaBuilder) WithRelationships() *SchemaBuilder

WithRelationships adds relationship fields to schemas that have *Ref fields Uses 1-level depth control to prevent circular references and N+1 problems

func (*SchemaBuilder) WithScope

func (b *SchemaBuilder) WithScope(rm meta.RESTMapper) *SchemaBuilder

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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