Documentation
¶
Overview ¶
Package otf is responsible for domain logic.
Index ¶
- Constants
- Variables
- func GenerateID(prefix string) string
- func GenerateRandomString(size int) string
- func GetChunk(p []byte, opts GetChunkOptions, complete bool) ([]byte, error)
- func Int(i int) *int
- func Int64(i int64) *int64
- func IsNotFound(err error) bool
- func NewBlobID() string
- func NewPagination(opts tfe.ListOptions, count int) *tfe.Pagination
- func SanitizeListOptions(opts *tfe.ListOptions)
- func String(str string) *string
- func TimeNow() *time.Time
- func UInt(i uint) *uint
- func Unpack(r io.Reader, dst string) error
- func UpdateOrganization(org *Organization, opts *tfe.OrganizationUpdateOptions) error
- type Apply
- type ApplyFinishOptions
- type ApplyService
- type BlobStore
- type Change
- type ChangeAction
- type ConfigurationVersion
- type ConfigurationVersionFactory
- type ConfigurationVersionGetOptions
- type ConfigurationVersionList
- type ConfigurationVersionListOptions
- type ConfigurationVersionService
- type ConfigurationVersionStore
- type Entitlements
- type ErrInvalidRunStatusTransition
- type ErrJobAlreadyStarted
- type Event
- type EventService
- type EventType
- type Executor
- type ExecutorFunc
- type GetChunkOptions
- type Job
- type JobFinishOptions
- type JobLogsUploader
- type JobService
- type JobStartOptions
- type JobWriter
- type Organization
- type OrganizationList
- type OrganizationService
- type OrganizationStore
- type Phase
- type Plan
- type PlanEnqueuer
- type PlanFile
- type PlanFinishOptions
- type PlanService
- type PutChunkOptions
- type Queue
- type ResourceChange
- type Run
- func (r *Run) Actions() *tfe.RunActions
- func (r *Run) ActivePhase() (Phase, error)
- func (r *Run) Cancel() error
- func (r *Run) Discard() error
- func (r *Run) Do(exe *Executor) error
- func (r *Run) Finish(bs BlobStore) (*Event, error)
- func (r *Run) ForceCancel() error
- func (r *Run) GetID() string
- func (r *Run) GetStatus() string
- func (r *Run) IsActive() bool
- func (r *Run) IsCancelable() bool
- func (r *Run) IsConfirmable() bool
- func (r *Run) IsDiscardable() bool
- func (r *Run) IsDone() bool
- func (r *Run) IsForceCancelable() bool
- func (r *Run) IsSpeculative() bool
- func (r *Run) Start() error
- func (r *Run) UpdateStatus(status tfe.RunStatus)
- type RunFactory
- type RunGetOptions
- type RunList
- type RunListOptions
- type RunService
- type RunStore
- type State
- type StateOutput
- type StateVersion
- type StateVersionFactory
- type StateVersionGetOptions
- type StateVersionList
- type StateVersionOutput
- type StateVersionOutputList
- type StateVersionService
- type StateVersionStore
- type Subscription
- type Workspace
- type WorkspaceList
- type WorkspaceListOptions
- type WorkspaceQueue
- type WorkspaceService
- type WorkspaceSpecifier
- type WorkspaceStore
Constants ¶
const ( // ChunkMaxLimit is maximum permissible size of a chunk ChunkMaxLimit = 65536 // ChunkStartMarker is the special byte that prefixes the first chunk ChunkStartMarker = byte(2) // ChunkEndMarker is the special byte that suffixes the last chunk ChunkEndMarker = byte(3) )
const ( DefaultAutoQueueRuns = true DefaultConfigurationSource = "tfe-api" )
const ( DefaultSessionTimeout = 20160 DefaultSessionExpiration = 20160 DefaultCollaboratorAuthPolicy = "password" DefaultCostEstimationEnabled = true )
const ( DefaultPageNumber = 1 DefaultPageSize = 20 MaxPageSize = 100 DefaultUserID = "user-123" DefaultUsername = "otf" )
const ( LocalStateFilename = "terraform.tfstate" PlanFilename = "plan.out" JSONPlanFilename = "plan.out.json" ApplyOutputFilename = "apply.out" )
const ( DefaultAllowDestroyPlan = true DefaultFileTriggersEnabled = true DefaultTerraformVersion = "0.15.4" DefaultExecutionMode = "remote" )
const ( // DefaultRefresh specifies that the state be refreshed prior to running a // plan DefaultRefresh = true )
Variables ¶
var ( ErrRunDiscardNotAllowed = errors.New("run was not paused for confirmation or priority; discard not allowed") ErrRunCancelNotAllowed = errors.New("run was not planning or applying; cancel not allowed") ErrRunForceCancelNotAllowed = errors.New("run was not planning or applying, has not been canceled non-forcefully, or the cool-off period has not yet passed") ErrInvalidRunGetOptions = errors.New("invalid run get options") // ActiveRunStatuses are those run statuses that deem a run to be active. // There can only be at most one active run for a workspace. ActiveRunStatuses = []tfe.RunStatus{ tfe.RunApplyQueued, tfe.RunApplying, tfe.RunConfirmed, tfe.RunPlanQueued, tfe.RunPlanned, tfe.RunPlanning, } )
var ( Version = "unknown" Commit = "unknown" )
var ( ErrWorkspaceAlreadyLocked = errors.New("workspace already locked") ErrWorkspaceAlreadyUnlocked = errors.New("workspace already unlocked") ErrInvalidWorkspaceSpecifier = errors.New("invalid workspace specifier options") )
var ( DefaultOrganizationPermissions = tfe.OrganizationPermissions{ CanCreateWorkspace: true, CanUpdate: true, CanDestroy: true, } )
var (
ErrInvalidConfigurationVersionGetOptions = errors.New("invalid configuration version get options")
)
var (
ErrInvalidStateVersionGetOptions = errors.New("invalid state version get options")
)
Functions ¶
func GenerateID ¶
GenerateID generates a unique identifier with the given prefix
func GenerateRandomString ¶
GenerateRandomString generates a random string composed of alphanumeric characters of length size.
func GetChunk ¶
func GetChunk(p []byte, opts GetChunkOptions, complete bool) ([]byte, error)
GetChunk retrieves a chunk of bytes from a byte slice. The first chunk in the slice is prefixed with a special byte. If complete is true then the last chunk in the slice is suffixed with a special byte.
func IsNotFound ¶
func NewPagination ¶
func NewPagination(opts tfe.ListOptions, count int) *tfe.Pagination
NewPagination constructs a Pagination obj.
func SanitizeListOptions ¶
func SanitizeListOptions(opts *tfe.ListOptions)
SanitizeListOptions ensures list options adhere to mins and maxs
func UpdateOrganization ¶
func UpdateOrganization(org *Organization, opts *tfe.OrganizationUpdateOptions) error
Types ¶
type Apply ¶
type Apply struct {
ID string
gorm.Model
ResourceAdditions int
ResourceChanges int
ResourceDestructions int
Status tfe.ApplyStatus
StatusTimestamps *tfe.ApplyStatusTimestamps
// Logs is the blob ID for the log output from a terraform apply
LogsBlobID string
}
func (*Apply) GetLogsBlobID ¶
func (*Apply) UpdateResources ¶
UpdateResources parses the output from terraform apply to determine the number and type of resource changes applied and updates the apply object accordingly.
func (*Apply) UpdateStatus ¶
func (a *Apply) UpdateStatus(status tfe.ApplyStatus)
type ApplyFinishOptions ¶
type ApplyFinishOptions 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,applies"`
ResourceAdditions int `jsonapi:"attr,resource-additions"`
ResourceChanges int `jsonapi:"attr,resource-changes"`
ResourceDestructions int `jsonapi:"attr,resource-destructions"`
}
ApplyFinishOptions represents the options for finishing an apply.
type ApplyService ¶
type BlobStore ¶
type BlobStore interface {
// Get fetches a blob
Get(string) ([]byte, error)
// Get fetches a blob chunk
GetChunk(string, GetChunkOptions) ([]byte, error)
// Put uploads a blob
Put(string, []byte) error
// Put uploads a blob chunk
PutChunk(string, []byte, PutChunkOptions) error
}
BlobStore implementations provide a persistent store from and to which binary objects can be fetched and uploaded.
type Change ¶
type Change struct {
Actions []ChangeAction
}
Change represents the type of change being made
type ChangeAction ¶
type ChangeAction string
const ( CreateAction ChangeAction = "create" UpdateAction ChangeAction = "update" DeleteAction ChangeAction = "delete" )
type ConfigurationVersion ¶
type ConfigurationVersion struct {
ID string
gorm.Model
AutoQueueRuns bool
Error string
ErrorMessage string
Source tfe.ConfigurationSource
Speculative bool
Status tfe.ConfigurationStatus
StatusTimestamps *tfe.CVStatusTimestamps
// BlobID is the ID of the blob containing the configuration
BlobID string
// Configuration Version belongs to a Workspace
Workspace *Workspace
}
ConfigurationVersion is a representation of an uploaded or ingressed Terraform configuration in TFE. A workspace must have at least one configuration version before any runs may be queued on it.
type ConfigurationVersionFactory ¶
type ConfigurationVersionFactory struct {
WorkspaceService WorkspaceService
}
ConfigurationVersionFactory creates ConfigurationVersion objects
func (*ConfigurationVersionFactory) NewConfigurationVersion ¶
func (f *ConfigurationVersionFactory) NewConfigurationVersion(workspaceID string, opts *tfe.ConfigurationVersionCreateOptions) (*ConfigurationVersion, error)
NewConfigurationVersion creates a ConfigurationVersion object from scratch
type ConfigurationVersionGetOptions ¶
type ConfigurationVersionGetOptions struct {
// ID of config version to retrieve
ID *string
// Get latest config version for this workspace ID
WorkspaceID *string
}
ConfigurationVersionGetOptions are options for retrieving a single config version. Either ID *or* WorkspaceID must be specfiied.
type ConfigurationVersionList ¶
type ConfigurationVersionList struct {
*tfe.Pagination
Items []*ConfigurationVersion
}
ConfigurationVersionList represents a list of configuration versions.
type ConfigurationVersionListOptions ¶
type ConfigurationVersionListOptions struct {
tfe.ListOptions
// Filter by run statuses (with an implicit OR condition)
Statuses []tfe.ConfigurationStatus
// Filter by workspace ID
WorkspaceID *string
}
ConfigurationVersionListOptions are options for paginating and filtering a list of configuration versions
type ConfigurationVersionService ¶
type ConfigurationVersionService interface {
Create(workspaceID string, opts *tfe.ConfigurationVersionCreateOptions) (*ConfigurationVersion, error)
Get(id string) (*ConfigurationVersion, error)
GetLatest(workspaceID string) (*ConfigurationVersion, error)
List(workspaceID string, opts tfe.ConfigurationVersionListOptions) (*ConfigurationVersionList, error)
Upload(id string, payload []byte) error
Download(id string) ([]byte, error)
}
type ConfigurationVersionStore ¶
type ConfigurationVersionStore interface {
Create(run *ConfigurationVersion) (*ConfigurationVersion, error)
Get(opts ConfigurationVersionGetOptions) (*ConfigurationVersion, error)
List(workspaceID string, opts ConfigurationVersionListOptions) (*ConfigurationVersionList, error)
Update(id string, fn func(*ConfigurationVersion) error) (*ConfigurationVersion, error)
}
type Entitlements ¶
type Entitlements struct {
*tfe.Entitlements
}
Entitlements represents the entitlements of an organization. Unlike TFE/TFC, OTF is free and therefore the user is entitled to all currently supported services.
func DefaultEntitlements ¶
func DefaultEntitlements(organizationID string) *Entitlements
DefaultEntitlements constructs an Entitlements struct with currently supported entitlements.
type ErrInvalidRunStatusTransition ¶
func (ErrInvalidRunStatusTransition) Error ¶
func (e ErrInvalidRunStatusTransition) Error() string
type ErrJobAlreadyStarted ¶
type ErrJobAlreadyStarted error
type EventService ¶
type EventService interface {
Publish(Event)
Subscribe(id string) Subscription
}
type EventType ¶
type EventType string
const ( OrganizationCreated EventType = "organization_created" OrganizationDeleted EventType = "organization_deleted" WorkspaceCreated EventType = "workspace_created" WorkspaceDeleted EventType = "workspace_deleted" RunCreated EventType = "run_created" RunCompleted EventType = "run_completed" RunCanceled EventType = "run_canceled" RunApplied EventType = "run_applied" RunPlanned EventType = "run_planned" RunPlannedAndFinished EventType = "run_planned_and_finished" PlanQueued EventType = "plan_queued" ApplyQueued EventType = "apply_queued" )
type Executor ¶
type Executor struct {
JobService
RunService RunService
ConfigurationVersionService ConfigurationVersionService
StateVersionService StateVersionService
// Current working directory
Path string
// logger
logr.Logger
// contains filtered or unexported fields
}
Executor executes a job, providing it with services, temp directory etc, capturing its stdout
func NewExecutor ¶
func NewExecutor(logger logr.Logger, rs RunService, cvs ConfigurationVersionService, svs StateVersionService, agentID string) (*Executor, error)
NewExecutor constructs an Executor.
func (*Executor) Cancel ¶
Cancel terminates execution. Force controls whether termination is graceful or not. Performed on a best-effort basis - the func or process may have finished before they are cancelled, in which case only the next func or process will be stopped from executing.
func (*Executor) Execute ¶
Execute performs the full lifecycle of executing a job: marking it as started, running the job, and then marking it as finished. Its logs are captured and forwarded.
func (*Executor) RunFunc ¶
func (e *Executor) RunFunc(fn ExecutorFunc) error
RunFunc invokes a func in the executor.
type ExecutorFunc ¶
ExecutorFunc is a func that can be invoked in the executor
type GetChunkOptions ¶
type Job ¶
type Job interface {
// GetID gets the ID of the job
GetID() string
// GetStatus gets the status of the job
GetStatus() string
// Do does the piece of work in an execution environment
Do(*Executor) error
}
Job represents a piece of work to be done
type JobFinishOptions ¶
type JobFinishOptions struct {
Errored bool
}
type JobLogsUploader ¶
type JobLogsUploader interface {
// UploadLogs uploads a chunk of output from the job.
UploadLogs(id string, logs []byte, opts PutChunkOptions) error
}
type JobService ¶
type JobService interface {
// Start is called by an agent when it starts a job. ErrJobAlreadyStarted
// should be returned if another agent has already started it.
Start(id string, opts JobStartOptions) (Job, error)
// Finish is called by an agent when it finishes a job.
Finish(id string, opts JobFinishOptions) (Job, error)
JobLogsUploader
}
type JobStartOptions ¶
type JobStartOptions struct {
AgentID string
}
type JobWriter ¶
type JobWriter struct {
// JobLogsUploader uploads a chunk of logs to the server
JobLogsUploader
// ID of job
ID string
logr.Logger
}
JobWriter writes logs on behalf of a job.
type Organization ¶
type Organization struct {
ID string
gorm.Model
Name string
CollaboratorAuthPolicy tfe.AuthPolicyType
CostEstimationEnabled bool
Email string
OwnersTeamSAMLRoleID string
Permissions *tfe.OrganizationPermissions
SAMLEnabled bool
SessionRemember int
SessionTimeout int
TrialExpiresAt time.Time
TwoFactorConformant bool
}
Organization represents a Terraform Enterprise organization.
func NewOrganization ¶
func NewOrganization(opts *tfe.OrganizationCreateOptions) (*Organization, error)
type OrganizationList ¶
type OrganizationList struct {
*tfe.Pagination
Items []*Organization
}
OrganizationList represents a list of Organizations.
type OrganizationService ¶
type OrganizationService interface {
Create(opts *tfe.OrganizationCreateOptions) (*Organization, error)
Get(name string) (*Organization, error)
List(opts tfe.OrganizationListOptions) (*OrganizationList, error)
Update(name string, opts *tfe.OrganizationUpdateOptions) (*Organization, error)
Delete(name string) error
GetEntitlements(name string) (*Entitlements, error)
}
type OrganizationStore ¶
type OrganizationStore interface {
Create(org *Organization) (*Organization, error)
Get(name string) (*Organization, error)
List(opts tfe.OrganizationListOptions) (*OrganizationList, error)
Update(name string, fn func(*Organization) error) (*Organization, error)
Delete(name string) error
}
type Plan ¶
type Plan struct {
ID string
gorm.Model
ResourceAdditions int
ResourceChanges int
ResourceDestructions int
Status tfe.PlanStatus
StatusTimestamps *tfe.PlanStatusTimestamps
// LogsBlobID is the blob ID for the log output from a terraform plan
LogsBlobID string
// PlanFileBlobID is the blob ID of the execution plan file in binary format
PlanFileBlobID string
// PlanJSONBlobID is the blob ID of the execution plan file in json format
PlanJSONBlobID string
}
Plan represents a Terraform Enterprise plan.
func (*Plan) GetLogsBlobID ¶
func (*Plan) HasChanges ¶
HasChanges determines whether plan has any changes (adds/changes/deletions).
func (*Plan) UpdateResources ¶
UpdateResources parses the plan file produced from terraform plan to determine the number and type of resource changes planned and updates the plan object accordingly.
func (*Plan) UpdateStatus ¶
func (p *Plan) UpdateStatus(status tfe.PlanStatus)
type PlanEnqueuer ¶
type PlanFile ¶
type PlanFile struct {
ResourcesChanges []ResourceChange `json:"resource_changes"`
}
PlanFile represents the schema of a plan file
type PlanFinishOptions ¶
type PlanFinishOptions 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,plans"`
ResourceAdditions int `jsonapi:"attr,resource-additions"`
ResourceChanges int `jsonapi:"attr,resource-changes"`
ResourceDestructions int `jsonapi:"attr,resource-destructions"`
}
PlanFinishOptions represents the options for finishing a plan.
type PlanService ¶
type PutChunkOptions ¶
type PutChunkOptions struct {
// End indicates this is the last and final chunk
End bool `schema:"end"`
}
type ResourceChange ¶
type ResourceChange struct {
Change Change
}
ResourceChange represents a proposed change to a resource in a plan file
type Run ¶
type Run struct {
ID string
gorm.Model
ForceCancelAvailableAt time.Time
IsDestroy bool
Message string
Permissions *tfe.RunPermissions
PositionInQueue int
Refresh bool
RefreshOnly bool
Status tfe.RunStatus
StatusTimestamps *tfe.RunStatusTimestamps
ReplaceAddrs []string
TargetAddrs []string
// Relations
Plan *Plan
Apply *Apply
Workspace *Workspace
ConfigurationVersion *ConfigurationVersion
}
func (*Run) Actions ¶
func (r *Run) Actions() *tfe.RunActions
Actions lists which actions are currently invokable.
func (*Run) ActivePhase ¶
ActivePhase retrieves the currently active phase
func (*Run) Finish ¶
Finish updates the run to reflect the current phase having finished. An event is emitted reflecting the run's new status.
func (*Run) ForceCancel ¶
ForceCancel updates the state of a run to reflect it having been forcefully cancelled.
func (*Run) IsActive ¶
IsActive determines whether run is currently the active run on a workspace, i.e. it is neither finished nor pending
func (*Run) IsCancelable ¶
IsCancelable determines whether run can be cancelled.
func (*Run) IsConfirmable ¶
IsConfirmable determines whether run can be confirmed.
func (*Run) IsDiscardable ¶
IsDiscardable determines whether run can be discarded.
func (*Run) IsDone ¶
IsDone determines whether run has reached an end state, e.g. applied, discarded, etc.
func (*Run) IsForceCancelable ¶
IsForceCancelable determines whether a run can be forcibly cancelled.
func (*Run) IsSpeculative ¶
func (*Run) UpdateStatus ¶
UpdateStatus updates the status of the run as well as its plan and apply
type RunFactory ¶
type RunFactory struct {
ConfigurationVersionService ConfigurationVersionService
WorkspaceService WorkspaceService
}
RunFactory is a factory for constructing Run objects.
func (*RunFactory) NewRun ¶
func (f *RunFactory) NewRun(opts *tfe.RunCreateOptions) (*Run, error)
NewRun constructs a run object.
type RunGetOptions ¶
type RunGetOptions struct {
// ID of run to retrieve
ID *string
// Get run via apply ID
ApplyID *string
// Get run via plan ID
PlanID *string
}
RunGetOptions are options for retrieving a single Run. Either ID or ApplyID or PlanID must be specfiied.
type RunList ¶
type RunList struct {
*tfe.Pagination
Items []*Run
}
RunList represents a list of runs.
type RunListOptions ¶
type RunListOptions struct {
tfe.RunListOptions
// Filter by run statuses (with an implicit OR condition)
Statuses []tfe.RunStatus
// Filter by workspace ID
WorkspaceID *string
}
RunListOptions are options for paginating and filtering a list of runs
type RunService ¶
type RunService interface {
Create(opts *tfe.RunCreateOptions) (*Run, error)
Get(id string) (*Run, error)
List(opts RunListOptions) (*RunList, error)
Apply(id string, opts *tfe.RunApplyOptions) error
Discard(id string, opts *tfe.RunDiscardOptions) error
Cancel(id string, opts *tfe.RunCancelOptions) error
ForceCancel(id string, opts *tfe.RunForceCancelOptions) error
EnqueuePlan(id string) error
GetPlanLogs(id string, opts GetChunkOptions) ([]byte, error)
GetApplyLogs(id string, opts GetChunkOptions) ([]byte, error)
GetPlanJSON(id string) ([]byte, error)
GetPlanFile(id string) ([]byte, error)
UploadPlan(runID string, plan []byte, json bool) error
JobService
}
RunService implementations allow interactions with runs
type RunStore ¶
type RunStore interface {
Create(run *Run) (*Run, error)
Get(opts RunGetOptions) (*Run, error)
List(opts RunListOptions) (*RunList, error)
// TODO: add support for a special error type that tells update to skip
// updates - useful when fn checks current fields and decides not to update
Update(id string, fn func(*Run) error) (*Run, error)
}
RunStore implementations persist Run objects.
type State ¶
type State struct {
Version int
Serial int64
Lineage string
Outputs map[string]StateOutput
}
State represents the schema of terraform state.
type StateOutput ¶
StateOutput represents an output in terraform state.
type StateVersion ¶
type StateVersion struct {
ID string
gorm.Model
Serial int64
VCSCommitSHA string
VCSCommitURL string
// BlobID is ID of the binary object containing the state
BlobID string
// State version belongs to a workspace
Workspace *Workspace
Outputs []*StateVersionOutput
// State version has many outputs
StateVersionOutputs []StateVersionOutput
}
StateVersion represents a Terraform Enterprise state version.
func (*StateVersion) DownloadURL ¶
func (r *StateVersion) DownloadURL() string
type StateVersionFactory ¶
type StateVersionFactory struct {
WorkspaceService WorkspaceService
BlobStore BlobStore
}
func (*StateVersionFactory) NewStateVersion ¶
func (f *StateVersionFactory) NewStateVersion(workspaceID string, opts tfe.StateVersionCreateOptions) (*StateVersion, error)
type StateVersionGetOptions ¶
type StateVersionGetOptions struct {
// ID of state version to retrieve
ID *string
// Get current state version belonging to workspace with this ID
WorkspaceID *string
}
StateVersionGetOptions are options for retrieving a single StateVersion. Either ID *or* WorkspaceID must be specfiied.
type StateVersionList ¶
type StateVersionList struct {
*tfe.Pagination
Items []*StateVersion
}
StateVersionList represents a list of state versions.
type StateVersionOutput ¶
type StateVersionOutputList ¶
type StateVersionOutputList []*StateVersionOutput
type StateVersionService ¶
type StateVersionService interface {
Create(workspaceID string, opts tfe.StateVersionCreateOptions) (*StateVersion, error)
Current(workspaceID string) (*StateVersion, error)
Get(id string) (*StateVersion, error)
Download(id string) ([]byte, error)
List(opts tfe.StateVersionListOptions) (*StateVersionList, error)
}
type StateVersionStore ¶
type StateVersionStore interface {
Create(sv *StateVersion) (*StateVersion, error)
Get(opts StateVersionGetOptions) (*StateVersion, error)
List(opts tfe.StateVersionListOptions) (*StateVersionList, error)
}
type Subscription ¶
type Subscription interface {
// Event stream for all subscriber's event.
C() <-chan Event
// Closes the event stream channel and disconnects from the event service.
Close() error
}
Subscription represents a stream of events for a subscriber
type Workspace ¶
type Workspace struct {
ID string
gorm.Model
AllowDestroyPlan bool
AutoApply bool
CanQueueDestroyPlan bool
Description string
Environment string
ExecutionMode string
FileTriggersEnabled bool
GlobalRemoteState bool
Locked bool
MigrationEnvironment string
Name string
Permissions *tfe.WorkspacePermissions
QueueAllRuns bool
SpeculativeEnabled bool
SourceName string
SourceURL string
StructuredRunOutputEnabled bool
TerraformVersion string
VCSRepo *tfe.VCSRepo
WorkingDirectory string
ResourceCount int
ApplyDurationAverage time.Duration
PlanDurationAverage time.Duration
PolicyCheckFailures int
RunFailures int
RunsCount int
TriggerPrefixes []string
// Workspace belongs to an organization
Organization *Organization
}
Workspace represents a Terraform Enterprise workspace.
func NewWorkspace ¶
func NewWorkspace(opts *tfe.WorkspaceCreateOptions, org *Organization) *Workspace
func UpdateWorkspace ¶
func UpdateWorkspace(ws *Workspace, opts *tfe.WorkspaceUpdateOptions) (*Workspace, error)
func (*Workspace) Actions ¶
func (ws *Workspace) Actions() *tfe.WorkspaceActions
func (*Workspace) ToggleLock ¶
type WorkspaceList ¶
type WorkspaceList struct {
*tfe.Pagination
Items []*Workspace
}
WorkspaceList represents a list of Workspaces.
type WorkspaceListOptions ¶
type WorkspaceListOptions struct {
// Pagination
tfe.ListOptions
// Optionally filter workspaces with name matching prefix
Prefix *string `schema:"search[name],omitempty"`
// OrganizationName filters workspaces by organization name
OrganizationName *string
// A list of relations to include. See available resources https://www.terraform.io/docs/cloud/api/workspaces.html#available-related-resources
Include *string `schema:"include"`
}
WorkspaceListOptions are options for paginating and filtering a list of Workspaces
type WorkspaceQueue ¶
type WorkspaceQueue struct {
// Active is the currently active run.
Active *Run
// Pending is the list of pending runs waiting for the active run to
// complete.
Pending []*Run
// PlanEnqueuer enqueues a plan onto the global queue
PlanEnqueuer
}
WorkspaceQueue is the queue of runs for a workspace. The queue has at most one active run, which blocks other pending runs. Speculative runs do not block and are therefore not added to the queue.
func (*WorkspaceQueue) Add ¶
func (q *WorkspaceQueue) Add(run *Run) error
Add adds a run to the workspace queue.
func (*WorkspaceQueue) Remove ¶
func (q *WorkspaceQueue) Remove(run *Run) error
Remove removes a run from the queue.
type WorkspaceService ¶
type WorkspaceService interface {
Create(org string, opts *tfe.WorkspaceCreateOptions) (*Workspace, error)
Get(spec WorkspaceSpecifier) (*Workspace, error)
List(opts WorkspaceListOptions) (*WorkspaceList, error)
Update(spec WorkspaceSpecifier, opts *tfe.WorkspaceUpdateOptions) (*Workspace, error)
Lock(id string, opts tfe.WorkspaceLockOptions) (*Workspace, error)
Unlock(id string) (*Workspace, error)
Delete(spec WorkspaceSpecifier) error
}
type WorkspaceSpecifier ¶
type WorkspaceSpecifier struct {
// Specify workspace using its ID
ID *string
// Specify workspace using its name and organization
Name *string
OrganizationName *string
}
WorkspaceSpecifier is used for identifying an individual workspace. Either ID *or* both Name and OrganizationName must be specfiied.
type WorkspaceStore ¶
type WorkspaceStore interface {
Create(ws *Workspace) (*Workspace, error)
Get(spec WorkspaceSpecifier) (*Workspace, error)
List(opts WorkspaceListOptions) (*WorkspaceList, error)
Update(spec WorkspaceSpecifier, fn func(*Workspace) error) (*Workspace, error)
Delete(spec WorkspaceSpecifier) error
}
Source Files
¶
- apply.go
- blob.go
- configuration_version.go
- delete_backend_config.go
- entitlements.go
- errors.go
- events.go
- executor.go
- job.go
- job_writer.go
- organization.go
- otf.go
- pagination.go
- parse_apply_output.go
- parser.go
- plan.go
- plan_file.go
- run.go
- state_version.go
- state_version_output.go
- unpack.go
- version.go
- workspace.go
- workspace_queue.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent provides a daemon capable of running remote operations on behalf of a user.
|
Package agent provides a daemon capable of running remote operations on behalf of a user. |
|
mock
Package mock provides mocks for the parent agent package
|
Package mock provides mocks for the parent agent package |
|
Package app implements services, co-ordinating between the layers of the project.
|
Package app implements services, co-ordinating between the layers of the project. |
|
Package cmd provides CLI functionality.
|
Package cmd provides CLI functionality. |
|
otf
command
|
|
|
otfd
command
|
|
|
Package filestore provides filesystem storage for binary objects (blobs).
|
Package filestore provides filesystem storage for binary objects (blobs). |
|
Package http provides an HTTP interface allowing HTTP clients to interact with OTF.
|
Package http provides an HTTP interface allowing HTTP clients to interact with OTF. |
|
Package inmem implements a layer of services in memory using purely Go constructs.
|
Package inmem implements a layer of services in memory using purely Go constructs. |
|
Package mock implements mocked services.
|
Package mock implements mocked services. |
|
Package sqlite implements persistent storage using the sqlite database.
|
Package sqlite implements persistent storage using the sqlite database. |
