workspace

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 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(modules moduleSubscription)

LoadWorkspacesUponModuleLoad automatically loads workspaces for a module whenever: * a new module is loaded into pug for the first time * an existing module is updated 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.Common

	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) ModulePath added in v0.2.0

func (ws *Workspace) ModulePath() string

func (*Workspace) String added in v0.2.0

func (ws *Workspace) String() string

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