Documentation ¶
Overview ¶
Package k8smeta implements metadata discovery and normalization of K8s resources.
Index ¶
- Variables
- type ResourceDiscovery
- type ResourceOpts
- type Resources
- func (r *Resources) APIResource(gvk schema.GroupVersionKind) *metav1.APIResource
- func (r *Resources) CanonicalGroupVersionKind(gvk schema.GroupVersionKind) (schema.GroupVersionKind, error)
- func (r *Resources) CanonicalResources() map[schema.GroupKind]metav1.APIResource
- func (r *Resources) Dump(println func(...interface{}))
- type SchemaDiscovery
- type ServerSchema
- type Validator
Constants ¶
This section is empty.
Variables ¶
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.
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.