Documentation
¶
Overview ¶
Package validate implements offline schema validation of Crossplane resources.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsErrBaseLayerNotFound ¶
IsErrBaseLayerNotFound checks if the error is of type BaseLayerNotFoundError.
func NewBaseLayerNotFoundError ¶
NewBaseLayerNotFoundError returns a new BaseLayerNotFoundError error.
Types ¶
type BaseLayerNotFoundError ¶
type BaseLayerNotFoundError struct {
// contains filtered or unexported fields
}
BaseLayerNotFoundError is returned when the base layer of the image could not be found.
func (*BaseLayerNotFoundError) Error ¶
func (e *BaseLayerNotFoundError) Error() string
Error implements the error interface.
type Cache ¶
type Cache interface {
Store(schemas [][]byte, path string) error
Flush() error
Init() error
Load(image string) ([]*unstructured.Unstructured, error)
Exists(image string) (string, error)
}
Cache defines an interface for caching schemas.
type Cmd ¶
type Cmd struct {
// Arguments.
Extensions string `arg:"" help:"Extension sources as a comma-separated list of files, directories, or '-' for standard input."`
Resources string `arg:"" help:"Resource sources as a comma-separated list of files, directories, or '-' for standard input."`
// Flags. Keep them in alphabetical order.
CacheDir string `` /* 159-byte string literal not displayed */
CleanCache bool `help:"Clean the cache directory before downloading package schemas."`
CrossplaneImage string `` /* 137-byte string literal not displayed */
ErrorOnMissingSchemas bool `default:"false" help:"Return non zero exit code if missing schemas."`
// rendererFlag.Decode rejects unknown formats, which is what Kong's
// "enum" tag would normally enforce — but enum doesn't apply to
// MapperValue-backed fields. The help text is the user-facing list
// of valid values.
Output rendererFlag `` /* 307-byte string literal not displayed */
SkipSuccessResults bool `help:"Skip printing success results."`
UpdateCache bool `` /* 297-byte string literal not displayed */
// contains filtered or unexported fields
}
Cmd arguments and flags for render subcommand.
func (*Cmd) AfterApply ¶
AfterApply implements kong.AfterApply. The renderer is already resolved by Kong's MapperValue plumbing on Cmd.Output by the time this runs, so AfterApply only sets the filesystem.
type Fetcher ¶
type Fetcher struct{}
Fetcher implements the ImageFetcher interface.
func (*Fetcher) FetchBaseLayer ¶
FetchBaseLayer fetches the base layer of the image which contains the 'package.yaml' file.
type ImageFetcher ¶
type ImageFetcher interface {
FetchBaseLayer(image string) (string, *conregv1.Layer, error)
FetchImage(image string) (string, []conregv1.Layer, error)
}
ImageFetcher defines an interface for fetching images.
type LocalCache ¶
type LocalCache struct {
// contains filtered or unexported fields
}
LocalCache implements the Cache interface.
func (*LocalCache) Exists ¶
func (c *LocalCache) Exists(image string) (string, error)
Exists checks if the cache contains the image and returns the path if it doesn't exist. If the image contains a semantic version constraint, the returned cache-path will include it on cache miss, as it can not be resolved by the cache.
func (*LocalCache) Init ¶
func (c *LocalCache) Init() error
Init creates the cache directory if it doesn't exist.
func (*LocalCache) Load ¶
func (c *LocalCache) Load(image string) ([]*unstructured.Unstructured, error)
Load loads schemas from the cache directory. image should be a validated image name with the format: <registry>/<image>:<tag>. <tag> can be a constraint, in which case the latest version of the schema that satisfies this constraint is loaded from the cache.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager defines a Manager for preparing Crossplane packages for validation.
func NewManager ¶
NewManager returns a new Manager.
func (*Manager) CRDs ¶
func (m *Manager) CRDs() []*extv1.CustomResourceDefinition
CRDs returns the collected CRDs.
func (*Manager) CacheAndLoad ¶
CacheAndLoad finds and caches dependencies and loads them as CRDs.
func (*Manager) PrepExtensions ¶
func (m *Manager) PrepExtensions(extensions []*unstructured.Unstructured) error
PrepExtensions converts the unstructured XRDs/CRDs to CRDs and extract package images to add as a dependency.
type Option ¶
type Option func(*Manager)
Option defines an option for the Manager.
func WithCrossplaneImage ¶
WithCrossplaneImage sets the Crossplane image to use for fetching CRDs.
func WithUpdateCache ¶
WithUpdateCache forces re-downloading packages with ranged semver constraints even when a matching version is already cached.