trigger

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package trigger provides functionality that help manipulate stacks triggers.

Index

Constants

View Source
const (
	// ErrTrigger indicates an error happened while triggering the stack.
	ErrTrigger errors.Kind = "trigger failed"

	// ErrParsing indicates an error happened while parsing the trigger file.
	ErrParsing errors.Kind = "parsing trigger file"
)
View Source
const (
	// DefaultContext is the default context for the trigger file when not specified.
	DefaultContext = "stack"
)

Variables

This section is empty.

Functions

func Create

func Create(root *config.Root, path project.Path, kind Kind, reason string) error

Create creates a trigger for a stack with the given path and the given reason inside the project rootdir.

func Dir

func Dir(rootdir string) string

Dir will return the triggers directory for the project rooted at rootdir. Both rootdir and the returned value are host absolute paths.

func StackPath

func StackPath(triggerFile project.Path) (project.Path, bool)

StackPath accepts a trigger file path and returns the path of the stack that is triggered by the given file. If the given file is not a stack trigger at all it will return false.

Types

type Info

type Info struct {
	// Ctime is unix timestamp of when the trigger was created.
	Ctime int64
	// Reason is the reason why the trigger was created, if any.
	Reason string
	// Type is the trigger type.
	Type Kind
	// Context is the context of the trigger (only `stack` at the moment)
	Context string
	// StackPath is the path of the triggered stack.
	StackPath project.Path
}

Info represents the parsed contents of a trigger.

func Is added in v0.9.0

func Is(root *config.Root, filename project.Path) (info Info, stack project.Path, exists bool, err error)

Is checks if the filename is a trigger file and if that's the case then it returns the parsed trigger info and the triggered path. If the trigger file exists, the exists returns true. If the file is not inside the triggerDir then it returns an empty Info, empty path, false and no error. If there's an error parsing the trigger file, it returns empty info, true and the error. It only parses the file if it's inside the triggers directory (.tmtriggers).

func ParseFile

func ParseFile(path string) (Info, error)

ParseFile will parse the given trigger file.

type Kind added in v0.9.0

type Kind string

Kind is the trigger type/kind.

const (
	Changed Kind = "changed"
	Ignored Kind = "ignore-change"
)

Supported trigger kinds.

Jump to

Keyboard shortcuts

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