workspace

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MPL-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package workspace provides access to terraform workspaces

Index

Constants

View Source
const (
	RemoteExecutionMode ExecutionMode = "remote"
	LocalExecutionMode  ExecutionMode = "local"
	AgentExecutionMode  ExecutionMode = "agent"

	DefaultAllowDestroyPlan    = true
	DefaultFileTriggersEnabled = true

	MinTerraformVersion     = "1.2.0"
	DefaultTerraformVersion = "1.3.7"
)

Variables

View Source
var (
	EventLocked   otf.EventType = "workspace_locked"
	EventUnlocked otf.EventType = "workspace_unlocked"
)

Functions

func NewService added in v0.0.32

func NewService(opts Options) *service

Types

type Client added in v0.0.32

type Client struct {
	otf.JSONAPIClient
}

func (*Client) GetWorkspace added in v0.0.32

func (c *Client) GetWorkspace(ctx context.Context, workspaceID string) (*Workspace, error)

GetWorkspace retrieves a workspace by its ID

func (*Client) GetWorkspaceByName added in v0.0.32

func (c *Client) GetWorkspaceByName(ctx context.Context, organization, workspace string) (*Workspace, error)

GetWorkspaceByName retrieves a workspace by organization and name.

func (*Client) ListWorkspaces added in v0.0.32

func (c *Client) ListWorkspaces(ctx context.Context, options ListOptions) (*WorkspaceList, error)

func (*Client) LockWorkspace added in v0.0.32

func (c *Client) LockWorkspace(ctx context.Context, workspaceID string, runID *string) (*Workspace, error)

func (*Client) UnlockWorkspace added in v0.0.32

func (c *Client) UnlockWorkspace(ctx context.Context, workspaceID string, runID *string, force bool) (*Workspace, error)

func (*Client) UpdateWorkspace added in v0.0.32

func (c *Client) UpdateWorkspace(ctx context.Context, workspaceID string, options UpdateOptions) (*Workspace, error)

UpdateWorkspace updates the settings of an existing workspace.

type ConnectOptions added in v0.0.32

type ConnectOptions struct {
	RepoPath      string `schema:"identifier,required"` // repo id: <owner>/<repo>
	VCSProviderID string `schema:"vcs_provider_id,required"`
}

type CreateOptions added in v0.0.32

type CreateOptions struct {
	AllowDestroyPlan           *bool
	AutoApply                  *bool
	Branch                     *string
	Description                *string
	ExecutionMode              *ExecutionMode
	FileTriggersEnabled        *bool
	GlobalRemoteState          *bool
	MigrationEnvironment       *string
	Name                       *string `schema:"name,required"`
	QueueAllRuns               *bool
	SpeculativeEnabled         *bool
	SourceName                 *string
	SourceURL                  *string
	StructuredRunOutputEnabled *bool
	TerraformVersion           *string
	TriggerPrefixes            []string
	WorkingDirectory           *string
	Organization               *string `schema:"organization_name,required"`

	*ConnectOptions
}

CreateOptions represents the options for creating a new workspace.

type ExecutionMode added in v0.0.32

type ExecutionMode string

func ExecutionModePtr added in v0.0.32

func ExecutionModePtr(m ExecutionMode) *ExecutionMode

ExecutionModePtr returns a pointer to an execution mode.

type ListOptions added in v0.0.32

type ListOptions struct {
	otf.ListOptions         // Pagination
	Prefix          string  `schema:"search[name],omitempty"`
	Organization    *string `schema:"organization_name,required"`
}

ListOptions are options for paginating and filtering a list of Workspaces

type LockButton added in v0.0.33

type LockButton struct {
	State    string // locked or unlocked
	Text     string // button text
	Tooltip  string // button tooltip
	Disabled bool   // button greyed out or not
	Action   string // form URL
}

type LockKind added in v0.0.33

type LockKind int

kind of entity holding a lock

const (
	UserLock LockKind = iota
	RunLock
)

type LockService added in v0.0.32

type LockService interface {
	LockWorkspace(ctx context.Context, workspaceID string, runID *string) (*Workspace, error)
	UnlockWorkspace(ctx context.Context, workspaceID string, runID *string, force bool) (*Workspace, error)
}

type OrganizationService added in v0.0.32

type OrganizationService organization.Service

type PermissionsService added in v0.0.32

type PermissionsService interface {
	GetPolicy(ctx context.Context, workspaceID string) (otf.WorkspacePolicy, error)

	SetPermission(ctx context.Context, workspaceID, team string, role rbac.Role) error
	UnsetPermission(ctx context.Context, workspaceID, team string) error
}

