k8smeta

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package k8smeta implements metadata discovery and normalization of K8s resources.

Index

Constants

This section is empty.

Variables

View Source
var ErrSchemaNotFound = errors.New("schema not found") // returned when a validation schema is not found

ErrSchemaNotFound is returned when a schema could not be found.

Functions

This section is empty.

Types

type ResourceDiscovery

type ResourceDiscovery interface {
	ServerGroups() (*metav1.APIGroupList, error)
	ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error)
}

ResourceDiscovery is the minimal interface required to gather information on server resources.

type ResourceOpts

type ResourceOpts struct {
	RequiredVerbs []string             // verbs that a resource must support in order to be loaded. Defaults to create/delete/get/list
	WarnFn        func(...interface{}) // a function that can print warnings in the resource discovery.
}

ResourceOpts is optional information for loading resources.

type Resources

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

Resources provides resource information for a K8s cluster.

func NewResources

func NewResources(disco ResourceDiscovery, opts ResourceOpts) (*Resources, error)

NewResources loads server resources using the supplied discovery interface.

func (*Resources) APIResource

func (r *Resources) APIResource(gvk schema.GroupVersionKind) *metav1.APIResource

APIResource returns the API resource for the supplied group version kind or nil if no resource could be found.

func (*Resources) CanonicalGroupVersionKind

func (r *Resources) CanonicalGroupVersionKind(gvk schema.GroupVersionKind) (schema.GroupVersionKind, error)

CanonicalGroupVersionKind provides the preferred/ canonical group version kind for the supplied input. It takes aliases into account (e.g. extensions/Deployment same as apps/Deployment) for doing so.

func (*Resources) CanonicalResources

func (r *Resources) CanonicalResources() map[schema.GroupKind]metav1.APIResource

CanonicalResources returns a map of API resources keyed by group-kind.

func (*Resources) Dump

func (r *Resources) Dump(println func(...interface{}))

Dump dumps resource mappings using the supplied println function.

type SchemaDiscovery

type SchemaDiscovery interface {
	OpenAPISchema() (*openapi_v2.Document, error)
}

SchemaDiscovery is the minimal interface needed to discover the server schema.

type ServerSchema

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

ServerSchema is a representation of the resource schema of a Kubernetes server.

func NewServerSchema

func NewServerSchema(disco SchemaDiscovery) *ServerSchema

NewServerSchema returns a server schema that can supply validators for the given discovery interface.

func (*ServerSchema) OpenAPIResources

func (ss *ServerSchema) OpenAPIResources() (openapi.Resources, error)

OpenAPIResources returns the OpenAPI resources for the server.

func (*ServerSchema) ValidatorFor

func (ss *ServerSchema) ValidatorFor(ctx context.Context, gvk schema.GroupVersionKind) (Validator, error)

ValidatorFor returns a validator for the supplied GroupVersionKind.

type Validator

type Validator interface {
	// Validate validates the supplied object and returns a slice of validation errors.
	Validate(obj *unstructured.Unstructured) []error
}

Validator validates documents of a specific type.

Jump to

Keyboard shortcuts

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