stack

package
v0.10.3-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MPL-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package stack defines all functionality around stacks, like loading, listing all stacks, etc.

Index

Constants

View Source
const (
	// ErrInvalidStackDir indicates that the given stack dir is invalid.
	ErrInvalidStackDir errors.Kind = "invalid stack directory"

	// ErrStackAlreadyExists indicates that the stack already exists and cant be created.
	ErrStackAlreadyExists errors.Kind = "stack already exists"

	// ErrStackDefaultCfgFound indicates that the dir already has a default
	// stack configuration.
	ErrStackDefaultCfgFound errors.Kind = "default configuration file for stack already exists"
)
View Source
const DefaultFilename = "stack.tm.hcl"

DefaultFilename is the default file name for created stacks.

View Source
const (
	// ErrCloneDestDirExists indicates that the dest dir on a clone
	// operation already exists.
	ErrCloneDestDirExists errors.Kind = "clone dest dir exists"
)

Variables

This section is empty.

Functions

func Clone

func Clone(root *config.Root, destdir, srcdir string, skipChildStacks bool) (int, error)

Clone will clone the stack at srcdir into destdir.

- srcdir must contain at least one stack directly, or in subdirs unless skipChildStacks is set (fail otherwise) - destdir must not exist (fail otherwise) - if skipChildStacks is true, child stacks are ignored - All files and directories are copied (except dotfiles/dirs) - If cloned stack has an ID it will be adjusted to a generated UUID. - If cloned stack has no ID the cloned stack also won't have an ID.

func Create

func Create(root *config.Root, stack config.Stack, imports ...string) (err error)

Create creates the provided stack on the filesystem. The list of import paths provided are generated inside the stack file.

If the stack already exists it will return an error and no changes will be made to the stack.

func UpdateStackID added in v0.3.1

func UpdateStackID(root *config.Root, stackdir string) (string, error)

UpdateStackID updates the stack.id of the given stack directory. The functions updates just the file which defines the stack block. The updated file will lose all comments.

Types

type Entry

type Entry struct {
	Stack  *config.Stack
	Reason string // Reason why this entry was returned.
}

Entry is a stack entry result.

func List

func List(root *config.Root, cfg *config.Tree) ([]Entry, error)

List loads from the config all terramate stacks. It returns a lexicographic sorted list of stack directories.

type EntrySlice

type EntrySlice []Entry

EntrySlice implements the Sort interface.

func (EntrySlice) Len

func (x EntrySlice) Len() int

func (EntrySlice) Less

func (x EntrySlice) Less(i, j int) bool

func (EntrySlice) Swap

func (x EntrySlice) Swap(i, j int)

type EvalCtx

type EvalCtx struct {
	*eval.Context
	// contains filtered or unexported fields
}

EvalCtx represents the evaluation context of a stack.

func NewEvalCtx

func NewEvalCtx(root *config.Root, stack *config.Stack, globals *eval.Object) *EvalCtx

NewEvalCtx creates a new stack evaluation context.

func (*EvalCtx) SetGlobals

func (e *EvalCtx) SetGlobals(g *eval.Object)

SetGlobals sets the given globals in the stack evaluation context.

func (*EvalCtx) SetMetadata

func (e *EvalCtx) SetMetadata(st *config.Stack)

SetMetadata sets the given metadata in the stack evaluation context.

type Manager

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

Manager is the terramate stacks manager.

func NewGitAwareManager added in v0.4.4

func NewGitAwareManager(root *config.Root, git *git.Git) *Manager

NewGitAwareManager returns a stack manager that supports change detection.

func NewManager

func NewManager(root *config.Root) *Manager

NewManager creates a new stack manager.

func (*Manager) AddWantedOf

func (m *Manager) AddWantedOf(scopeStacks config.List[*config.SortableStack]) (config.List[*config.SortableStack], error)

AddWantedOf returns all wanted stacks from the given stacks.

func (*Manager) List

func (m *Manager) List(checkRepo bool) (*Report, error)

List walks the basedir directory looking for terraform stacks. The stacks are cached and sorted lexicographicly by the directory.

func (*Manager) ListChanged

func (m *Manager) ListChanged(gitBaseRef string) (*Report, error)

ListChanged lists the stacks that have changed on the current HEAD, compared to the main branch. This method assumes a version control system in place and that you are working on a branch that is not main. It's an error to call this method in a directory that's not inside a repository or a repository with no commits in it. It never returns cached values.

func (*Manager) StackByID added in v0.10.1

func (m *Manager) StackByID(id string) (*config.Stack, bool, error)

StackByID returns the stack with the given id.

type RepoChecks

type RepoChecks struct {
	UncommittedFiles []string
	UntrackedFiles   []string
}

RepoChecks contains the info of default checks.

type Report

type Report struct {
	Stacks []Entry

	// Checks contains the result info of default checks.
	Checks RepoChecks
}

Report is the report of project's stacks and the result of its default checks.

Directories

Path Synopsis
Package trigger provides functionality that help manipulate stacks triggers.
Package trigger provides functionality that help manipulate stacks triggers.

Jump to

Keyboard shortcuts

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