bobtask

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: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskPathSeparator = '/'
)

Variables

View Source
var (
	ErrBobfileNotFound        = fmt.Errorf("could not find a bobfile")
	ErrHashesFileDoesNotExist = fmt.Errorf("hashes file does not exist")
	ErrTaskHashDoesNotExist   = fmt.Errorf("task hash does not exist")
	ErrHashInDoesNotExist     = fmt.Errorf("input-hash does not exist")
	ErrInvalidInput           = fmt.Errorf("invalid input")
	ErrBuildinfostoreIsNil    = fmt.Errorf("buildinfostore is nil")

	ErrInvalidTargetDefinition  = fmt.Errorf("invalid target definition, can't find 'path' or 'image' directive")
	ErrAmbigousTargetDefinition = fmt.Errorf("ambigous target definition, can't have 'path' and 'image' directive on same target")

	ErrAmbigousTargets = fmt.Errorf("ambigous targets detected")
)
View Source
var ErrArtifactDoesNotExist = fmt.Errorf("artifact does not exist")
View Source
var ErrInvalidTarHeaderType = fmt.Errorf("invalid tar header type")

Functions

func CreateErrAmbiguousTargets

func CreateErrAmbiguousTargets(tasks []string, target string) error

Types

type ArtifactInfo

type ArtifactInfo interface {
	Metadata() *ArtifactMetadata
	String() string
	Types() []targettype.T
}

func ArtifactInspectFromReader

func ArtifactInspectFromReader(reader io.ReadCloser) (_ ArtifactInfo, err error)

ArtifactInspectFromPath opens a artifact from a io reader and returns a string containing compact information about a target.

type ArtifactMetadata

type ArtifactMetadata struct {
	// Project is the project in which the task is defined
	Project string `yaml:"project,omitempty"`

	// Taskname this artifact was build for
	Taskname string `yaml:"taskname,omitempty"`

	// InputHash and unique identifier
	InputHash string `yaml:"input_hash,omitempty"`

	// CreatedAt timestamp the artifact was created
	CreatedAt time.Time `yaml:"created_at,omitempty"`
}

func NewArtifactMetadata

func NewArtifactMetadata() *ArtifactMetadata

type Map

type Map map[string]Task

func (Map) CollectNixDependenciesForTasks

func (tm Map) CollectNixDependenciesForTasks(whitelist []string) ([]nix.Dependency, error)

CollectNixDependenciesForTasks will collect all nix dependencies for task taskName in nixDependencies slice

func (Map) CollectTasksInPipeline

func (tm Map) CollectTasksInPipeline(taskName string) ([]string, error)

CollectTasksInPipeline will collect all task names in the pipeline for task taskName in the tasksInPipeline slice

func (Map) FilterInputs

func (tm Map) FilterInputs() (err error)

FilterInputs in parallel

func (Map) FilterInputsSequential

func (tm Map) FilterInputsSequential() (err error)

FilterInputsSequential is the sequential version of FilterInputs. Can be handy for debugging input errors.

func (Map) IgnoreChildTargets

func (tm Map) IgnoreChildTargets(dir string) (err error)

IgnoreChildTargets fills the `InputAdditionalIgnores` field of each task with the targets of each tasks children. `dir` must be the root of the aggregate, and it is used to ignore resolved targets relative to this project

func (Map) KeysSortedAlpabethically

func (tm Map) KeysSortedAlpabethically() (keys []string)

func (Map) Sanitize

func (tm Map) Sanitize() (err error)

Sanitize task map and write filtered & sanitized properties from dirty members to plain (e.g. dirtyInputs -> filter&sanitize -> inputs)

func (Map) String

func (tm Map) String() string

func (Map) VerifyDuplicateTargets

func (tm Map) VerifyDuplicateTargets() error

VerifyDuplicateTargets checks if multiple build tasks point to the same target.

func (Map) Walk

func (tm Map) Walk(root string, parentLevel string, fn func(taskname string, _ Task, _ error) error) error

