tfc_trigger

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTfcOrganizationEnvName = "TFBUDDY_DEFAULT_TFC_ORGANIZATION"
View Source
const ProjectConfigFilename = `.tfbuddy.yaml`

Variables

View Source
var (
	ErrWorkspaceNotDefined = errors.New("the workspace is not defined in " + ProjectConfigFilename)
	ErrNoChangesDetected   = errors.New("no changes detected for configured Terraform directories")
	ErrWorkspaceLocked     = errors.New("workspace is already locked")
	ErrWorkspaceUnlocked   = errors.New("workspace is already unlocked")
)

predefined errors

Functions

func FindLockingMR

func FindLockingMR(ctx context.Context, tags []string, thisMR string) string

Types

type ErroredWorkspace

type ErroredWorkspace struct {
	Name  string
	Error string
}

type ProjectConfig

type ProjectConfig struct {
	Workspaces []*TFCWorkspace `yaml:"workspaces"`
}

type TFCTrigger

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

func (*TFCTrigger) GetAction added in v0.1.6

func (t *TFCTrigger) GetAction() TriggerAction

func (*TFCTrigger) GetBranch added in v0.1.6

func (t *TFCTrigger) GetBranch() string

func (*TFCTrigger) GetCommitSHA added in v0.1.6

func (t *TFCTrigger) GetCommitSHA() string

func (*TFCTrigger) GetMergeRequestDiscussionID added in v0.1.6

func (t *TFCTrigger) GetMergeRequestDiscussionID() string

func (*TFCTrigger) GetMergeRequestIID added in v0.1.6

func (t *TFCTrigger) GetMergeRequestIID() int

func (*TFCTrigger) GetMergeRequestRootNoteID added in v0.1.6

func (t *TFCTrigger) GetMergeRequestRootNoteID() int64

func (*TFCTrigger) GetProjectNameWithNamespace added in v0.1.6

func (t *TFCTrigger) GetProjectNameWithNamespace() string

func (*TFCTrigger) GetTriggerSource added in v0.1.6

func (t *TFCTrigger) GetTriggerSource() TriggerSource

func (*TFCTrigger) GetVcsProvider added in v0.1.6

func (t *TFCTrigger) GetVcsProvider() string

func (*TFCTrigger) GetWorkspace added in v0.1.6

func (t *TFCTrigger) GetWorkspace() string

func (*TFCTrigger) LockUnlockWorkspace

func (t *TFCTrigger) LockUnlockWorkspace(ws *tfe.Workspace, mr vcs.DetailedMR, lock bool) error

func (*TFCTrigger) SetMergeRequestDiscussionID added in v0.1.6

func (t *TFCTrigger) SetMergeRequestDiscussionID(mrDiscID string)

func (*TFCTrigger) SetMergeRequestRootNoteID added in v0.1.6

func (t *TFCTrigger) SetMergeRequestRootNoteID(id int64)

func (*TFCTrigger) TriggerCleanupEvent

func (t *TFCTrigger) TriggerCleanupEvent(ctx context.Context) error

func (*TFCTrigger) TriggerTFCEvents

func (t *TFCTrigger) TriggerTFCEvents(ctx context.Context) (*TriggeredTFCWorkspaces, error)

type TFCTriggerOptions added in v0.1.6

type TFCTriggerOptions struct {
	Action                   TriggerAction
	Branch                   string
	CommitSHA                string
	ProjectNameWithNamespace string
	MergeRequestIID          int
	MergeRequestDiscussionID string
	MergeRequestRootNoteID   int64
	TriggerSource            TriggerSource
	VcsProvider              string
	Workspace                string `short:"w" long:"workspace" description:"A specific terraform Workspace to use" required:"false"`
	TFVersion                string `short:"v" long:"tf_version" description:"A specific terraform version to use" required:"false"`
	Target                   string `short:"t" long:"target" description:"A specific terraform target to use" required:"false"`
	AllowEmptyRun            bool   `short:"e" long:"allow_empty_run" description:"A specific terraform AllowEmptyRun" required:"false"`
}

func NewTFCTriggerConfig added in v0.1.6

func NewTFCTriggerConfig(opts *TFCTriggerOptions) (*TFCTriggerOptions, error)

type TFCWorkspace

type TFCWorkspace struct {
	Name         string   `yaml:"name" validate:"empty=false"`
	Organization string   `yaml:"organization" validate:"empty=false"`
	Dir          string   `yaml:"dir"`
	Mode         string   `yaml:"mode" default:"apply-before-merge" validate:"one_of=apply-before-merge,merge-before-apply,tfc-vcs-repo"`
	TriggerDirs  []string `yaml:"triggerDirs"`
	AutoMerge    bool     `yaml:"autoMerge" default:"true"`
}

func (*TFCWorkspace) UnmarshalYAML

func (s *TFCWorkspace) UnmarshalYAML(unmarshal func(interface{}) error) error

type Trigger

type Trigger interface {
	TriggerTFCEvents(context.Context) (*TriggeredTFCWorkspaces, error)
	TriggerCleanupEvent(context.Context) error
	GetAction() TriggerAction
	GetBranch() string
	GetCommitSHA() string
	GetProjectNameWithNamespace() string
	GetMergeRequestIID() int
	GetMergeRequestDiscussionID() string
	SetMergeRequestDiscussionID(mrdisID string)
	GetMergeRequestRootNoteID() int64
	SetMergeRequestRootNoteID(id int64)
	GetTriggerSource() TriggerSource
	GetWorkspace() string
	GetVcsProvider() string
}

func NewTFCTrigger

func NewTFCTrigger(
	gl vcs.GitClient,
	tfc tfc_api.ApiClient,
	runstream runstream.StreamClient,
	cfg *TFCTriggerOptions,
) Trigger

type TriggerAction

type TriggerAction int
const (
	ApplyAction TriggerAction = iota
	DestroyAction
	LockAction
	PlanAction
	RefreshAction
	UnlockAction
	InvalidAction
)

func CheckTriggerAction added in v0.1.6

func CheckTriggerAction(action string) TriggerAction

func (TriggerAction) String

func (a TriggerAction) String() string

type TriggerSource

type TriggerSource int
const (
	CommentTrigger TriggerSource = iota
	MergeRequestEventTrigger
)

type TriggeredTFCWorkspaces

type TriggeredTFCWorkspaces struct {
	Errored  []*ErroredWorkspace
	Executed []string
}

Jump to

Keyboard shortcuts

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