tfc_trigger

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: MPL-2.0 Imports: 20 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(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) GetConfig

func (t *TFCTrigger) GetConfig() TriggerConfig

func (*TFCTrigger) LockUnlockWorkspace

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

func (*TFCTrigger) TriggerCleanupEvent

func (t *TFCTrigger) TriggerCleanupEvent() error

func (*TFCTrigger) TriggerTFCEvents

func (t *TFCTrigger) TriggerTFCEvents() (*TriggeredTFCWorkspaces, error)

type TFCTriggerConfig

type TFCTriggerConfig struct {
	Action                   TriggerAction
	Branch                   string
	CommitSHA                string
	ProjectNameWithNamespace string
	MergeRequestIID          int
	MergeRequestDiscussionID string
	MergeRequestRootNoteID   int64
	TriggerSource            TriggerSource
	VcsProvider              string
	Workspace                string
}

func (*TFCTriggerConfig) GetAction

func (tC *TFCTriggerConfig) GetAction() TriggerAction

func (*TFCTriggerConfig) GetBranch

func (tC *TFCTriggerConfig) GetBranch() string

func (*TFCTriggerConfig) GetCommitSHA

func (tC *TFCTriggerConfig) GetCommitSHA() string

func (*TFCTriggerConfig) GetMergeRequestDiscussionID

func (tC *TFCTriggerConfig) GetMergeRequestDiscussionID() string

func (*TFCTriggerConfig) GetMergeRequestIID

func (tC *TFCTriggerConfig) GetMergeRequestIID() int

func (*TFCTriggerConfig) GetMergeRequestRootNoteID

func (tC *TFCTriggerConfig) GetMergeRequestRootNoteID() int64

func (*TFCTriggerConfig) GetProjectNameWithNamespace

func (tC *TFCTriggerConfig) GetProjectNameWithNamespace() string

func (*TFCTriggerConfig) GetTriggerSource

func (tC *TFCTriggerConfig) GetTriggerSource() TriggerSource

func (*TFCTriggerConfig) GetVcsProvider

func (tC *TFCTriggerConfig) GetVcsProvider() string

func (*TFCTriggerConfig) GetWorkspace

func (tC *TFCTriggerConfig) GetWorkspace() string

func (*TFCTriggerConfig) SetAction

func (tC *TFCTriggerConfig) SetAction(action TriggerAction)

func (*TFCTriggerConfig) SetMergeRequestDiscussionID

func (tC *TFCTriggerConfig) SetMergeRequestDiscussionID(mrDiscID string)

func (*TFCTriggerConfig) SetMergeRequestRootNoteID

func (tC *TFCTriggerConfig) SetMergeRequestRootNoteID(id int64)

func (*TFCTriggerConfig) SetWorkspace

func (tC *TFCTriggerConfig) SetWorkspace(workspace string)

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"`
}

func (*TFCWorkspace) UnmarshalYAML

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

type Trigger

type Trigger interface {
	TriggerTFCEvents() (*TriggeredTFCWorkspaces, error)
	GetConfig() TriggerConfig
	TriggerCleanupEvent() error
}

func NewTFCTrigger

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

type TriggerAction

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

func (TriggerAction) String

func (a TriggerAction) String() string

type TriggerConfig

type TriggerConfig interface {
	GetAction() TriggerAction
	SetAction(action TriggerAction)
	GetBranch() string
	GetCommitSHA() string
	GetProjectNameWithNamespace() string
	GetMergeRequestIID() int
	GetMergeRequestDiscussionID() string
	SetMergeRequestDiscussionID(mrdisID string)
	GetMergeRequestRootNoteID() int64
	SetMergeRequestRootNoteID(id int64)
	GetTriggerSource() TriggerSource
	GetWorkspace() string
	SetWorkspace(workspace string)
	GetVcsProvider() 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