target

package
v0.0.0-...-b7a57f2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTargetDoesNotExist = fmt.Errorf("target does not exist")
)
View Source
var IgnoredTargets = []string{"node_modules/.cache"}

Functions

func ShouldIgnore

func ShouldIgnore(path string) bool

ShouldIgnore checks if file path should be ignored when creating/extracting artifact or creating the buildinfo

Types

type Option

type Option func(t *T)

func WithDir

func WithDir(dir string) Option

func WithDockerImages

func WithDockerImages(images []string) Option

func WithFilesystemEntries

func WithFilesystemEntries(entries []string) Option

type Reason

type Reason string

Reason contains the reason why a file/directory makes the target invalid

const (
	ReasonCreatedAfterBuild Reason = "CREATED-AFTER-BUILD"
	ReasonSizeChanged       Reason = "SIZE-CHANGED"
	ReasonHashChanged       Reason = "HASH-CHANGED"
	ReasonMissing           Reason = "MISSING"
	ReasonForcedByNoCache   Reason = "FORCED-BY-NO-CACHE"
)

type T

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

func New

func New(opts ...Option) *T

func (*T) AsInvalidFiles

func (t *T) AsInvalidFiles(reason Reason) map[string][]Reason

AsInvalidFiles returns all FilesystemEntriesRaw as invalid with the specified reason

func (*T) BuildInfo

func (t *T) BuildInfo() (bi *buildinfo.Targets, err error)

BuildInfo reads file info and computes the target hash for filesystem and docker targets.

func (*T) DockerImages

func (t *T) DockerImages() []string

func (*T) FilesystemEntries

func (t *T) FilesystemEntries() []string

FilesystemEntries in relation to the umrella bobfile

func (*T) FilesystemEntriesRaw

func (t *T) FilesystemEntriesRaw() []string

FilesystemEntriesRaw returns the filesystem entries relative to the umbrella bobfile.

func (*T) FilesystemEntriesRawPlain

func (t *T) FilesystemEntriesRawPlain() []string

func (*T) Resolve

func (t *T) Resolve() error

Resolve filesystem entries based on filesystemEntriesRaw. Becomes a noop after the first call.

func (*T) Verify

func (t *T) Verify() bool

Verify existence and integrity of targets against an expected buildinfo. In case the expected buildinfo does not exist Verify checks against filesystemEntriesRaw.

Verify returns true when no targets are defined. Verify returns when there is nothing to compare against.

func (*T) VerifyShallow

func (t *T) VerifyShallow() VerifyResult

VerifyShallow compare targets against an existing buildinfo. It will only check if the size of the files changed. Docker targets are verified similarly as in plain verify as there is no performance penalty. In case the expected buildinfo does not exist Verify checks against filesystemEntriesRaw.

func (*T) WithDockerRegistryClient

func (t *T) WithDockerRegistryClient(c dockermobyutil.RegistryClient)

func (*T) WithExpected

func (t *T) WithExpected(expected *buildinfo.Targets)

type Target

type Target interface {
	BuildInfo() (*buildinfo.Targets, error)

	Verify() bool
	VerifyShallow() VerifyResult
	Resolve() error

	FilesystemEntries() []string
	FilesystemEntriesRaw() []string
	FilesystemEntriesRawPlain() []string

	WithExpected(*buildinfo.Targets)
	DockerImages() []string

	// AsInvalidFiles returns all FilesystemEntriesRaw as invalid with the specified reason
	AsInvalidFiles(reason Reason) map[string][]Reason
}

type VerifyResult

type VerifyResult struct {
	// TargetIsValid shows if target is valid or not
	TargetIsValid bool
	// InvalidFiles maps filePath to reasons why it's invalid
	InvalidFiles map[string][]Reason
}

VerifyResult is the result of a target verify call. It tells if the target is valid and if not InvalidFiles will contain the list of invalid files along with their reason. A file can be invalid for multiple reasons. ex. a changed file is invalid because of size and content hash. The map of invalid files can be used to extract only invalidated files from an artifact.

func NewVerifyResult

func NewVerifyResult() VerifyResult

NewVerifyResult initializes a new VerifyResult

func (VerifyResult) AddInvalidReason

func (v VerifyResult) AddInvalidReason(filePath string, reason Reason)

AddInvalidReason adds a reason for invalidation to a certain filePath

Jump to

Keyboard shortcuts

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