workspace

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MPL-2.0 Imports: 20 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

func TerraformEnv

func TerraformEnv(workspaceName string) string

Types

type CostSummary added in v0.5.0

type CostSummary float64

func (CostSummary) String added in v0.5.0

func (c CostSummary) String() string

type ListOptions

type ListOptions struct {
	// Filter by ID of workspace's module.
	ModuleID *resource.ID
}

type ReloadSummary added in v0.5.0

type ReloadSummary struct {
	Added   []string
	Removed []string
}

func (ReloadSummary) LogValue added in v0.5.0

func (s ReloadSummary) LogValue() slog.Value

func (ReloadSummary) String added in v0.5.0

func (s ReloadSummary) String() string

type Service

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

func NewService

func NewService(opts ServiceOptions) *Service

func (Service) Cost added in v0.5.0

func (s Service) Cost(workspaceIDs ...resource.ID) (task.Spec, error)

Cost creates a task that retrieves a breakdown of the costs of the infrastructure deployed by the workspace.

func (*Service) Create

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

Create a workspace. Asynchronous.

func (*Service) Delete

func (s *Service) Delete(workspaceID resource.ID) (task.Spec, error)

Delete a workspace. Asynchronous.

func (*Service) Get

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

func (*Service) GetByName

func (s *Service) GetByName(modulePath, name string) (*Workspace, error)

func (*Service) List

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

func (*Service) LoadWorkspacesUponInit added in v0.5.0

func (s *Service) LoadWorkspacesUponInit(sub <-chan resource.Event[*task.Task])

LoadWorkspacesUponInit automatically loads workspaces for a module whenever it is successfully initialized and the module does not yet have a current workspace.

func (*Service) LoadWorkspacesUponModuleLoad

func (s *Service) LoadWorkspacesUponModuleLoad(sub <-chan resource.Event[*module.Module])

LoadWorkspacesUponModuleLoad automatically loads workspaces for a module loaded into pug.

func (Service) Reload

func (r Service) Reload(moduleID resource.ID) (task.Spec, error)

Reload returns a task spec that runs `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.

TODO: separate into Load and Reload

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.

type ServiceOptions

type ServiceOptions struct {
	Tasks   *task.Service
	Modules *module.Service
	Logger  logging.Interface
	DataDir string
	Workdir internal.Workdir
}

type Workspace

type Workspace struct {
	resource.ID

	Name       string
	ModuleID   resource.ID
	ModulePath string
	Cost       float64
}

func New

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

func (*Workspace) LogValue

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

func (*Workspace) String added in v0.2.0

func (ws *Workspace) String() string

func (*Workspace) TerraformEnv

func (ws *Workspace) TerraformEnv() string

func (*Workspace) VarsFile added in v0.5.0

func (ws *Workspace) VarsFile(workdir internal.Workdir) (string, bool)

VarsFile returns the filename of the workspace's terraform variables file and whether it exists or not.

Jump to

Keyboard shortcuts

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