Documentation
¶
Overview ¶
templ: version: v0.3.865
Package workspace provides access to terraform workspaces
Index ¶
- Constants
- Variables
- func NewCommand(apiClient *otfapi.Client) *cobra.Command
- func WorkspaceHeaderLinks(workspaceID resource.TfeID, canUpdate bool) templ.Component
- type CLI
- type Client
- func (c *Client) Get(ctx context.Context, workspaceID resource.TfeID) (*Workspace, error)
- func (c *Client) GetByName(ctx context.Context, organization organization.Name, workspace string) (*Workspace, error)
- func (c *Client) List(ctx context.Context, opts ListOptions) (*resource.Page[*Workspace], error)
- func (c *Client) Lock(ctx context.Context, workspaceID resource.TfeID, runID *resource.TfeID) (*Workspace, error)
- func (c *Client) Unlock(ctx context.Context, workspaceID resource.TfeID, runID *resource.TfeID, ...) (*Workspace, error)
- func (c *Client) Update(ctx context.Context, workspaceID resource.TfeID, opts UpdateOptions) (*Workspace, error)
- type ConnectOptions
- type Connection
- type CreateOptions
- type ExecutionMode
- type FakeService
- func (f *FakeService) AddTags(ctx context.Context, workspaceID resource.TfeID, tags []TagSpec) error
- func (f *FakeService) Create(context.Context, CreateOptions) (*Workspace, error)
- func (f *FakeService) Delete(context.Context, resource.TfeID) (*Workspace, error)
- func (f *FakeService) Get(context.Context, resource.TfeID) (*Workspace, error)
- func (f *FakeService) GetByName(context.Context, organization.Name, string) (*Workspace, error)
- func (f *FakeService) GetWorkspacePolicy(context.Context, resource.TfeID) (Policy, error)
- func (f *FakeService) List(ctx context.Context, opts ListOptions) (*resource.Page[*Workspace], error)
- func (f *FakeService) ListConnectedWorkspaces(ctx context.Context, vcsProviderID resource.TfeID, repoPath string) ([]*Workspace, error)
- func (f *FakeService) ListTags(context.Context, organization.Name, ListTagsOptions) (*resource.Page[*Tag], error)
- func (f *FakeService) Lock(context.Context, resource.TfeID, *resource.TfeID) (*Workspace, error)
- func (f *FakeService) RemoveTags(ctx context.Context, workspaceID resource.TfeID, tags []TagSpec) error
- func (f *FakeService) SetPermission(ctx context.Context, workspaceID, teamID resource.TfeID, role authz.Role) error
- func (f *FakeService) Unlock(context.Context, resource.TfeID, *resource.TfeID, bool) (*Workspace, error)
- func (f *FakeService) UnsetPermission(ctx context.Context, workspaceID, teamID resource.TfeID) error
- func (f *FakeService) Update(_ context.Context, _ resource.TfeID, opts UpdateOptions) (*Workspace, error)
- type LatestRun
- type ListOptions
- type ListTagsOptions
- type ListWorkspaceTagsOptions
- type Options
- type Permission
- type Policy
- type Service
- func (s *Service) AddHandlers(r *mux.Router)
- func (s *Service) AddTags(ctx context.Context, workspaceID resource.TfeID, tags []TagSpec) error
- func (s *Service) AfterCreateWorkspace(hook func(context.Context, *Workspace) error)
- func (s *Service) BeforeCreateWorkspace(hook func(context.Context, *Workspace) error)
- func (s *Service) BeforeUpdateWorkspace(hook func(context.Context, *Workspace) error)
- func (s *Service) Create(ctx context.Context, opts CreateOptions) (*Workspace, error)
- func (s *Service) Delete(ctx context.Context, workspaceID resource.TfeID) (*Workspace, error)
- func (s *Service) DeleteTags(ctx context.Context, organization organization.Name, tagIDs []resource.TfeID) error
- func (s *Service) Get(ctx context.Context, workspaceID resource.TfeID) (*Workspace, error)
- func (s *Service) GetByName(ctx context.Context, organization organization.Name, workspace string) (*Workspace, error)
- func (s *Service) GetWorkspacePolicy(ctx context.Context, workspaceID resource.TfeID) (Policy, error)
- func (s *Service) List(ctx context.Context, opts ListOptions) (*resource.Page[*Workspace], error)
- func (s *Service) ListConnectedWorkspaces(ctx context.Context, vcsProviderID resource.TfeID, repoPath string) ([]*Workspace, error)
- func (s *Service) ListTags(ctx context.Context, organization organization.Name, opts ListTagsOptions) (*resource.Page[*Tag], error)
- func (s *Service) ListWorkspaceTags(ctx context.Context, workspaceID resource.TfeID, opts ListWorkspaceTagsOptions) (*resource.Page[*Tag], error)
- func (s *Service) Lock(ctx context.Context, workspaceID resource.TfeID, runID *resource.TfeID) (*Workspace, error)
- func (f Service) NewWorkspace(ctx context.Context, opts CreateOptions) (*Workspace, error)
- func (s *Service) RemoveTags(ctx context.Context, workspaceID resource.TfeID, tags []TagSpec) error
- func (s *Service) SetLatestRun(ctx context.Context, workspaceID, runID resource.TfeID) (*Workspace, error)
- func (s *Service) SetPermission(ctx context.Context, workspaceID, teamID resource.TfeID, role authz.Role) error
- func (s *Service) TagWorkspaces(ctx context.Context, tagID resource.TfeID, workspaceIDs []resource.TfeID) error
- func (s *Service) Unlock(ctx context.Context, workspaceID resource.TfeID, runID *resource.TfeID, ...) (*Workspace, error)
- func (s *Service) UnsetPermission(ctx context.Context, workspaceID, teamID resource.TfeID) error
- func (s *Service) Update(ctx context.Context, workspaceID resource.TfeID, opts UpdateOptions) (*Workspace, error)
- func (s *Service) Watch(ctx context.Context) (<-chan pubsub.Event[*Workspace], func())
- type TFEOrganizationTag
- type TFERun
- type TFETag
- type TFEVCSRepo
- type TFEVCSRepoOptions
- type TFEWorkspace
- type TFEWorkspaceActions
- type TFEWorkspaceCreateOptions
- type TFEWorkspaceList
- type TFEWorkspaceListOptions
- type TFEWorkspaceOutput
- type TFEWorkspacePermissions
- type TFEWorkspaceUpdateOptions
- type Tag
- type TagSpec
- type TagSpecs
- type UpdateOptions
- type VCSRepoOptionsJSON
- type VCSTriggerStrategy
- type Version
- type Workspace
- func (ws *Workspace) Enlock(id resource.ID) error
- func (ws *Workspace) ExecutionModes() []string
- func (ws *Workspace) Locked() bool
- func (ws *Workspace) LogValue() slog.Value
- func (ws *Workspace) String() string
- func (ws *Workspace) Unlock(id resource.ID, force bool) error
- func (ws *Workspace) Update(opts UpdateOptions) (*bool, error)
Constants ¶
const ( // // VCS trigger strategies to present to the user. // // every vcs event trigger runs VCSTriggerAlways string = "always" // only vcs events with changed files matching a set of glob patterns // triggers run VCSTriggerPatterns string = "patterns" // only push tag vcs events trigger runs VCSTriggerTags string = "tags" )
Variables ¶
var ( ErrWorkspaceAlreadyLocked = errors.New("workspace already locked") ErrWorkspaceLockedByDifferentUser = errors.New("workspace locked by different user") ErrWorkspaceLockedByRun = errors.New("workspace is locked by Run") ErrWorkspaceAlreadyUnlocked = errors.New("workspace already unlocked") ErrWorkspaceUnlockDenied = errors.New("unauthorized to unlock workspace") ErrWorkspaceInvalidLock = errors.New("invalid workspace lock") ErrUnsupportedTerraformVersion = errors.New("unsupported terraform version") ErrTagsRegexAndTriggerPatterns = errors.New("cannot specify both tags-regex and trigger-patterns") ErrTagsRegexAndAlwaysTrigger = errors.New("cannot specify both tags-regex and always-trigger") ErrTriggerPatternsAndAlwaysTrigger = errors.New("cannot specify both trigger-patterns and always-trigger") ErrInvalidTriggerPattern = errors.New("invalid trigger glob pattern") ErrInvalidTagsRegex = errors.New("invalid vcs tags regular expression") ErrAgentExecutionModeWithoutPool = errors.New("agent execution mode requires agent pool ID") ErrNonAgentExecutionModeWithPool = errors.New("agent pool ID can only be specified with agent execution mode") )
var ErrInvalidTagSpec = errors.New("invalid tag spec: must provide either an ID or a name")
Functions ¶
Types ¶
type Client ¶
type ConnectOptions ¶
type Connection ¶ added in v0.1.4
type Connection struct {
// Pushes to this VCS branch trigger runs. Empty string means the default
// branch is used. Ignored if TagsRegex is non-empty.
Branch string
// Pushed tags matching this regular expression trigger runs. Mutually
// exclusive with TriggerPatterns.
TagsRegex string
VCSProviderID resource.TfeID
Repo string
// By default, once a workspace is connected to a repo it is not
// possible to run a terraform apply via the CLI. Setting this to true
// overrides this behaviour.
AllowCLIApply bool
}
type CreateOptions ¶
type CreateOptions struct {
AgentPoolID *resource.TfeID
AllowDestroyPlan *bool
AutoApply *bool
Description *string
ExecutionMode *ExecutionMode
GlobalRemoteState *bool
MigrationEnvironment *string
Name *string
QueueAllRuns *bool
SpeculativeEnabled *bool
SourceName *string
SourceURL *string
StructuredRunOutputEnabled *bool
Tags []TagSpec
Engine *engine.Engine
EngineVersion *Version
TriggerPrefixes []string
TriggerPatterns []string
WorkingDirectory *string
Organization *organization.Name
// Always trigger runs. A value of true is mutually exclusive with
// setting TriggerPatterns or ConnectOptions.TagsRegex.
AlwaysTrigger *bool
*ConnectOptions
}
CreateOptions represents the options for creating a new workspace.
type ExecutionMode ¶
type ExecutionMode string
const ( RemoteExecutionMode ExecutionMode = "remote" LocalExecutionMode ExecutionMode = "local" AgentExecutionMode ExecutionMode = "agent" DefaultAllowDestroyPlan = true )
func ExecutionModePtr ¶
func ExecutionModePtr(m ExecutionMode) *ExecutionMode
ExecutionModePtr returns a pointer to an execution mode.
type FakeService ¶ added in v0.2.2
func (*FakeService) Create ¶ added in v0.2.2
func (f *FakeService) Create(context.Context, CreateOptions) (*Workspace, error)
func (*FakeService) GetByName ¶ added in v0.2.2
func (f *FakeService) GetByName(context.Context, organization.Name, string) (*Workspace, error)
func (*FakeService) GetWorkspacePolicy ¶ added in v0.3.6
func (*FakeService) List ¶ added in v0.2.2
func (f *FakeService) List(ctx context.Context, opts ListOptions) (*resource.Page[*Workspace], error)
func (*FakeService) ListConnectedWorkspaces ¶ added in v0.2.2
func (*FakeService) ListTags ¶ added in v0.2.2
func (f *FakeService) ListTags(context.Context, organization.Name, ListTagsOptions) (*resource.Page[*Tag], error)
func (*FakeService) RemoveTags ¶ added in v0.2.2
func (*FakeService) SetPermission ¶ added in v0.2.2
func (*FakeService) UnsetPermission ¶ added in v0.2.2
func (*FakeService) Update ¶ added in v0.2.2
func (f *FakeService) Update(_ context.Context, _ resource.TfeID, opts UpdateOptions) (*Workspace, error)
type ListOptions ¶
type ListOptions struct {
Search string `schema:"search[name]"`
Tags []string `schema:"search[tags]"`
Status []runstatus.Status `schema:"search[status]"`
Organization *organization.Name `schema:"organization_name"`
resource.PageOptions
}
ListOptions are options for paginating and filtering a list of Workspaces
type ListTagsOptions ¶
type ListTagsOptions struct {
resource.PageOptions
}
ListTagsOptions are options for paginating and filtering a list of tags
type ListWorkspaceTagsOptions ¶
type ListWorkspaceTagsOptions struct {
resource.PageOptions
}
ListWorkspaceTagsOptions are options for paginating and filtering a list of workspace tags
type Options ¶
type Options struct {
*sql.DB
*sql.Listener
*tfeapi.Responder
*authz.Authorizer
logr.Logger
OrganizationService *organization.Service
VCSProviderService *vcsprovider.Service
TeamService *team.Service
UserService *user.Service
ConnectionService *connections.Service
DefaultEngine *engine.Engine
EngineService *engine.Service
}
type Permission ¶ added in v0.3.17
Permission binds a role to a team.
type Policy ¶ added in v0.3.17
type Policy struct {
Permissions []Permission
// contains filtered or unexported fields
}
type Service ¶
type Service struct {
logr.Logger
*authz.Authorizer
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) AddHandlers ¶ added in v0.2.2
func (*Service) AfterCreateWorkspace ¶ added in v0.1.8
func (*Service) BeforeCreateWorkspace ¶ added in v0.2.0
func (*Service) BeforeUpdateWorkspace ¶ added in v0.2.0
func (*Service) DeleteTags ¶ added in v0.2.2
func (*Service) GetWorkspacePolicy ¶ added in v0.3.6
func (s *Service) GetWorkspacePolicy(ctx context.Context, workspaceID resource.TfeID) (Policy, error)
GetWorkspacePolicy retrieves the authorization policy for a workspace.
NOTE: there is no auth because it is used in the process of making an auth decision.
func (*Service) ListConnectedWorkspaces ¶ added in v0.1.14
func (*Service) ListTags ¶ added in v0.2.2
func (s *Service) ListTags(ctx context.Context, organization organization.Name, opts ListTagsOptions) (*resource.Page[*Tag], error)
func (*Service) ListWorkspaceTags ¶ added in v0.2.2
func (*Service) Lock ¶ added in v0.2.2
func (s *Service) Lock(ctx context.Context, workspaceID resource.TfeID, runID *resource.TfeID) (*Workspace, error)
Lock locks the workspace. A workspace can only be locked on behalf of a run or a user. If the former then runID must be populated. Otherwise a user is extracted from the context.
func (Service) NewWorkspace ¶ added in v0.3.20
func (f Service) NewWorkspace(ctx context.Context, opts CreateOptions) (*Workspace, error)
func (*Service) RemoveTags ¶ added in v0.2.2
func (*Service) SetLatestRun ¶ added in v0.3.10
func (s *Service) SetLatestRun(ctx context.Context, workspaceID, runID resource.TfeID) (*Workspace, error)
SetLatestRun sets the latest run for the workspace
func (*Service) SetPermission ¶ added in v0.2.2
func (*Service) TagWorkspaces ¶ added in v0.2.2
func (*Service) Unlock ¶ added in v0.2.2
func (s *Service) Unlock(ctx context.Context, workspaceID resource.TfeID, runID *resource.TfeID, force bool) (*Workspace, error)
Unlock unlocks the workspace. A workspace can only be unlocked on behalf of a run or a user. If the former then runID must be non-nil; otherwise a user is extracted from the context.
func (*Service) UnsetPermission ¶ added in v0.2.2
type TFEOrganizationTag ¶ added in v0.3.17
type TFEOrganizationTag struct {
ID resource.TfeID `jsonapi:"primary,tags"`
// Optional:
Name string `jsonapi:"attribute" json:"name,omitempty"`
// Optional: Number of workspaces that have this tag
InstanceCount int `jsonapi:"attribute" json:"instance-count,omitempty"`
// The org this tag belongs to
Organization *organization.TFEOrganization `jsonapi:"relationship" json:"organization"`
}
TFEOrganizationTag represents a Terraform Enterprise Organization tag
type TFETag ¶ added in v0.3.17
type TFETag struct {
ID *resource.TfeID `jsonapi:"primary,tags"`
Name string `jsonapi:"attribute" json:"name,omitempty"`
}
Tag is owned by an organization and applied to workspaces. Used for grouping and search. Only one of ID or name must be specified.
func (*TFETag) UnmarshalID ¶ added in v0.3.17
UnmarshalID helps datadog/jsonapi to unmarshal the ID in a serialized tag - either the ID or the name is set, and datadog/jsonapi otherwise gets upset when ID is unset.
type TFEVCSRepo ¶ added in v0.3.17
type TFEVCSRepo struct {
Branch string `json:"branch"`
DisplayIdentifier string `json:"display-identifier"`
Identifier string `json:"identifier"`
IngressSubmodules bool `json:"ingress-submodules"`
OAuthTokenID resource.TfeID `json:"oauth-token-id"`
RepositoryHTTPURL string `json:"repository-http-url"`
TagsRegex string `json:"tags-regex"`
ServiceProvider string `json:"service-provider"`
}
TFEVCSRepo contains the configuration of a VCS integration.
type TFEVCSRepoOptions ¶ added in v0.3.17
type TFEVCSRepoOptions struct {
Branch *string `json:"branch,omitempty"`
Identifier *string `json:"identifier,omitempty"`
IngressSubmodules *bool `json:"ingress-submodules,omitempty"`
OAuthTokenID *resource.TfeID `json:"oauth-token-id,omitempty"`
TagsRegex *string `json:"tags-regex,omitempty"`
}
TFEVCSRepoOptions is used by workspaces, policy sets, and registry modules TFEVCSRepoOptions represents the configuration options of a VCS integration.
type TFEWorkspace ¶ added in v0.3.17
type TFEWorkspace struct {
ID resource.TfeID `jsonapi:"primary,workspaces"`
Actions *TFEWorkspaceActions `jsonapi:"attribute" json:"actions"`
AgentPoolID *resource.TfeID `jsonapi:"attribute" json:"agent-pool-id"`
AllowDestroyPlan bool `jsonapi:"attribute" json:"allow-destroy-plan"`
AutoApply bool `jsonapi:"attribute" json:"auto-apply"`
CanQueueDestroyPlan bool `jsonapi:"attribute" json:"can-queue-destroy-plan"`
CreatedAt time.Time `jsonapi:"attribute" json:"created-at"`
Description string `jsonapi:"attribute" json:"description"`
Environment string `jsonapi:"attribute" json:"environment"`
ExecutionMode string `jsonapi:"attribute" json:"execution-mode"`
FileTriggersEnabled bool `jsonapi:"attribute" json:"file-triggers-enabled"`
GlobalRemoteState bool `jsonapi:"attribute" json:"global-remote-state"`
Locked bool `jsonapi:"attribute" json:"locked"`
MigrationEnvironment string `jsonapi:"attribute" json:"migration-environment"`
Name string `jsonapi:"attribute" json:"name"`
Operations bool `jsonapi:"attribute" json:"operations"`
Permissions *TFEWorkspacePermissions `jsonapi:"attribute" json:"permissions"`
QueueAllRuns bool `jsonapi:"attribute" json:"queue-all-runs"`
SpeculativeEnabled bool `jsonapi:"attribute" json:"speculative-enabled"`
SourceName string `jsonapi:"attribute" json:"source-name"`
SourceURL string `jsonapi:"attribute" json:"source-url"`
StructuredRunOutputEnabled bool `jsonapi:"attribute" json:"structured-run-output-enabled"`
TerraformVersion *Version `jsonapi:"attribute" json:"terraform-version"`
TriggerPrefixes []string `jsonapi:"attribute" json:"trigger-prefixes"`
TriggerPatterns []string `jsonapi:"attribute" json:"trigger-patterns"`
VCSRepo *TFEVCSRepo `jsonapi:"attribute" json:"vcs-repo"`
WorkingDirectory string `jsonapi:"attribute" json:"working-directory"`
UpdatedAt time.Time `jsonapi:"attribute" json:"updated-at"`
ResourceCount int `jsonapi:"attribute" json:"resource-count"`
ApplyDurationAverage time.Duration `jsonapi:"attribute" json:"apply-duration-average"`
PlanDurationAverage time.Duration `jsonapi:"attribute" json:"plan-duration-average"`
PolicyCheckFailures int `jsonapi:"attribute" json:"policy-check-failures"`
RunFailures int `jsonapi:"attribute" json:"run-failures"`
RunsCount int `jsonapi:"attribute" json:"workspace-kpis-runs-count"`
TagNames []string `jsonapi:"attribute" json:"tag-names"`
// Relations
CurrentRun *TFERun `jsonapi:"relationship" json:"current-run"`
Organization *organization.TFEOrganization `jsonapi:"relationship" json:"organization"`
Outputs []*TFEWorkspaceOutput `jsonapi:"relationship" json:"outputs"`
}
TFEWorkspace represents a Terraform Enterprise workspace.
func ToTFE ¶ added in v0.3.17
func ToTFE(a *authz.Authorizer, from *Workspace, r *http.Request) (*TFEWorkspace, error)
ToTFE converts an OTF workspace to a TFE workspace.
type TFEWorkspaceActions ¶ added in v0.3.17
type TFEWorkspaceActions struct {
IsDestroyable bool `json:"is-destroyable"`
}
TFEWorkspaceActions represents the workspace actions.
type TFEWorkspaceCreateOptions ¶ added in v0.3.17
type TFEWorkspaceCreateOptions struct {
// Type is a public field utilized by JSON:API to set the resource type via
// the field tag. It is not a user-defined value and does not need to be
// set. https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,workspaces"`
// Required when execution-mode is set to agent. The ID of the agent pool
// belonging to the workspace's organization. This value must not be
// specified if execution-mode is set to remote or local or if operations is
// set to true.
AgentPoolID *resource.TfeID `jsonapi:"attribute" json:"agent-pool-id,omitempty"`
// Whether destroy plans can be queued on the workspace.
AllowDestroyPlan *bool `jsonapi:"attribute" json:"allow-destroy-plan,omitempty"`
// Whether to automatically apply changes when a Terraform plan is successful.
AutoApply *bool `jsonapi:"attribute" json:"auto-apply,omitempty"`
// A description for the workspace.
Description *string `jsonapi:"attribute" json:"description,omitempty"`
// Which execution mode to use. Valid values are remote, local, and agent.
// When set to local, the workspace will be used for state storage only.
// This value must not be specified if operations is specified.
// 'agent' execution mode is not available in Terraform Enterprise.
ExecutionMode *string `jsonapi:"attribute" json:"execution-mode,omitempty"`
// Whether to filter runs based on the changed files in a VCS push. If
// enabled, the working directory and trigger prefixes describe a set of
// paths which must contain changes for a VCS push to trigger a run. If
// disabled, any push will trigger a run.
FileTriggersEnabled *bool `jsonapi:"attribute" json:"file-triggers-enabled,omitempty"`
GlobalRemoteState *bool `jsonapi:"attribute" json:"global-remote-state,omitempty"`
// The legacy TFE environment to use as the source of the migration, in the
// form organization/environment. Omit this unless you are migrating a legacy
// environment.
MigrationEnvironment *string `jsonapi:"attribute" json:"migration-environment,omitempty"`
// The name of the workspace, which can only include letters, numbers, -,
// and _. This will be used as an identifier and must be unique in the
// organization.
Name *string `jsonapi:"attribute" json:"name"`
// DEPRECATED. Whether the workspace will use remote or local execution mode.
// Use ExecutionMode instead.
Operations *bool `jsonapi:"attribute" json:"operations,omitempty"`
// Organization the workspace belongs to. Required.
Organization *organization.Name `schema:"organization_name"`
// Whether to queue all runs. Unless this is set to true, runs triggered by
// a webhook will not be queued until at least one run is manually queued.
QueueAllRuns *bool `jsonapi:"attribute" json:"queue-all-runs,omitempty"`
// Whether this workspace allows speculative plans. Setting this to false
// prevents Terraform Cloud or the Terraform Enterprise instance from
// running plans on pull requests, which can improve security if the VCS
// repository is public or includes untrusted contributors.
SpeculativeEnabled *bool `jsonapi:"attribute" json:"speculative-enabled,omitempty"`
// BETA. A friendly name for the application or client creating this
// workspace. If set, this will be displayed on the workspace as
// "Created via <SOURCE NAME>".
SourceName *string `jsonapi:"attribute" json:"source-name,omitempty"`
// BETA. A URL for the application or client creating this workspace. This
// can be the URL of a related resource in another app, or a link to
// documentation or other info about the client.
SourceURL *string `jsonapi:"attribute" json:"source-url,omitempty"`
// BETA. Enable the experimental advanced run user interface.
// This only applies to runs using Terraform version 0.15.2 or newer,
// and runs executed using older versions will see the classic experience
// regardless of this setting.
StructuredRunOutputEnabled *bool `jsonapi:"attribute" json:"structured-run-output-enabled,omitempty"`
// The version of Terraform to use for this workspace. Upon creating a
// workspace, the latest version is selected unless otherwise specified.
TerraformVersion *Version `jsonapi:"attribute" json:"terraform-version,omitempty" schema:"terraform_version"`
// List of repository-root-relative paths which list all locations to be
// tracked for changes. See FileTriggersEnabled above for more details.
TriggerPrefixes []string `jsonapi:"attribute" json:"trigger-prefixes,omitempty"`
// Optional: List of patterns used to match against changed files in order
// to decide whether to trigger a run or not.
TriggerPatterns []string `jsonapi:"attribute" json:"trigger-patterns,omitempty"`
// Settings for the workspace's VCS repository. If omitted, the workspace is
// created without a VCS repo. If included, you must specify at least the
// oauth-token-id and identifier keys below.
VCSRepo *TFEVCSRepoOptions `jsonapi:"attribute" json:"vcs-repo,omitempty"`
// A relative path that Terraform will execute within. This defaults to the
// root of your repository and is typically set to a subdirectory matching the
// environment when multiple environments exist within the same repository.
WorkingDirectory *string `jsonapi:"attribute" json:"working-directory,omitempty"`
// A list of tags to attach to the workspace. If the tag does not already
// exist, it is created and added to the workspace.
Tags []*TFETag `jsonapi:"relationship" json:"tags,omitempty"`
}
TFEWorkspaceCreateOptions represents the options for creating a new workspace.
type TFEWorkspaceList ¶ added in v0.3.17
type TFEWorkspaceList struct {
*types.Pagination
Items []*Workspace
}
TFEWorkspaceList represents a list of workspaces.
type TFEWorkspaceListOptions ¶ added in v0.3.17
type TFEWorkspaceListOptions struct {
types.ListOptions
// Optional: A search string (partial workspace name) used to filter the results.
Search string `schema:"search[name],omitempty"`
// Optional: A search string (comma-separated tag names) used to filter the results.
Tags string `schema:"search[tags],omitempty"`
// Optional: A search string (comma-separated tag names to exclude) used to filter the results.
ExcludeTags string `schema:"search[exclude-tags],omitempty"`
// Optional: A search on substring matching to filter the results.
WildcardName string `schema:"search[wildcard-name],omitempty"`
// Optional: A filter string to list all the workspaces linked to a given project id in the organization.
ProjectID resource.TfeID `schema:"filter[project][id],omitempty"`
}
TFEWorkspaceListOptions represents the options for listing workspaces.
type TFEWorkspaceOutput ¶ added in v0.3.17
type TFEWorkspacePermissions ¶ added in v0.3.17
type TFEWorkspacePermissions struct {
CanDestroy bool `json:"can-destroy"`
CanForceUnlock bool `json:"can-force-unlock"`
CanLock bool `json:"can-lock"`
CanQueueApply bool `json:"can-queue-apply"`
CanQueueDestroy bool `json:"can-queue-destroy"`
CanQueueRun bool `json:"can-queue-run"`
CanReadSettings bool `json:"can-read-settings"`
CanUnlock bool `json:"can-unlock"`
CanUpdate bool `json:"can-update"`
CanUpdateVariable bool `json:"can-update-variable"`
}
TFEWorkspacePermissions represents the workspace permissions.
type TFEWorkspaceUpdateOptions ¶ added in v0.3.17
type TFEWorkspaceUpdateOptions struct {
// Type is a public field utilized by JSON:API to set the resource type via
// the field tag. It is not a user-defined value and does not need to be
// set. https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,workspaces"`
// Required when execution-mode is set to agent. The ID of the agent pool
// belonging to the workspace's organization. This value must not be
// specified if execution-mode is set to remote or local or if operations is
// set to true.
AgentPoolID *resource.TfeID `jsonapi:"attribute" json:"agent-pool-id,omitempty"`
// Whether destroy plans can be queued on the workspace.
AllowDestroyPlan *bool `jsonapi:"attribute" json:"allow-destroy-plan,omitempty"`
// Whether to automatically apply changes when a Terraform plan is successful.
AutoApply *bool `jsonapi:"attribute" json:"auto-apply,omitempty"`
// A new name for the workspace, which can only include letters, numbers, -,
// and _. This will be used as an identifier and must be unique in the
// organization. Warning: Changing a workspace's name changes its URL in the
// API and UI.
Name *string `jsonapi:"attribute" json:"name,omitempty"`
// A description for the workspace.
Description *string `jsonapi:"attribute" json:"description,omitempty"`
// Which execution mode to use. Valid values are remote, local, and agent.
// When set to local, the workspace will be used for state storage only.
// This value must not be specified if operations is specified.
// 'agent' execution mode is not available in Terraform Enterprise.
ExecutionMode *string `jsonapi:"attribute" json:"execution-mode,omitempty" schema:"execution_mode"`
// Whether to filter runs based on the changed files in a VCS push. If
// enabled, the working directory and trigger prefixes describe a set of
// paths which must contain changes for a VCS push to trigger a run. If
// disabled, any push will trigger a run.
FileTriggersEnabled *bool `jsonapi:"attribute" json:"file-triggers-enabled,omitempty"`
GlobalRemoteState *bool `jsonapi:"attribute" json:"global-remote-state,omitempty"`
// DEPRECATED. Whether the workspace will use remote or local execution mode.
// Use ExecutionMode instead.
Operations *bool `jsonapi:"attribute" json:"operations,omitempty"`
// Whether to queue all runs. Unless this is set to true, runs triggered by
// a webhook will not be queued until at least one run is manually queued.
QueueAllRuns *bool `jsonapi:"attribute" json:"queue-all-runs,omitempty"`
// Whether this workspace allows speculative plans. Setting this to false
// prevents Terraform Cloud or the Terraform Enterprise instance from
// running plans on pull requests, which can improve security if the VCS
// repository is public or includes untrusted contributors.
SpeculativeEnabled *bool `jsonapi:"attribute" json:"speculative-enabled,omitempty"`
// BETA. Enable the experimental advanced run user interface.
// This only applies to runs using Terraform version 0.15.2 or newer,
// and runs executed using older versions will see the classic experience
// regardless of this setting.
StructuredRunOutputEnabled *bool `jsonapi:"attribute" json:"structured-run-output-enabled,omitempty"`
// The version of Terraform to use for this workspace.
TerraformVersion *Version `jsonapi:"attribute" json:"terraform-version,omitempty" schema:"terraform_version"`
// List of repository-root-relative paths which list all locations to be
// tracked for changes. See FileTriggersEnabled above for more details.
TriggerPrefixes []string `jsonapi:"attribute" json:"trigger-prefixes,omitempty"`
// Optional: List of patterns used to match against changed files in order
// to decide whether to trigger a run or not.
TriggerPatterns []string `jsonapi:"attribute" json:"trigger-patterns,omitempty"`
// To delete a workspace's existing VCS repo, specify null instead of an
// object. To modify a workspace's existing VCS repo, include whichever of
// the keys below you wish to modify. To add a new VCS repo to a workspace
// that didn't previously have one, include at least the oauth-token-id and
// identifier keys.
VCSRepo VCSRepoOptionsJSON `jsonapi:"attribute" json:"vcs-repo,omitempty"`
// A relative path that Terraform will execute within. This defaults to the
// root of your repository and is typically set to a subdirectory matching
// the environment when multiple environments exist within the same
// repository.
WorkingDirectory *string `jsonapi:"attribute" json:"working-directory,omitempty"`
}
TFEWorkspaceUpdateOptions represents the options for updating a workspace.
func (*TFEWorkspaceUpdateOptions) Validate ¶ added in v0.3.17
func (opts *TFEWorkspaceUpdateOptions) Validate() error
type Tag ¶
type Tag struct {
ID resource.TfeID // ID of the form 'tag-*'. Globally unique.
Name string // Meaningful symbol. Unique to an organization.
InstanceCount int // Number of workspaces that have this tag
Organization organization.Name // Organization this tag belongs to.
}
Tag is a symbol associated with one or more workspaces. Helps searching and grouping workspaces.
type UpdateOptions ¶
type UpdateOptions struct {
AgentPoolID *resource.TfeID `json:"agent-pool-id,omitempty"`
AllowDestroyPlan *bool
AutoApply *bool
Name *string
Description *string
ExecutionMode *ExecutionMode `json:"execution-mode,omitempty"`
GlobalRemoteState *bool
Operations *bool
QueueAllRuns *bool
SpeculativeEnabled *bool
StructuredRunOutputEnabled *bool
EngineVersion *Version
TriggerPrefixes []string
TriggerPatterns []string
WorkingDirectory *string
Engine *engine.Engine
// Always trigger runs. A value of true is mutually exclusive with
// setting TriggerPatterns or ConnectOptions.TagsRegex.
AlwaysTrigger *bool
// Disconnect workspace from repo. It is invalid to specify true for an
// already disconnected workspace.
Disconnect bool
// Specifying ConnectOptions either connects a currently
// disconnected workspace, or modifies a connection if already
// connected.
*ConnectOptions
}
type VCSRepoOptionsJSON ¶ added in v0.3.17
type VCSRepoOptionsJSON struct {
TFEVCSRepoOptions
Valid bool `json:"-"`
Set bool `json:"-"`
}
VCSRepoOptionsJSON wraps VCSRepoOptions and implements json.Unmarshaler in order to differentiate between VCSRepoOptions having been explicitly to null, and omitted.
NOTE: Credit to https://www.calhoun.io/how-to-determine-if-a-json-key-has-been-set-to-null-or-not-provided/
func (*VCSRepoOptionsJSON) UnmarshalJSON ¶ added in v0.3.17
func (o *VCSRepoOptionsJSON) UnmarshalJSON(data []byte) error
UnmarshalJSON differentiates between VCSRepoOptions having been explicitly set to null by the client, or the client has left it out.
type VCSTriggerStrategy ¶ added in v0.1.4
type VCSTriggerStrategy string
VCS trigger strategy determines which VCS events trigger runs
type Version ¶ added in v0.3.21
type Version struct {
// Latest if true means runs use the Latest available version at time of
// creation of the run.
Latest bool
// contains filtered or unexported fields
}
Version is a workspace's engine version.
func (*Version) MarshalText ¶ added in v0.3.21
func (*Version) UnmarshalText ¶ added in v0.3.21
type Workspace ¶
type Workspace struct {
ID resource.TfeID `jsonapi:"primary,workspaces"`
CreatedAt time.Time `jsonapi:"attribute" json:"created_at"`
UpdatedAt time.Time `jsonapi:"attribute" json:"updated_at"`
AgentPoolID *resource.TfeID `jsonapi:"attribute" json:"agent-pool-id"`
AllowDestroyPlan bool `jsonapi:"attribute" json:"allow_destroy_plan"`
AutoApply bool `jsonapi:"attribute" json:"auto_apply"`
CanQueueDestroyPlan bool `jsonapi:"attribute" json:"can_queue_destroy_plan"`
Description string `jsonapi:"attribute" json:"description"`
Environment string `jsonapi:"attribute" json:"environment"`
ExecutionMode ExecutionMode `jsonapi:"attribute" json:"execution_mode"`
GlobalRemoteState bool `jsonapi:"attribute" json:"global_remote_state"`
MigrationEnvironment string `jsonapi:"attribute" json:"migration_environment"`
Name string `jsonapi:"attribute" json:"name"`
QueueAllRuns bool `jsonapi:"attribute" json:"queue_all_runs"`
SpeculativeEnabled bool `jsonapi:"attribute" json:"speculative_enabled"`
StructuredRunOutputEnabled bool `jsonapi:"attribute" json:"structured_run_output_enabled"`
SourceName string `jsonapi:"attribute" json:"source_name"`
SourceURL string `jsonapi:"attribute" json:"source_url"`
WorkingDirectory string `jsonapi:"attribute" json:"working_directory"`
Organization organization.Name `jsonapi:"attribute" json:"organization"`
LatestRun *LatestRun `jsonapi:"attribute" json:"latest_run"`
Tags []string `jsonapi:"attribute" json:"tags"`
Lock resource.ID `json:"-"`
Engine *engine.Engine `jsonapi:"attribute" json:"engine"`
EngineVersion *Version `jsonapi:"attribute" json:"engine_version"`
// VCS Connection; nil means the workspace is not connected.
Connection *Connection
// TriggerPatterns is mutually exclusive with Connection.TagsRegex.
//
// Note: TriggerPatterns ought to belong in Connection but it is included at
// the root of Workspace because the go-tfe integration tests set
// this field without setting the connection!
TriggerPatterns []string
// TriggerPrefixes exists only to pass the go-tfe integration tests and
// is not used when determining whether to trigger runs. Use
// TriggerPatterns instead.
TriggerPrefixes []string
}
Workspace is a terraform workspace.
func NewTestWorkspace ¶ added in v0.3.20
func NewTestWorkspace(t *testing.T, opts *CreateOptions) *Workspace
func (*Workspace) Enlock ¶
Enlock locks the workspace with the given ID. The ID must be either a run or user ID.
func (*Workspace) ExecutionModes ¶
ExecutionModes returns a list of possible execution modes