plan

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogKeyTFEWorkspace = "tfe_workspace"
	LogKeyTFERun       = "tfe_run"
)

Variables

This section is empty.

Functions

func FilesMatchAnyDirectory added in v0.4.3

func FilesMatchAnyDirectory(files []*pull.File, dirs []string) bool

FilesMatchAnyDirectory returns true if any file matches any of the given directories.

func FilesMatchDirectory added in v0.4.3

func FilesMatchDirectory(files []*pull.File, dir string) bool

FilesMatchDirectory returns true if any of the given files have a path prefixed by dir + "/".

Types

type ClientProvider

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

func NewClientProvider

func NewClientProvider(c ClientProviderConfig, middlewares ...githubapp.ClientMiddleware) (*ClientProvider, error)

func (*ClientProvider) Address

func (p *ClientProvider) Address() string

func (*ClientProvider) Client

func (p *ClientProvider) Client(org string) (*tfe.Client, error)

type ClientProviderConfig

type ClientProviderConfig struct {
	Address       string               `yaml:"address"`
	Organizations []OrganizationConfig `yaml:"organizations"`
}

func (*ClientProviderConfig) SetValuesFromEnv

func (c *ClientProviderConfig) SetValuesFromEnv()

type Comment added in v0.1.4

type Comment struct {
	Name    string `yaml:"name"`
	Content string `yaml:"content"`
}

type Config

type Config struct {
	Workspaces    []WorkspaceConfig `yaml:"workspaces"`
	ApprovalRules []*approval.Rule  `yaml:"approval_rules"`
	Comments      []Comment         `yaml:"comments"`
	// If changed files within a PR match any of these prefixes/directories,
	// then all relevant workspaces will be matched.
	TriggerPrefixes []string `yaml:"trigger_prefixes"`
	// contains filtered or unexported fields
}

func (*Config) ParseComments added in v0.1.4

func (c *Config) ParseComments() error

type Context

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

func NewContext

func NewContext(ctx context.Context, wkcfg WorkspaceConfig, prctx pull.Context, cfg *Config, statusCtx string, v3client *github.Client, tp *ClientProvider) (*Context, error)

func (*Context) Evaluate

func (pc *Context) Evaluate() Result

func (*Context) MonitorRun

func (pc *Context) MonitorRun(ctx context.Context, poster StatusPoster, runID string)

func (*Context) Trigger added in v0.2.0

func (pc *Context) Trigger() common.Trigger

type EvaluationStatus

type EvaluationStatus int
const (
	StatusSkipped EvaluationStatus = iota // note: values used for ordering
	StatusPolicyPending
	StatusPolicyDisapproved
	StatusPlanCreated
	StatusPlanPending
	StatusPlanDone
)

func (EvaluationStatus) String

func (s EvaluationStatus) String() string

type OrganizationConfig

type OrganizationConfig struct {
	Name  string `yaml:"name"`
	Token string `yaml:"token"`
}

type Result

type Result struct {
	StatusDescription string
	Status            EvaluationStatus

	Error error

	PolicyResult common.Result

	RunID string
}

type StatusPoster

type StatusPoster interface {
	PostStatus(ctx context.Context, prctx pull.Context, wkcfg WorkspaceConfig, runID string, client *github.Client, state, message string) error
}

type WorkspaceConfig

type WorkspaceConfig struct {
	Organization     string        `yaml:"organization"`
	Name             string        `yaml:"name"`
	WorkingDirectory string        `yaml:"working_directory"`
	Branch           string        `yaml:"branch"`
	Policy           policy.Policy `yaml:"policy"`
	Comment          string        `yaml:"comment"`
	ShowSkipped      bool          `yaml:"show_skipped"`
	// Allows the exclusion of this workspace from being considered when
	// evaluating Config.TriggerPrefixes
	SkipTriggerPrefixes bool `yaml:"skip_trigger_prefixes"`
}

func FilterRelevantWorkspaces added in v0.4.3

func FilterRelevantWorkspaces(cfg *Config, baseBranch string, defaultBranch string, changedFiles []*pull.File) []WorkspaceConfig

FilterRelevantWorkspaces returns only the workspaces whose branch and file paths match the pull request, avoiding unnecessary evaluation of workspaces that would be skipped by matchPR. This allows callers to pre-filter before spawning concurrent evaluations.

func (WorkspaceConfig) String

func (w WorkspaceConfig) String() string

Jump to

Keyboard shortcuts

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