walk the task tree starting at root. Following dependend tasks. dependencies are expressed in local scope, level is used to resolve the taskname in global scope.

type RebuildOptions

type RebuildOptions struct {
	HashIn *hash.In
}

type RebuildType

type RebuildType string
const (
	RebuildAlways   RebuildType = "always"
	RebuildOnChange RebuildType = "on-change"
)

type TargetEntry

type TargetEntry interface{}

type Task

type Task struct {

	// InputDirty is the representation read from a bobfile.
	InputDirty string `yaml:"input,omitempty"`
	// InputAdditionalIgnores is a list of ignores
	// usually the child targets.
	InputAdditionalIgnores []string `yaml:"input_additional_ignores,omitempty"`

	CmdDirty string `yaml:"cmd,omitempty"`

	// DependsOn are task which must succeed before this task
	// can run.
	DependsOn []string `yaml:"dependsOn,omitempty"`

	// dependsOnIDs task id's used for optimization.
	// Not exposed in a Bobfile.
	DependsOnIDs []int `yaml:"-"`

	// Target defines the output of a task.
	TargetDirty TargetEntry `yaml:"target,omitempty"`

	// defines the rebuild strategy
	RebuildDirty string `yaml:"rebuild,omitempty"`

	// taskID is a integer provided to
	// avoid referencing tasks by name
	// (string comparison, map access)
	TaskID int

	// DependenciesDirty read from the bobfile
	DependenciesDirty []string `yaml:"dependencies,omitempty"`
	// contains filtered or unexported fields
}

Hint: When adding a new *Dirty field assure to update IsValidDecoration().

func Make

func Make(opts ...TaskOption) Task

func (*Task) ArtifactCreate

func (t *Task) ArtifactCreate(artifactName hash.In) (err error)

ArtifactCreate create an archive for one or multiple targets

func (*Task) ArtifactExists

func (t *Task) ArtifactExists(artifactName hash.In) bool

ArtifactExists return true when the artifact exists in localstore

func (*Task) ArtifactExtract

func (t *Task) ArtifactExtract(artifactName hash.In, invalidFiles map[string][]target.Reason) (success bool, err error)

ArtifactExtract extract an artifact from the localstore if it exists. Return true on a successful extract operation.

func (*Task) ArtifactInspect

func (t *Task) ArtifactInspect(artifactNames ...hash.In) (ai ArtifactInfo, err error)

func (*Task) Clean

func (t *Task) Clean(verbose ...bool) error

Clean all filesystem targets as given in the Bobfile

func (*Task) CleanTargetsWithReason

func (t *Task) CleanTargetsWithReason(invalidFiles map[string][]target.Reason, verbose ...bool) error

CleanTargetsWithReason removes files assosiated to a target but considering the reason for a deletion. This assures that we can be sure a target was correctly created and has not been there before the task ran.

func (*Task) ColoredName

func (t *Task) ColoredName() string

func (*Task) Dependencies

func (t *Task) Dependencies() []nix.Dependency

func (*Task) DidTaskChange

func (t *Task) DidTaskChange() (_ bool, err error)

didTaskChange returns true if the `In` hash does not exist in the buildinfo storage. This indicates that there has not been a previous build for this combination of inputs.

func (*Task) Dir

func (t *Task) Dir() string

func (*Task) Env

func (t *Task) Env() []string

func (*Task) FilterInputs

func (t *Task) FilterInputs(wd string) (err error)

func (*Task) FilteredInputs

func (t *Task) FilteredInputs(projectRoot string) (_ []string, err error)

filteredInputs returns inputs filtered by ignores and file targets. Calls sanitize on the result.

func (*Task) GetArtifactMetadata

func (t *Task) GetArtifactMetadata(artifactName string) (_ *ArtifactMetadata, err error)

GetArtifactMetadata creates a new artifact instance to retrive Metadata separately and returns ArtifactMetadata, close the artifacts before returning

func (*Task) HashIn

