workspace

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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PugDirectory

func PugDirectory(name string) string

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

func TerraformEnv

func TerraformEnv(name string) string

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 {
	// 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(ctx context.Context, 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

func (*Service) Subscribe

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

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) PugDirectory

func (ws *Workspace) PugDirectory() 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