validate

package
v1.18.2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

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 added in v1.18.0

func IsErrBaseLayerNotFound(err error) bool

IsErrBaseLayerNotFound checks if the error is of type BaseLayerNotFoundError.

func NewBaseLayerNotFoundError added in v1.18.0

func NewBaseLayerNotFoundError(image string) error

NewBaseLayerNotFoundError returns a new BaseLayerNotFoundError error.

func SchemaValidation

func SchemaValidation(resources []*unstructured.Unstructured, crds []*extv1.CustomResourceDefinition, skipSuccessLogs bool, w io.Writer) error

SchemaValidation validates the resources against the given CRDs.

Types

type BaseLayerNotFoundError added in v1.18.0

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 added in v1.18.0

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() ([]*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:"Extensions source which can be a file, directory, or '-' for standard input."`
	Resources  string `arg:"" help:"Resources source which can be a file, directory, or '-' for standard input."`

	// Flags. Keep them in alphabetical order.
	CacheDir           string `` /* 164-byte string literal not displayed */
	CleanCache         bool   `help:"Clean the cache directory before downloading package schemas."`
	SkipSuccessResults bool   `help:"Skip printing success results."`
	CrossplaneImage    string `help:"Specify the Crossplane image to be used for validating the built-in schemas."`
	// contains filtered or unexported fields
}

Cmd arguments and flags for render subcommand.

func (*Cmd) AfterApply

func (c *Cmd) AfterApply() error

AfterApply implements kong.AfterApply.

func (*Cmd) Help

func (c *Cmd) Help() string

Help prints out the help for the validate command.

func (*Cmd) Run

func (c *Cmd) Run(k *kong.Context, _ logging.Logger) error

Run validate.

type Fetcher

type Fetcher struct{}

Fetcher implements the ImageFetcher interface.

func (*Fetcher) FetchBaseLayer

func (f *Fetcher) FetchBaseLayer(image string) (*conregv1.Layer, error)

FetchBaseLayer fetches the base layer of the image which contains the 'package.yaml' file.

func (*Fetcher) FetchImage added in v1.18.0

func (f *Fetcher) FetchImage(image string) ([]conregv1.Layer, error)

FetchImage pulls the full image and extracts the CRDs folder to fetch .yaml files.

type FileLoader

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

FileLoader implements the Loader interface for reading from a file and converting input to unstructured objects.

func (*FileLoader) Load

func (f *FileLoader) Load() ([]*unstructured.Unstructured, error)

Load reads the contents from a file.

type FolderLoader

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

FolderLoader implements the Loader interface for reading from a folder.

func (*FolderLoader) Load

func (f *FolderLoader) Load() ([]*unstructured.Unstructured, error)

Load reads the contents from all files in a folder.

type ImageFetcher

type ImageFetcher interface {
	FetchBaseLayer(image string) (*conregv1.Layer, error)
	FetchImage(image string) ([]conregv1.Layer, error)
}

ImageFetcher defines an interface for fetching images.

type Loader

type Loader interface {
	Load() ([]*unstructured.Unstructured, error)
}

Loader interface defines the contract for different input sources.

func NewLoader

func NewLoader(input string) (Loader, error)

NewLoader returns a Loader based on the input source.

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.

func (*LocalCache) Flush

func (c *LocalCache) Flush() error

Flush removes the cache directory.

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() ([]*unstructured.Unstructured, error)

Load loads the schemas from the cache directory.

func (*LocalCache) Store

func (c *LocalCache) Store(schemas [][]byte, path string) error

Store stores the schemas in the directory.

type Manager

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

Manager defines a Manager for preparing Crossplane packages for validation.

func NewManager

func NewManager(cacheDir string, fs afero.Fs, w io.Writer, opts ...Option) *Manager

NewManager returns a new Manager.

func (*Manager) CacheAndLoad

func (m *Manager) CacheAndLoad(cleanCache bool) error

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 added in v1.18.0

type Option func(*Manager)

Option defines an option for the Manager.

func WithCrossplaneImage added in v1.18.0

func WithCrossplaneImage(image string) Option

WithCrossplaneImage sets the Crossplane image to use for fetching CRDs.

type StdinLoader

type StdinLoader struct{}

StdinLoader implements the Loader interface for reading from stdin.

func (*StdinLoader) Load

func (s *StdinLoader) Load() ([]*unstructured.Unstructured, error)

Load reads the contents from stdin.

Jump to

Keyboard shortcuts

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