workspace

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sort

func Sort(getter moduleGetter) func(*Workspace, *Workspace) int

Sort sorts workspaces accordingly:

1. first by their module path, lexicographically. 2. then, if module paths are equal, then by their workspace name, lexicographically

Types

type ListOptions

type ListOptions struct {
	// Filter by ID of workspace's module. If zero value then no filtering is
	// performed.
	ModuleID resource.ID
}

type Service

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

func NewService

func NewService(opts ServiceOptions) *Service

func (*Service) Create

func (s *Service) Create(path, name string) (*Workspace, *task.Task, error)

Create a workspace. Asynchronous.

func (*Service) Delete

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

Delete a workspace. Asynchronous.

func (*Service) Get

func (s *Service) Get(workspaceID resource.ID) (*Workspace, error)

func (*Service) GetByName

func (s *Service) GetByName(moduleID resource.ID, name string) (*Workspace, error)

func (*Service) List

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

func (*Service) LoadWorkspacesUponModuleLoad

func (s *Service) LoadWorkspacesUponModuleLoad(ms moduleSubscription)

LoadWorkspacesUponModuleLoad automatically loads workspaces for a module whenever: * a new module is loaded into pug for the first time, unless it is yet to be initialized (because `terraform workspace list` would fail) * an existing module is updated, has been initialized, and does not yet have a current workspace.

func (*Service) Reload

func (s *Service) Reload(moduleID resource.ID) (*task.Task, error)

Reload invokes `terraform workspace list` on a module and updates pug with the results, adding any newly discovered workspaces and pruning any workspaces no longer found to exist.

func (*Service) SelectWorkspace

func (s *Service) SelectWorkspace(moduleID, workspaceID resource.ID) error

SelectWorkspace runs the `terraform workspace select <workspace_name>` command, which sets the current workspace for the module. Once that's finished it then updates the current workspace in pug itself too.

func (*Service) SetCurrentRun

func (s *Service) SetCurrentRun(workspaceID, runID resource.ID) error

type ServiceOptions

type ServiceOptions struct {
	TaskService   *task.Service
	ModuleService *module.Service
	Logger        logging.Interface
}

type Workspace

type Workspace struct {
	resource.Resource

	Name string

	// The workspace's current or last active run.
	CurrentRunID *resource.ID

	AutoApply bool
}

func New

func New(mod *module.Module, name string) (*Workspace, error)

func (*Workspace) LogValue

func (ws *Workspace) LogValue() slog.Value

func (*Workspace) ModuleID

func (ws *Workspace) ModuleID() resource.ID

func (*Workspace) TerraformEnv

func (ws *Workspace) TerraformEnv() string

Jump to

Keyboard shortcuts

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