type QualifiedName added in v0.0.32

type QualifiedName struct {
	Organization string
	Name         string
}

QualifiedName is the workspace's fully qualified name including the name of its organization

type Service added in v0.0.32

type Service interface {
	CreateWorkspace(ctx context.Context, opts CreateOptions) (*Workspace, error)
	UpdateWorkspace(ctx context.Context, workspaceID string, opts UpdateOptions) (*Workspace, error)
	GetWorkspace(ctx context.Context, workspaceID string) (*Workspace, error)
	GetWorkspaceByName(ctx context.Context, organization, workspace string) (*Workspace, error)
	GetWorkspaceJSONAPI(ctx context.Context, workspaceID string, r *http.Request) (*jsonapi.Workspace, error)
	ListWorkspaces(ctx context.Context, opts ListOptions) (*WorkspaceList, error)
	// ListWorkspacesByWebhookID retrieves workspaces by webhook ID.
	//
	// TODO: rename to ListConnectedWorkspaces
	ListWorkspacesByRepoID(ctx context.Context, repoID uuid.UUID) ([]*Workspace, error)
	DeleteWorkspace(ctx context.Context, workspaceID string) (*Workspace, error)

	SetCurrentRun(ctx context.Context, workspaceID, runID string) (*Workspace, error)

	LockService
	PermissionsService
	// contains filtered or unexported methods
}

type UpdateOptions added in v0.0.32

type UpdateOptions struct {
	AllowDestroyPlan           *bool
	AutoApply                  *bool
	Name                       *string
	Description                *string
	ExecutionMode              *ExecutionMode `schema:"execution_mode"`
	FileTriggersEnabled        *bool
	GlobalRemoteState          *bool
	Operations                 *bool
	QueueAllRuns               *bool
	SpeculativeEnabled         *bool
	StructuredRunOutputEnabled *bool
	TerraformVersion           *string `schema:"terraform_version"`
	TriggerPrefixes            []string
	WorkingDirectory           *string
}

type VCSProviderService added in v0.0.32

type VCSProviderService vcsprovider.Service

type Workspace added in v0.0.32

type Workspace struct {
	ID                         string
	CreatedAt                  time.Time
	UpdatedAt                  time.Time
	AllowDestroyPlan           bool
	AutoApply                  bool
	Branch                     string
	CanQueueDestroyPlan        bool
	Description                string
	Environment                string
	ExecutionMode              ExecutionMode
	FileTriggersEnabled        bool
	GlobalRemoteState          bool
	MigrationEnvironment       string
	Name                       string
	QueueAllRuns               bool
	SpeculativeEnabled         bool
	StructuredRunOutputEnabled bool
	SourceName                 string
	SourceURL                  string
	TerraformVersion           string
	TriggerPrefixes            []string
	WorkingDirectory           string
	Organization               string
	LatestRunID                *string
	Connection                 *repo.Connection
	Permissions                []otf.WorkspacePermission
	// contains filtered or unexported fields
}

Workspace is a terraform workspace.

func NewWorkspace added in v0.0.32

func NewWorkspace(opts CreateOptions) (*Workspace, error)

func (*Workspace) ExecutionModes added in v0.0.32

func (ws *Workspace) ExecutionModes() []string

ExecutionModes returns a list of possible execution modes

func (*Workspace) Lock added in v0.0.33

func (ws *Workspace) Lock(id string, kind LockKind) error

Lock the workspace

func (*Workspace) Locked added in v0.0.33

func (ws *Workspace) Locked() bool

Locked determines whether workspace is locked.

func (*Workspace) MarshalLog added in v0.0.32

func (ws *Workspace) MarshalLog() any

func (*Workspace) QualifiedName added in v0.0.32

func (ws *Workspace) QualifiedName() QualifiedName

QualifiedName returns the workspace's qualified name including the name of its organization

func (*Workspace) String added in v0.0.32

func (ws *Workspace) String() string

func (*Workspace) Unlock added in v0.0.33

func (ws *Workspace) Unlock(id string, kind LockKind, force bool) error

Unlock the workspace.

func (*Workspace) Update added in v0.0.32

func (ws *Workspace) Update(opts UpdateOptions) error

Update updates the workspace with the given options.

type WorkspaceList added in v0.0.32

type WorkspaceList struct {
	*otf.Pagination
	Items []*Workspace
}

WorkspaceList is a list of workspaces.

type WorkspaceService added in v0.0.32

type WorkspaceService = Service

Jump to

Keyboard shortcuts

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