taskfile

package
v3.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrIncludedTaskfilesCantHaveDotenvs is returned when a included Taskfile contains dotenvs
	ErrIncludedTaskfilesCantHaveDotenvs = errors.New("task: Included Taskfiles can't have dotenv declarations. Please, move the dotenv declaration to the main Taskfile")
)

Functions

func Dotenv

func Dotenv(c *compiler.Compiler, tf *ast.Taskfile, dir string) (*ast.Vars, error)

func Exists

func Exists(path string) (string, error)

Exists will check if a file at the given path Exists. If it does, it will return the path to it. If it does not, it will search the search for any files at the given path with any of the default Taskfile files names. If any of these match a file, the first matching path will be returned. If no files are found, an error will be returned.

func ExistsWalk

func ExistsWalk(path string) (string, error)

ExistsWalk will check if a file at the given path exists by calling the exists function. If a file is not found, it will walk up the directory tree calling the exists function until it finds a file or reaches the root directory. On supported operating systems, it will also check if the user ID of the directory changes and abort if it does.

func Read

func Read(
	node Node,
	insecure bool,
	download bool,
	offline bool,
	timeout time.Duration,
	tempDir string,
	l *logger.Logger,
) (*ast.Taskfile, error)

Read reads a Read for a given directory Uses current dir when dir is left empty. Uses Read.yml or Read.yaml when entrypoint is left empty

Types

type BaseNode

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

BaseNode is a generic node that implements the Parent() and Optional() methods of the NodeReader interface. It does not implement the Read() method and it designed to be embedded in other node types so that this boilerplate code does not need to be repeated.

func NewBaseNode

func NewBaseNode(opts ...NodeOption) *BaseNode

func (*BaseNode) Optional

func (node *BaseNode) Optional() bool

func (*BaseNode) Parent

func (node *BaseNode) Parent() Node

type Cache

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

func NewCache

func NewCache(dir string) (*Cache, error)

type FileNode

type FileNode struct {
	*BaseNode
	Dir        string
	Entrypoint string
}

A FileNode is a node that reads a taskfile from the local filesystem.

func NewFileNode

func NewFileNode(uri string, opts ...NodeOption) (*FileNode, error)

func (*FileNode) BaseDir

func (node *FileNode) BaseDir() string

func (*FileNode) Location

func (node *FileNode) Location() string

func (*FileNode) Read

func (node *FileNode) Read(ctx context.Context) ([]byte, error)

func (*FileNode) Remote

func (node *FileNode) Remote() bool

type HTTPNode

type HTTPNode struct {
	*BaseNode
	URL *url.URL
}

An HTTPNode is a node that reads a Taskfile from a remote location via HTTP.

func NewHTTPNode

func NewHTTPNode(uri string, insecure bool, opts ...NodeOption) (*HTTPNode, error)

func (*HTTPNode) BaseDir

func (node *HTTPNode) BaseDir() string

func (*HTTPNode) Location

func (node *HTTPNode) Location() string

func (*HTTPNode) Read

func (node *HTTPNode) Read(ctx context.Context) ([]byte, error)

func (*HTTPNode) Remote

func (node *HTTPNode) Remote() bool

type Node

type Node interface {
	Read(ctx context.Context) ([]byte, error)
	Parent() Node
	Location() string
	Optional() bool
	Remote() bool
	BaseDir() string
}

func NewNode

func NewNode(
	uri string,
	insecure bool,
	opts ...NodeOption,
) (Node, error)

func NewRootNode

func NewRootNode(
	dir string,
	entrypoint string,
	insecure bool,
) (Node, error)

type NodeOption

type NodeOption func(*BaseNode)

func WithOptional

func WithOptional(optional bool) NodeOption

func WithParent

func WithParent(parent Node) NodeOption

type StdinNode

type StdinNode struct {
	*BaseNode
	Dir string
}

A StdinNode is a node that reads a taskfile from the standard input stream.

func NewStdinNode

func NewStdinNode(dir string) (*StdinNode, error)

func (*StdinNode) BaseDir

func (node *StdinNode) BaseDir() string

func (*StdinNode) Location

func (node *StdinNode) Location() string

func (*StdinNode) Read

func (node *StdinNode) Read(ctx context.Context) ([]byte, error)

func (*StdinNode) Remote

func (node *StdinNode) Remote() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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