checks

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	CommonCheckFields
	// contains filtered or unexported fields
}

Check is wrapper struct around a Condition. This wrapping setup is used so that we only need to implement the UnmarshalYAML method once (in Check) instead of having to implement it in each individual condition type. This is similar to what we do with ParseAction for decoding the actions associated with steps.

func (*Check) UnmarshalYAML

func (c *Check) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements custom deserialization process to ensure that the check is decoded into the correct struct type

func (*Check) Verify

func (c *Check) Verify(ctx VerificationContext) error

Verify wraps the Verify method from the underlying condition

type Checksum

type Checksum struct {
	SHA256 string `yaml:"sha256"`
}

Checksum is a struct that contains different types of checksums against which a file can be verified. Right now we just support SHA256 checksums, but in the future others such as MD5 can be added if needed.

func (*Checksum) Verify

func (c *Checksum) Verify(contents []byte) error

Verify computes the checksum of the contents and compares it to the expected value

type CommonCheckFields

type CommonCheckFields struct {
	Msg string `yaml:"msg"`
}

CommonCheckFields are common fields across all check types

type Condition

type Condition interface {
	Verify(ctx VerificationContext) error
}

Condition is the common interface implemented by all condition types

type PathExists

type PathExists struct {
	Path     string    `yaml:"path_exists"`
	Checksum *Checksum `yaml:"checksum"`
}

PathExists is a condition that verifies that a file exists at a given path It can also verify the contents of the file against a checksum

func (*PathExists) Verify

func (c *PathExists) Verify(ctx VerificationContext) error

Verify checks the condition and returns an error if it fails

type VerificationContext

type VerificationContext struct {
	Platform   platforms.Spec
	FileSystem afero.Fs
}

VerificationContext contains contextual information required to verify conditions of various types

Jump to

Keyboard shortcuts

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