func (t *Task) HashIn() (taskHash hash.In, err error)

HashIn computes the input hash

func (*Task) HashInAlways

func (t *Task) HashInAlways() (taskHash hash.In, err error)

HashInAlways computes the input hash without using a cached value

func (*Task) Inputs

func (t *Task) Inputs() []string

func (*Task) IsDecoration

func (t *Task) IsDecoration() bool

IsDecoration check if the task is a decorated task

func (*Task) IsValidDecoration

func (t *Task) IsValidDecoration() bool

IsValidDecoration checks if the task is a valid decoration. tasks containing a `dependsOn` node only are considered as valid decoration.

Make sure to update IsValidDecoration() very time a new *Dirty field is added to the task.

func (*Task) LogSkippedInput

func (t *Task) LogSkippedInput() []string

LogSkippedInput skipped input files from the task. prints nothing if there is not skipped input.

func (*Task) Name

func (t *Task) Name() string

func (*Task) Nixpkgs

func (t *Task) Nixpkgs() string

func (*Task) Project

func (t *Task) Project() string

Project returns the projectname. In case of a non existing projectname the tasks local directory is returned.

func (*Task) ReadBuildInfo

func (t *Task) ReadBuildInfo() (bi *buildinfo.I, err error)

ReadBuildInfo indexed by the input hash from the store

func (*Task) Rebuild

func (t *Task) Rebuild() RebuildType

func (*Task) Run

func (t *Task) Run(ctx context.Context, namePad int) (err error)

func (*Task) SetColor

func (t *Task) SetColor(color aurora.Color)

func (*Task) SetDependencies

func (t *Task) SetDependencies(dependencies []nix.Dependency)

func (*Task) SetDir

func (t *Task) SetDir(dir string)

func (*Task) SetEnv

func (t *Task) SetEnv(env []string)

func (*Task) SetEnvID

func (t *Task) SetEnvID(envID envutil.Hash)

func (*Task) SetInputs

func (t *Task) SetInputs(inputs []string)

func (*Task) SetName

func (t *Task) SetName(name string)

func (*Task) SetNixpkgs

func (t *Task) SetNixpkgs(nixpkgs string)

func (*Task) SetProject

func (t *Task) SetProject(proj string)

func (*Task) SetRebuildStrategy

func (t *Task) SetRebuildStrategy(rebuild RebuildType)

Set the rebuild strategy for the task defaults to `on-change`.

func (*Task) ShortName

func (t *Task) ShortName() string

func (*Task) Target

func (t *Task) Target() (empty target.Target, _ error)

Target takes care of populating the targets members correctly. It returns a nil in case of a non-existing target and a nil error.

func (*Task) TargetExists

func (t *Task) TargetExists() bool

func (*Task) UnmarshalYAML

func (t *Task) UnmarshalYAML(value *yaml.Node) (err error)

func (*Task) Verify

func (t *Task) Verify() error

Verify a bobfile before task runner.

func (*Task) VerifyAfter

func (t *Task) VerifyAfter() error

VerifyAfter a bobfile after task runner.

func (*Task) VerifyBefore

func (t *Task) VerifyBefore() error

VerifyBefore a bobfile before task runner.

func (*Task) WithBuildinfoStore

func (t *Task) WithBuildinfoStore(s buildinfostore.Store) *Task

func (*Task) WithDockerRegistryClient

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

func (*Task) WithEnvStore

func (t *Task) WithEnvStore(s envutil.Store) *Task

func (*Task) WithLocalstore

func (t *Task) WithLocalstore(s store.Store) *Task

func (*Task) WithRemotestore

func (t *Task) WithRemotestore(s store.Store) *Task

func (*Task) WriteBuildinfo

func (t *Task) WriteBuildinfo(buildinfo *buildinfo.I) (err error)

WriteBuildinfo indexed by the input hash to the store

type TaskOption

type TaskOption func(t *Task)

func WithEnvironment

func WithEnvironment(envs []string) TaskOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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