run

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByStatus

func ByStatus(i, j *Run) int

ByStatus sorts runs according to the following order:

* Planning, Applying (most recent first) * Planned (most recent first) * PlanQueued,ApplyQueued (oldest first) * Scheduled (oldest first) * Pending (oldest first) * Applied,Errored,Canceled,Finished,NoChanges,Discarded (most recent first)

func ByUpdatedDesc

func ByUpdatedDesc(i, j *Run) int

func StartScheduler

func StartScheduler(ctx context.Context, runs *Service, workspaces *workspace.Service)

StartScheduler starts the run scheduler, which is responsible for ensuring there is at most one active run on each workspace at a time.

The scheduler attempts to schedule runs upon every run event it receives.

Types

type Change

type Change struct {
	Actions []ChangeAction
}

Change represents the type of change being made

type ChangeAction

type ChangeAction string
const (
	CreateAction ChangeAction = "create"
	UpdateAction ChangeAction = "update"
	DeleteAction ChangeAction = "delete"
)

type CreateOptions

type CreateOptions struct {
	TargetAddrs []state.ResourceAddress
	// contains filtered or unexported fields
}

type ListOptions

type ListOptions struct {
	// Filter runs by those that belong to the given ancestor, e.g. a module or workspace
	AncestorID resource.ID
	// Filter runs by status: match run if it has one of these statuses.
	Status []Status
	// Order runs by oldest first (true), or newest first (false)
	Oldest bool
}

type Report

type Report struct {
	Additions    int `json:"additions"`
	Changes      int `json:"changes"`
	Destructions int `json:"destructions"`
}

Report reports a summary of additions, changes, and deletions of resources in a plan or an apply.

func (Report) HasChanges

func (r Report) HasChanges() bool

func (Report) String

func (r Report) String() string

type ResourceChange

type ResourceChange struct {
	Change Change
}

ResourceChange represents a proposed change to a resource in a plan file

type Run

type Run struct {
	resource.Resource

	Created time.Time
	Updated time.Time

	Status      Status
	AutoApply   bool
	TargetAddrs []state.ResourceAddress

	PlanReport  Report
	ApplyReport Report

	// Error is non-nil when the run status is Errored
	Error error
	// contains filtered or unexported fields
}

func (*Run) IsFinished

func (r *Run) IsFinished() bool

func (*Run) LogValue

func (r *Run) LogValue() slog.Value

func (*Run) PlanArgs

func (r *Run) PlanArgs() []string

PlanArgs produces the arguments for terraform plan

func (*Run) PlanPath

func (r *Run) PlanPath() string

PlanPath is the path to the run's plan file, relative to the module's directory.

func (*Run) WorkspaceID

func (r *Run) WorkspaceID() resource.ID

type Service

type Service struct {
	Broker *pubsub.Broker[*Run]
	// contains filtered or unexported fields
}

func NewService

func NewService(opts ServiceOptions) *Service

func (*Service) Apply

func (s *Service) Apply(runID resource.ID) (*task.Task, error)

Apply creates an apply task for a run. The run must be in the planned state, and it must be the current run for its workspace.

func (*Service) Create

func (s *Service) Create(workspaceID resource.ID, opts CreateOptions) (*Run, error)

Create a run.

func (*Service) Delete

func (s *Service) Delete(id resource.ID) error

func (*Service) Get

func (s *Service) Get(runID resource.ID) (*Run, error)

func (*Service) List

func (s *Service) List(opts ListOptions) []*Run

func (*Service) Subscribe

func (s *Service) Subscribe(ctx context.Context) <-chan resource.Event[*Run]

type ServiceOptions

type ServiceOptions struct {
	TaskService             *task.Service
	ModuleService           *module.Service
	WorkspaceService        *workspace.Service
	StateService            *state.Service
	DisableReloadAfterApply bool
	Logger                  logging.Interface
}

type Status

type Status string
const (
	Pending     Status = "pending"
	Scheduled   Status = "scheduled"
	PlanQueued  Status = "plan queued"
	Planning    Status = "planning"
	Planned     Status = "planned"
	NoChanges   Status = "no changes"
	ApplyQueued Status = "apply queued"
	Applying    Status = "applying"
	Applied     Status = "applied"
	Errored     Status = "errored"
	Canceled    Status = "canceled"
	Discarded   Status = "discarded"

	MaxStatusLen = len(ApplyQueued)
)

Jump to

Keyboard shortcuts

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