validate

package
v1.15.2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 27 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 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 Cache

type Cache interface {
	Store([][]byte, string) error
	Flush() error
	Init() error
	Load() ([]*unstructured.Unstructured, error)
	Exists(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 `help:"Absolute path to the cache directory where downloaded schemas are stored." default:".crossplane/cache"`
	CleanCache         bool   `help:"Clean the cache directory before downloading package schemas."`
	SkipSuccessResults bool   `help:"Skip printing success results."`
	// 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

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)
}

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) *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 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