snapshot

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultCompositionValidators

func DefaultCompositionValidators(s *Snapshot) (validator.Validator, error)

DefaultCompositionValidators returns a new Composition validator.

func DefaultXRDValidators

func DefaultXRDValidators() (validator.Validator, error)

DefaultXRDValidators returns a new Meta validator.

func ValidatorsForObj

ValidatorsForObj returns a mapping of GVK -> validator for the given runtime.Object.

Types

type CompositionValidator

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

CompositionValidator defines a validator for compositions.

func (*CompositionValidator) Validate

func (c *CompositionValidator) Validate(ctx context.Context, data any) *validate.Result

Validate performs validation rules on the given data input per the rules defined for the Validator.

type DepManager

type DepManager interface {
	View(context.Context, []v1beta1.Dependency) (*manager.View, error)
	Versions(context.Context, v1beta1.Dependency) ([]string, error)
	Watch() <-chan cache.Event
}

DepManager defines the API necessary for working with the dependency manager.

type Factory

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

Factory is used to "stamp out" Snapshots while allowing a shared set of references.

func NewFactory

func NewFactory(workdir string, opts ...FactoryOption) (*Factory, error)

NewFactory returns a new Snapshot Factory instance.

func (*Factory) New

func (f *Factory) New(ctx context.Context, opts ...Option) (*Snapshot, error)

New constructs a new Snapshot at the given workdir, with the supplied logger.

func (*Factory) WatchExt

func (f *Factory) WatchExt() <-chan cache.Event

WatchExt provides a channel for callers to subscribe to external changes that affect the Factory. For example, cache changes.

type FactoryOption

type FactoryOption func(*Factory)

FactoryOption modifies a Factory.

func WithDepManager

func WithDepManager(m DepManager) FactoryOption

WithDepManager overrides the default dependency manager with the provided manager.

func WithLogger

func WithLogger(l logging.Logger) FactoryOption

WithLogger overrides the default logger with the provided Logger.

type MetaValidator

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

MetaValidator defines a validator for meta files.

func DefaultMetaValidators

func DefaultMetaValidators(s *Snapshot) (*MetaValidator, error)

DefaultMetaValidators returns a new Meta validator.

func (*MetaValidator) Marshal

func (m *MetaValidator) Marshal(ctx context.Context, data any) (metav1.Pkg, runtime.Object, error)

Marshal marshals the given data object into a Pkg, errors otherwise.

func (*MetaValidator) Validate

func (m *MetaValidator) Validate(ctx context.Context, data any) *validate.Result

Validate performs validation rules on the given data input per the rules defined for the Validator.

type Option

type Option func(*Snapshot)

Option modifies a Snapshot.

func WithWorkspace

func WithWorkspace(w *workspace.Workspace) Option

WithWorkspace overrides the default workspace with the provided workspace.

type PatchesValidator

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

PatchesValidator validates the patches fields of a Composition.

func NewPatchesValidator

func NewPatchesValidator(s *Snapshot) *PatchesValidator

NewPatchesValidator returns a new PatchesValidator.

type Snapshot

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

Snapshot provides a unified point in time snapshot of the details needed to perform operations on an xpkg project. These details include: - currently parsed workspace files - external dependencies per the crossplane.yaml in the xpkg project

func (*Snapshot) Package

func (s *Snapshot) Package(name string) *mxpkg.ParsedPackage

Package returns the ParsedPackage corresponding to the supplied package name as defined in the crossplane.yaml, if one exists. Nil otherwise.

func (*Snapshot) ReParseFile

func (s *Snapshot) ReParseFile(ctx context.Context, path string) error

ReParseFile re-parses the file at the given path. This is only useful in cases where our snapshot representation has changed prior to the given file being saved.

func (*Snapshot) UpdateContent

func (s *Snapshot) UpdateContent(ctx context.Context, uri span.URI, changes []protocol.TextDocumentContentChangeEvent) error

UpdateContent updates the current in-memory content representation for the provided file uri.

func (*Snapshot) Validate

func (s *Snapshot) Validate(ctx context.Context, uri span.URI) ([]protocol.Diagnostic, error)

Validate performs validation on all filtered nodes and returns diagnostics for any validation errors encountered. TODO(hasheddan): consider decoupling forming diagnostics from getting validation errors.

func (*Snapshot) ValidateAllFiles

func (s *Snapshot) ValidateAllFiles(ctx context.Context) (map[span.URI][]protocol.Diagnostic, error)

ValidateAllFiles performs validations on all files in Snapshot.

func (*Snapshot) ValidateMeta

func (s *Snapshot) ValidateMeta(ctx context.Context) (span.URI, []protocol.Diagnostic, error)

ValidateMeta performs validations specifically on the meta file. This is specifically helpful when performing background validations and not responding to validation requests synchronously.

func (*Snapshot) Validator

Validator returns the Validator corresponding to the provided GVK within the Snapshot, if one exists. Nil otherwise.

type TypeValidator

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

TypeValidator validates the dependency type matches the supplied dependency in a meta file.

func NewTypeValidator

func NewTypeValidator(s *Snapshot) *TypeValidator

NewTypeValidator returns a new TypeValidator.

type VersionValidator

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

VersionValidator is used to validate the dependency versions in a meta file.

func NewVersionValidator

func NewVersionValidator(manager DepManager) *VersionValidator

NewVersionValidator returns a new VersionValidator. NOTE(@tnthornton) NewVersionValidator needs snapshot's manager due to the use case where someone adds a dependency to the crossplane.yaml and we need to validate its existence.

type XRDSchemaValidator

type XRDSchemaValidator struct{}

XRDSchemaValidator validates XRD schema definitions.

func NewXRDSchemaValidator

func NewXRDSchemaValidator() *XRDSchemaValidator

NewXRDSchemaValidator returns a new XRDSchemaValidator.

type XRDValidator

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

XRDValidator defines a validator for xrd files.

func (*XRDValidator) Marshal

Marshal marshals the given data object into a Pkg, errors otherwise.

func (*XRDValidator) Validate

func (x *XRDValidator) Validate(ctx context.Context, data any) *validate.Result

Validate performs validation rules on the given data input per the rules defined for the Validator.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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