Documentation
¶
Overview ¶
Package otf is responsible for domain logic.
Index ¶
- Constants
- Variables
- func AddSubjectToContext(ctx context.Context, subj Subject) context.Context
- func Bool(b bool) *bool
- func ConfigVersionCacheKey(id string) string
- func Contains[E comparable](s []E, v E) bool
- func ConvertID(id, resource string) string
- func CurrentTimestamp() time.Time
- func ExclusiveReporter(ctx context.Context, logger logr.Logger, hostname string, ...) error
- func Exists(path string) bool
- func GenerateAuthToken(accountType string) (string, error)
- func GenerateRandomString(size int) string
- func GenerateToken() (string, error)
- func GetMapKeys(m map[string]interface{}) []string
- func HostnameCredentialEnv(hostname string) string
- func Index[E comparable](s []E, v E) int
- func Int(i int) *int
- func Int64(i int64) *int64
- func ListModuleRepositories(ctx context.Context, app Application, providerID string) ([]cloud.Repo, error)
- func LockFileCacheKey(id string) string
- func LogCacheKey(runID string, phase PhaseType) string
- func MarshalWorkspaceLockParams(ws *Workspace) (pggen.UpdateWorkspaceLockByIDParams, error)
- func NewID(rtype string) string
- func NewTestCloudConfig(c cloud.Cloud) cloud.Config
- func NewTestTarball(t *testing.T, contents ...string) []byte
- func Pack(src string) ([]byte, error)
- func ParseBranchRef(ref string) (string, bool)
- func ParseRef(ref string) (string, bool)
- func PrefixSlice(slice []string, prefix string) (ret []string)
- func SSLCertsDir() string
- func SetHostname(hostname string, listen *net.TCPAddr) (string, error)
- func StateVersionCacheKey(id string) string
- func String(str string) *string
- func Time(t time.Time) *time.Time
- func UInt(i uint) *uint
- func UUID(u uuid.UUID) *uuid.UUID
- func Unpack(r io.Reader, dst string) error
- func UpdateModuleVersionStatus(ctx context.Context, app Application, opts UpdateModuleVersionStatusOptions) (*Module, *ModuleVersion, error)
- func UpdateOrganizationFromOpts(org *Organization, opts OrganizationUpdateOptions) error
- func ValidStringID(v *string) bool
- type AgentToken
- func AgentFromContext(ctx context.Context) (*AgentToken, error)
- func NewAgentToken(opts CreateAgentTokenOptions) (*AgentToken, error)
- func NewTestAgentToken(t *testing.T, org *Organization) *AgentToken
- func UnmarshalAgentTokenJSONAPI(dto *jsonapi.AgentToken) *AgentToken
- func UnmarshalAgentTokenResult(row AgentTokenRow) *AgentToken
- func (t *AgentToken) CanAccessOrganization(action rbac.Action, name string) bool
- func (*AgentToken) CanAccessSite(action rbac.Action) bool
- func (t *AgentToken) CanAccessWorkspace(action rbac.Action, policy *WorkspacePolicy) bool
- func (t *AgentToken) CreatedAt() time.Time
- func (t *AgentToken) Description() string
- func (t *AgentToken) ID() string
- func (t *AgentToken) Organization() string
- func (t *AgentToken) String() string
- func (t *AgentToken) Token() *string
- type AgentTokenRow
- type AgentTokenService
- type AgentTokenStore
- type Application
- type Apply
- type Cache
- type Change
- type ChangeAction
- type Chunk
- func (c Chunk) AddEndMarker() Chunk
- func (c Chunk) AddStartMarker() Chunk
- func (c Chunk) Cut(opts GetChunkOptions) Chunk
- func (c Chunk) IsEnd() bool
- func (c Chunk) IsStart() bool
- func (c Chunk) Key() string
- func (c Chunk) NextOffset() int
- func (c Chunk) RemoveEndMarker() Chunk
- func (c Chunk) RemoveStartMarker() Chunk
- type ChunkService
- type ChunkStore
- type ConfigUploader
- type ConfigurationSource
- type ConfigurationStatus
- type ConfigurationVersion
- func NewConfigurationVersion(workspaceID string, opts ConfigurationVersionCreateOptions) (*ConfigurationVersion, error)
- func NewTestConfigurationVersion(t *testing.T, ws *Workspace, opts ConfigurationVersionCreateOptions) *ConfigurationVersion
- func UnmarshalConfigurationVersionResult(result ConfigurationVersionResult) (*ConfigurationVersion, error)
- func (cv *ConfigurationVersion) AddStatusTimestamp(status ConfigurationStatus, timestamp time.Time)
- func (cv *ConfigurationVersion) AutoQueueRuns() bool
- func (cv *ConfigurationVersion) CreatedAt() time.Time
- func (cv *ConfigurationVersion) ID() string
- func (cv *ConfigurationVersion) IngressAttributes() *IngressAttributes
- func (cv *ConfigurationVersion) Source() ConfigurationSource
- func (cv *ConfigurationVersion) Speculative() bool
- func (cv *ConfigurationVersion) Status() ConfigurationStatus
- func (cv *ConfigurationVersion) StatusTimestamp(status ConfigurationStatus) (time.Time, error)
- func (cv *ConfigurationVersion) StatusTimestamps() []ConfigurationVersionStatusTimestamp
- func (cv *ConfigurationVersion) String() string
- func (cv *ConfigurationVersion) Upload(ctx context.Context, config []byte, uploader ConfigUploader) error
- func (cv *ConfigurationVersion) WorkspaceID() string
- type ConfigurationVersionCreateOptions
- type ConfigurationVersionGetOptions
- type ConfigurationVersionList
- type ConfigurationVersionListOptions
- type ConfigurationVersionResult
- type ConfigurationVersionService
- type ConfigurationVersionStatusTimestamp
- type ConfigurationVersionStore
- type ConnectWorkspaceOptions
- type CreateAgentTokenOptions
- type CreateModuleOptions
- type CreateModuleVersionOptions
- type CreateTeamOptions
- type CreateVariableOptions
- type CreateWorkspaceOptions
- type CurrentRunService
- type DB
- type Database
- type DownloadModuleOptions
- type Downloader
- type Entitlements
- type Environment
- type EnvironmentFunc
- type Event
- type EventService
- type EventType
- type ExecutionMode
- type GetChunkOptions
- type GetModuleOptions
- type HookCallback
- type HookOptions
- type HookService
- type HostnameService
- type Identity
- type IngressAttributes
- type JobWriter
- type ListModulesOptions
- type ListOptions
- type LockableApplication
- type LogService
- type Module
- func (m *Module) Add(modver *ModuleVersion)
- func (m *Module) CreatedAt() time.Time
- func (m *Module) ID() string
- func (m *Module) Latest() *ModuleVersion
- func (m *Module) MarshalLog() any
- func (m *Module) Name() string
- func (m *Module) Organization() *Organization
- func (m *Module) Provider() string
- func (m *Module) Repo() *ModuleRepo
- func (m *Module) Status() ModuleStatus
- func (m *Module) UpdateStatus(status ModuleStatus)
- func (m *Module) UpdatedAt() time.Time
- func (m *Module) Version(version string) *ModuleVersion
- func (m *Module) Versions() SortedModuleVersions
- type ModuleDeleter
- type ModuleList
- type ModuleRepo
- type ModuleRow
- type ModuleService
- type ModuleStatus
- type ModuleStore
- type ModuleVersion
- func (v *ModuleVersion) CreatedAt() time.Time
- func (v *ModuleVersion) ID() string
- func (v *ModuleVersion) MarshalLog() any
- func (v *ModuleVersion) ModuleID() string
- func (v *ModuleVersion) Status() ModuleVersionStatus
- func (v *ModuleVersion) StatusError() string
- func (v *ModuleVersion) UpdatedAt() time.Time
- func (v *ModuleVersion) Version() string
- type ModuleVersionRow
- type ModuleVersionService
- type ModuleVersionStatus
- type ModuleVersionStore
- type ModuleVersionUploader
- type NewSessionOption
- type NewTeamOption
- type NewTestModuleOption
- type NewTestRegistrySessionOption
- type NewTestWorkspaceOption
- type NewUserOption
- type Organization
- func (org *Organization) CreatedAt() time.Time
- func (org *Organization) ID() string
- func (org *Organization) Name() string
- func (org *Organization) SessionRemember() int
- func (org *Organization) SessionTimeout() int
- func (org *Organization) String() string
- func (org *Organization) UpdatedAt() time.Time
- type OrganizationAccess
- type OrganizationCreateOptions
- type OrganizationList
- type OrganizationListOptions
- type OrganizationService
- type OrganizationStore
- type OrganizationUpdateOptions
- type Pagination
- func (p *Pagination) CurrentPage() int
- func (p *Pagination) NextPage() *int
- func (p *Pagination) NextPageQuery() string
- func (p *Pagination) PrevPage() *int
- func (p *Pagination) PrevPageQuery() string
- func (p *Pagination) ToJSONAPI() *jsonapi.Pagination
- func (p *Pagination) TotalCount() int
- func (p *Pagination) TotalPages() int
- type PersistedChunk
- type Phase
- type PhaseFinishOptions
- type PhaseSpec
- type PhaseStartOptions
- type PhaseStatus
- type PhaseStatusTimestamp
- type PhaseType
- type Plan
- type PlanFile
- type PlanFormat
- type PubSubService
- type PublishModuleOptions
- type PutChunkOptions
- type RegistrySession
- func NewRegistrySession(organization string) (*RegistrySession, error)
- func NewTestRegistrySession(t *testing.T, org *Organization, opts ...NewTestRegistrySessionOption) *RegistrySession
- func UnmarshalRegistrySessionJSONAPI(dto *jsonapi.RegistrySession) *RegistrySession
- func UnmarshalRegistrySessionRow(result RegistrySessionRow) *RegistrySession
- func (t *RegistrySession) CanAccessOrganization(action rbac.Action, name string) bool
- func (*RegistrySession) CanAccessSite(action rbac.Action) bool
- func (t *RegistrySession) CanAccessWorkspace(action rbac.Action, policy *WorkspacePolicy) bool
- func (t *RegistrySession) Expiry() time.Time
- func (t *RegistrySession) ID() string
- func (t *RegistrySession) MarshalLog() any
- func (t *RegistrySession) Organization() string
- func (t *RegistrySession) String() string
- func (t *RegistrySession) Token() string
- type RegistrySessionRow
- type RegistrySessionService
- type RegistrySessionStore
- type Reporter
- type ResourceChange
- type ResourceReport
- type Run
- func (r *Run) Apply() *Apply
- func (r *Run) AutoApply() bool
- func (r *Run) CanAccessOrganization(action rbac.Action, name string) bool
- func (*Run) CanAccessSite(action rbac.Action) bool
- func (r *Run) CanAccessWorkspace(action rbac.Action, policy *WorkspacePolicy) bool
- func (r *Run) CanLock(requestor Identity) error
- func (r *Run) CanUnlock(requestor Identity, force bool) error
- func (r *Run) Cancel() (enqueue bool, err error)
- func (r *Run) Cancelable() bool
- func (r *Run) Commit() *string
- func (r *Run) ConfigurationVersionID() string
- func (r *Run) Confirmable() bool
- func (r *Run) CreatedAt() time.Time
- func (r *Run) Discard() error
- func (r *Run) Discardable() bool
- func (r *Run) Do(env Environment) error
- func (r *Run) Done() bool
- func (r *Run) EnqueueApply() error
- func (r *Run) EnqueuePlan() error
- func (r *Run) ExecutionMode() ExecutionMode
- func (r *Run) Finish(phase PhaseType, opts PhaseFinishOptions) error
- func (r *Run) ForceCancel() error
- func (r *Run) ForceCancelAvailableAt() *time.Time
- func (r *Run) HasApply() bool
- func (r *Run) HasChanges() bool
- func (r *Run) ID() string
- func (r *Run) IsDestroy() bool
- func (r *Run) Latest() bool
- func (r *Run) Message() string
- func (r *Run) Organization() string
- func (r *Run) Phase() PhaseType
- func (r *Run) Plan() *Plan
- func (r *Run) PlanOnly() bool
- func (r *Run) Queued() bool
- func (r *Run) Refresh() bool
- func (r *Run) RefreshOnly() bool
- func (r *Run) ReplaceAddrs() []string
- func (r *Run) RunID() string
- func (r *Run) Speculative() bool
- func (r *Run) Start(phase PhaseType) error
- func (r *Run) Status() RunStatus
- func (r *Run) StatusTimestamp(status RunStatus) (time.Time, error)
- func (r *Run) StatusTimestamps() []RunStatusTimestamp
- func (r *Run) String() string
- func (r *Run) TargetAddrs() []string
- func (r *Run) WorkspaceID() string
- type RunApplyOptions
- type RunCancelOptions
- type RunCreateOptions
- type RunDiscardOptions
- type RunFactory
- type RunForceCancelOptions
- type RunList
- type RunListOptions
- type RunResult
- type RunService
- type RunStarter
- type RunStatus
- type RunStatusTimestamp
- type RunStore
- type Session
- type SessionResult
- type SessionService
- type SessionStore
- type SortedModuleVersions
- type State
- type StateCreateOptions
- type StateOutput
- type StateVersion
- func NewStateVersion(opts StateVersionCreateOptions) (*StateVersion, error)
- func NewTestStateVersion(t *testing.T, outputs ...StateOutput) *StateVersion
- func UnmarshalStateVersionJSONAPI(dto *jsonapi.StateVersion) *StateVersion
- func UnmarshalStateVersionResult(row StateVersionResult) (*StateVersion, error)
- type StateVersionCreateOptions
- type StateVersionGetOptions
- type StateVersionList
- type StateVersionListOptions
- type StateVersionOutput
- type StateVersionResult
- type StateVersionService
- type StateVersionStore
- type Subject
- type Superuser
- type Team
- func NewTeam(name string, org *Organization, opts ...NewTeamOption) *Team
- func NewTestOwners(t *testing.T, org *Organization, opts ...NewTeamOption) *Team
- func NewTestTeam(t *testing.T, org *Organization, opts ...NewTeamOption) *Team
- func UnmarshalTeamResult(row TeamResult, opts ...NewTeamOption) *Team
- func (u *Team) CreatedAt() time.Time
- func (u *Team) ID() string
- func (u *Team) IsOwners() bool
- func (u *Team) Name() string
- func (u *Team) Organization() string
- func (u *Team) OrganizationAccess() OrganizationAccess
- func (u *Team) String() string
- func (u *Team) TeamName() string
- func (u *Team) Update(opts UpdateTeamOptions) error
- type TeamResult
- type TeamService
- type TeamSpec
- type TeamStore
- type TerraformModule
- type TestRunCreateOptions
- type Token
- type TokenCreateOptions
- type TokenService
- type TokenStore
- type UnhookCallback
- type UnhookOptions
- type Unlocked
- type Unmarshaler
- type UpdateModuleStatusOptions
- type UpdateModuleVersionStatusOptions
- type UpdateTeamOptions
- type UpdateVariableOptions
- type UpdateWorkspaceOptions
- type UploadModuleVersionOptions
- type User
- func (u *User) CanAccessOrganization(action rbac.Action, name string) bool
- func (u *User) CanAccessSite(action rbac.Action) bool
- func (u *User) CanAccessWorkspace(action rbac.Action, policy *WorkspacePolicy) bool
- func (u *User) CanLock(requestor Identity) error
- func (u *User) CanUnlock(requestor Identity, force bool) error
- func (u *User) CreatedAt() time.Time
- func (u *User) ID() string
- func (u *User) IsOwner(organization string) bool
- func (u *User) IsSiteAdmin() bool
- func (u *User) IsTeamMember(teamID string) bool
- func (u *User) IsUnprivilegedUser(organization string) bool
- func (u *User) Organizations() []string
- func (u *User) String() string
- func (u *User) SyncMemberships(ctx context.Context, store UserStore, orgs []string, teams []*Team) error
- func (u *User) Team(name, organization string) (*Team, error)
- func (u *User) Teams() []*Team
- func (u *User) TeamsByOrganization(organization string) []*Team
- func (u *User) UpdatedAt() time.Time
- func (u *User) Username() string
- type UserListOptions
- type UserResult
- type UserService
- type UserSpec
- type UserStore
- type VCSProvider
- func (t *VCSProvider) CloudConfig() cloud.Config
- func (t *VCSProvider) CreatedAt() time.Time
- func (t *VCSProvider) ID() string
- func (t *VCSProvider) MarshalLog() any
- func (t *VCSProvider) Name() string
- func (t *VCSProvider) NewClient(ctx context.Context) (cloud.Client, error)
- func (t *VCSProvider) Organization() string
- func (t *VCSProvider) String() string
- func (t *VCSProvider) Token() string
- type VCSProviderCreateOptions
- type VCSProviderFactory
- type VCSProviderRow
- type VCSProviderService
- type VCSProviderStore
- type Variable
- func NewTestVariable(t *testing.T, ws *Workspace, opts CreateVariableOptions) *Variable
- func NewVariable(workspaceID string, opts CreateVariableOptions) (*Variable, error)
- func UnmarshalVariableJSONAPI(json *dto.Variable) *Variable
- func UnmarshalVariableListJSONAPI(json *dto.VariableList) []*Variable
- func UnmarshalVariableRow(result VariableRow) *Variable
- func (v *Variable) Category() VariableCategory
- func (v *Variable) Description() string
- func (v *Variable) HCL() bool
- func (v *Variable) ID() string
- func (v *Variable) Key() string
- func (v *Variable) MarshalLog() any
- func (v *Variable) Sensitive() bool
- func (v *Variable) Update(opts UpdateVariableOptions) error
- func (v *Variable) Value() string
- func (v *Variable) WorkspaceID() string
- type VariableCategory
- type VariableRow
- type VariableService
- type VariableStore
- type WatchLogsOptions
- type WatchOptions
- type Workspace
- func (ws *Workspace) AllowDestroyPlan() bool
- func (ws *Workspace) AutoApply() bool
- func (ws *Workspace) CanQueueDestroyPlan() bool
- func (ws *Workspace) CreatedAt() time.Time
- func (ws *Workspace) Description() string
- func (ws *Workspace) Environment() string
- func (ws *Workspace) ExecutionMode() ExecutionMode
- func (ws *Workspace) ExecutionModes() []string
- func (ws *Workspace) FileTriggersEnabled() bool
- func (ws *Workspace) GetLock() WorkspaceLockState
- func (ws *Workspace) GlobalRemoteState() bool
- func (ws *Workspace) ID() string
- func (ws *Workspace) LatestRunID() *string
- func (ws *Workspace) Lock(lock WorkspaceLockState) error
- func (ws *Workspace) Locked() bool
- func (ws *Workspace) MarshalLog() any
- func (ws *Workspace) MigrationEnvironment() string
- func (ws *Workspace) Name() string
- func (ws *Workspace) Organization() string
- func (ws *Workspace) QualifiedName() WorkspaceQualifiedName
- func (ws *Workspace) QueueAllRuns() bool
- func (ws *Workspace) Repo() *WorkspaceRepo
- func (ws *Workspace) SetLatestRun(runID string)
- func (ws *Workspace) SourceName() string
- func (ws *Workspace) SourceURL() string
- func (ws *Workspace) SpeculativeEnabled() bool
- func (ws *Workspace) String() string
- func (ws *Workspace) StructuredRunOutputEnabled() bool
- func (ws *Workspace) TerraformVersion() string
- func (ws *Workspace) TriggerPrefixes() []string
- func (ws *Workspace) Unlock(iden Identity, force bool) error
- func (ws *Workspace) Update(opts UpdateWorkspaceOptions) error
- func (ws *Workspace) UpdatedAt() time.Time
- func (ws *Workspace) WorkingDirectory() string
- type WorkspaceConnectionService
- type WorkspaceConnector
- type WorkspaceList
- type WorkspaceListOptions
- type WorkspaceLockOptions
- type WorkspaceLockService
- type WorkspaceLockState
- type WorkspacePermission
- type WorkspacePermissionResult
- type WorkspacePermissionService
- type WorkspacePolicy
- type WorkspaceQualifiedName
- type WorkspaceRepo
- type WorkspaceResult
- type WorkspaceService
- type WorkspaceStore
- type WorkspaceUnlockOptions
Constants ¶
const ( DefaultAutoQueueRuns = true DefaultConfigurationSource = "tfe-api" // List all available configuration version statuses. ConfigurationErrored ConfigurationStatus = "errored" ConfigurationPending ConfigurationStatus = "pending" ConfigurationUploaded ConfigurationStatus = "uploaded" // Default maximum config size is 10mb. DefaultConfigMaxSize int64 = 1024 * 1024 * 10 )
const ( // 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 ( DefaultPageNumber = 1 DefaultPageSize = 10 MaxPageSize = 100 )
const ( PendingPhase PhaseType = "pending" PlanPhase PhaseType = "plan" ApplyPhase PhaseType = "apply" FinalPhase PhaseType = "final" UnknownPhase PhaseType = "unknown" PhasePending PhaseStatus = "pending" PhaseQueued PhaseStatus = "queued" PhaseRunning PhaseStatus = "running" PhaseFinished PhaseStatus = "finished" PhaseCanceled PhaseStatus = "canceled" PhaseErrored PhaseStatus = "errored" PhaseUnreachable PhaseStatus = "unreachable" )
const ( LocalStateFilename = "terraform.tfstate" PlanFilename = "plan.out" JSONPlanFilename = "plan.out.json" LockFilename = ".terraform.lock.hcl" )
const ( DefaultUserID = "user-123" DefaultUsername = "otf" )
const ( CategoryTerraform VariableCategory = "terraform" CategoryEnv VariableCategory = "env" // https://developer.hashicorp.com/terraform/cloud-docs/workspaces/variables/managing-variables#character-limits VariableDescriptionMaxChars = 512 VariableKeyMaxChars = 128 VariableValueMaxKB = 256 // 256*1024 bytes )
const ( DefaultAllowDestroyPlan = true DefaultFileTriggersEnabled = true MinTerraformVersion = "1.2.0" DefaultTerraformVersion = "1.3.7" RemoteExecutionMode ExecutionMode = "remote" LocalExecutionMode ExecutionMode = "local" AgentExecutionMode ExecutionMode = "agent" )
const (
DefaultRegistrySessionExpiry = 10 * time.Minute
)
const DefaultSSLCertsDir = "/etc/ssl/certs/ca-certificates.crt"
const (
DefaultSessionExpiry = 24 * time.Hour
)
const (
DefaultStateVersion = 4
)
const ReporterLockID int64 = 179366396344335597
ReporterLockID is a unique ID guaranteeing only one reporter on a cluster is running at any time.
Variables ¶
var ( // ErrAccessNotPermitted is returned when an authorization check fails. ErrAccessNotPermitted = errors.New("access to the resource is not permitted") ErrUnauthorized = errors.New("unauthorized") // ErrResourceNotFound is returned when a receiving a 404. ErrResourceNotFound = errors.New("resource not found") // ErrResourceAlreadyExists is returned when attempting to create a resource // that already exists. ErrResourceAlreadyExists = errors.New("resource already exists") // ErrRequiredName is returned when a name option is not present. ErrRequiredName = errors.New("name is required") // ErrInvalidName is returned when the name option has invalid value. ErrInvalidName = errors.New("invalid value for name") // ErrForeignKeyViolation is returned when attempting to delete or // update a resource that is referenced by another resource and the // delete/update would orphan the reference. ErrForeignKeyViolation = errors.New("foreign key constraint violation") )
Generic errors applicable to all resources.
var ( // ErrInvalidTerraformVersion is returned when a terraform version string is // not a semantic version string (major.minor.patch). ErrInvalidTerraformVersion = errors.New("invalid terraform version") // ErrUnsupportedTerraformVersion is returned when a terraform version is // not supported. ErrUnsupportedTerraformVersion = fmt.Errorf("only terraform versions >= %s are supported", MinTerraformVersion) // ErrInvalidWorkspaceID is returned when the workspace ID is invalid. ErrInvalidWorkspaceID = errors.New("invalid value for workspace ID") // ErrInvalidWorkspaceValue is returned when workspace value is invalid. ErrInvalidWorkspaceValue = errors.New("invalid value for workspace") // ErrInvalidOrg is returned when the organization option has an invalid value. ErrInvalidOrg = errors.New("invalid value for organization") // ErrRequiredOrg is returned when the organization option is not present ErrRequiredOrg = errors.New("organization is required") )
Resource Errors
var ( DefaultSessionTimeout = 20160 DefaultSessionExpiration = 20160 )
var ( ErrStatusTimestampNotFound = errors.New("corresponding status timestamp not found") 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") ErrInvalidRunStateTransition = errors.New("invalid run state transition") ActiveRun = []RunStatus{ RunApplyQueued, RunApplying, RunConfirmed, RunPlanQueued, RunPlanned, RunPlanning, } IncompleteRun = append(ActiveRun, RunPending) CompletedRun = []RunStatus{ RunApplied, RunErrored, RunDiscarded, RunCanceled, RunForceCanceled, } )
var ( SiteAdminID = "user-site-admin" SiteAdmin = User{/* contains filtered or unexported fields */} )
var ( ErrVariableDescriptionMaxExceeded = fmt.Errorf("maximum variable description size (%d chars) exceeded", VariableDescriptionMaxChars) ErrVariableKeyMaxExceeded = fmt.Errorf("maximum variable key size (%d chars) exceeded", VariableKeyMaxChars) ErrVariableValueMaxExceeded = fmt.Errorf("maximum variable value size of %d KB exceeded", VariableValueMaxKB) )
var ( // Build-time parameters set -ldflags Version = "unknown" Commit = "unknown" Built = "unknown" )
var ( ErrWorkspaceAlreadyLocked = errors.New("workspace already locked") ErrWorkspaceLockedByDifferentUser = errors.New("workspace locked by different user") ErrWorkspaceAlreadyUnlocked = errors.New("workspace already unlocked") ErrWorkspaceUnlockDenied = errors.New("unauthorized to unlock workspace") ErrWorkspaceInvalidLock = errors.New("invalid workspace lock") EventWorkspaceLocked EventType = "workspace_locked" EventWorkspaceUnlocked EventType = "workspace_unlocked" )
var DefaultCacheTTL = 10 * time.Minute
DefaultCacheTTL is the default TTL for cached objects
var ErrInvalidStateVersionGetOptions = errors.New("invalid state version get options")
var ErrInvalidTeamSpec = errors.New("invalid team spec options")
var ErrPhaseAlreadyStarted = errors.New("phase already started")
Functions ¶
func AddSubjectToContext ¶ added in v0.0.12
AddSubjectToContext adds a subject to a context
func ConfigVersionCacheKey ¶ added in v0.0.11
func Contains ¶ added in v0.0.21
func Contains[E comparable](s []E, v E) bool
Contains reports whether v is present in s.
func ConvertID ¶ added in v0.0.12
ConvertID converts an ID for use with a different resource, e.g. convert run-123 to plan-123.
func CurrentTimestamp ¶ added in v0.0.12
CurrentTimestamp is *the* way to get a current timestamps in otf and time.Now() should be avoided.
We want timestamps to be rounded to nearest millisecond so that they can be persisted/serialised and not lose precision thereby making comparisons and testing easier.
We also want timestamps to be in the UTC time zone. Again it makes testing easier because libs such as testify's assert use DeepEqual rather than time.Equal to compare times (and structs containing times). That means the internal representation is compared, including the time zone which may differ even though two times refer to the same instant.
In any case, the time zone of the server is often not of importance, whereas that of the user often is, and conversion to their time zone is necessary regardless.
func ExclusiveReporter ¶ added in v0.0.19
func ExclusiveReporter(ctx context.Context, logger logr.Logger, hostname string, app LockableApplication) error
ExclusiveReporter runs a reporter, ensuring it is the *only* reporter running.
func GenerateAuthToken ¶ added in v0.0.12
GenerateAuthToken generates an authentication token for a type of account e.g. agent, user
func GenerateRandomString ¶
GenerateRandomString generates a random string composed of alphanumeric characters of length size.
func GenerateToken ¶ added in v0.0.12
func GetMapKeys ¶ added in v0.0.8
func HostnameCredentialEnv ¶ added in v0.0.19
HostnameCredentialEnv returns the environment variable key for an API token specific to the given hostname.
func Index ¶ added in v0.0.21
func Index[E comparable](s []E, v E) int
Index returns the index of the first occurrence of v in s, or -1 if not present.
func ListModuleRepositories ¶ added in v0.0.19
func ListModuleRepositories(ctx context.Context, app Application, providerID string) ([]cloud.Repo, error)
ListModuleRepositories wraps the ListRepositories endpoint, returning only those repositories with a name matching the format '<something>-<provider>-<module>'.
NOTE: no pagination is performed, only matching results from the first page are retrieved
func LockFileCacheKey ¶ added in v0.0.12
func LogCacheKey ¶ added in v0.0.11
func MarshalWorkspaceLockParams ¶ added in v0.0.12
func MarshalWorkspaceLockParams(ws *Workspace) (pggen.UpdateWorkspaceLockByIDParams, error)
func NewID ¶ added in v0.0.8
NewID constructs resource IDs, which are composed of the resource type and a random 16 character string, separated by a hyphen.
func NewTestTarball ¶ added in v0.0.16
NewTestTarball creates a tarball (.tar.gz) consisting of files respectively populated with the given contents. The files are assigned random names with the terraform file extension appended (.tf)
func ParseBranchRef ¶ added in v0.0.19
ParseBranchRef parses a git ref expecting it to be a reference to a branch. If it is not then false is returned, otherwise the branch name along with true is returned.
func PrefixSlice ¶ added in v0.0.8
PrefixSlice prefixes each string in a slice with another string.
func SSLCertsDir ¶ added in v0.0.21
func SSLCertsDir() string
SSLCertsDir returns the directory containing CA certificates.
func SetHostname ¶ added in v0.0.19
SetHostname sets the system hostname. If hostname is provided it'll use that; otherwise the listen address is used (which should be that used by the otfd daemon).
func StateVersionCacheKey ¶ added in v0.0.11
func UpdateModuleVersionStatus ¶ added in v0.0.19
func UpdateModuleVersionStatus(ctx context.Context, app Application, opts UpdateModuleVersionStatusOptions) (*Module, *ModuleVersion, error)
UpdateModuleVersionStatus updates a module version's status, and ensures its parent module's status is updated accordingly.
func UpdateOrganizationFromOpts ¶ added in v0.0.12
func UpdateOrganizationFromOpts(org *Organization, opts OrganizationUpdateOptions) error
func ValidStringID ¶ added in v0.0.8
ValidStringID checks if the given string pointer is non-nil and contains a typical string identifier.
Types ¶
type AgentToken ¶ added in v0.0.12
type AgentToken struct {
// contains filtered or unexported fields
}
AgentToken is an long-lived authentication token for an external agent.
func AgentFromContext ¶ added in v0.0.12
func AgentFromContext(ctx context.Context) (*AgentToken, error)
AgentFromContext retrieves an agent(-token) from a context
func NewAgentToken ¶ added in v0.0.12
func NewAgentToken(opts CreateAgentTokenOptions) (*AgentToken, error)
func NewTestAgentToken ¶ added in v0.0.19
func NewTestAgentToken(t *testing.T, org *Organization) *AgentToken
func UnmarshalAgentTokenJSONAPI ¶ added in v0.0.12
func UnmarshalAgentTokenJSONAPI(dto *jsonapi.AgentToken) *AgentToken
func UnmarshalAgentTokenResult ¶ added in v0.0.12
func UnmarshalAgentTokenResult(row AgentTokenRow) *AgentToken
UnmarshalAgentTokenResult unmarshals a row from the database.
func (*AgentToken) CanAccessOrganization ¶ added in v0.0.12
func (t *AgentToken) CanAccessOrganization(action rbac.Action, name string) bool
func (*AgentToken) CanAccessSite ¶ added in v0.0.12
func (*AgentToken) CanAccessSite(action rbac.Action) bool
func (*AgentToken) CanAccessWorkspace ¶ added in v0.0.12
func (t *AgentToken) CanAccessWorkspace(action rbac.Action, policy *WorkspacePolicy) bool
func (*AgentToken) CreatedAt ¶ added in v0.0.12
func (t *AgentToken) CreatedAt() time.Time
func (*AgentToken) Description ¶ added in v0.0.12
func (t *AgentToken) Description() string
func (*AgentToken) ID ¶ added in v0.0.12
func (t *AgentToken) ID() string
func (*AgentToken) Organization ¶ added in v0.0.21
func (t *AgentToken) Organization() string
func (*AgentToken) String ¶ added in v0.0.12
func (t *AgentToken) String() string
func (*AgentToken) Token ¶ added in v0.0.12
func (t *AgentToken) Token() *string
type AgentTokenRow ¶ added in v0.0.12
type AgentTokenService ¶ added in v0.0.12
type AgentTokenService interface {
CreateAgentToken(ctx context.Context, opts CreateAgentTokenOptions) (*AgentToken, error)
// GetAgentToken retrieves AgentToken using its cryptographic
// authentication token.
GetAgentToken(ctx context.Context, token string) (*AgentToken, error)
ListAgentTokens(ctx context.Context, organization string) ([]*AgentToken, error)
DeleteAgentToken(ctx context.Context, id string) (*AgentToken, error)
}
AgentTokenService provides access to agent tokens
type AgentTokenStore ¶ added in v0.0.12
type AgentTokenStore interface {
CreateAgentToken(ctx context.Context, at *AgentToken) error
// GetAgentTokenByID retrieves agent token using its ID.
GetAgentTokenByID(ctx context.Context, id string) (*AgentToken, error)
// GetAgentTokenByToken retrieves agent token using its cryptographic
// authentication token.
GetAgentTokenByToken(ctx context.Context, token string) (*AgentToken, error)
ListAgentTokens(ctx context.Context, organization string) ([]*AgentToken, error)
DeleteAgentToken(ctx context.Context, id string) error
}
AgentTokenStore persists agent authentication tokens.
type Application ¶ added in v0.0.12
type Application interface {
// Tx provides a transaction within which to operate on the store.
Tx(ctx context.Context, tx func(Application) error) error
DB() DB
OrganizationService
WorkspaceService
StateVersionService
ConfigurationVersionService
RunService
EventService
UserService
SessionService
RegistrySessionService
TokenService
TeamService
AgentTokenService
CurrentRunService
VCSProviderService
LockableApplication
cloud.Service
ModuleService
ModuleVersionService
HostnameService
VariableService
HookService
}
Application provides access to the otf application services
type Apply ¶
type Apply struct {
// ResourcesReport is a report of applied resource changes
*ResourceReport
// contains filtered or unexported fields
}
Apply is the apply phase of a run
func (Apply) Status ¶
func (p Apply) Status() PhaseStatus
func (Apply) StatusTimestamp ¶ added in v0.0.12
func (p Apply) StatusTimestamp(status PhaseStatus) (time.Time, error)
func (Apply) StatusTimestamps ¶
func (p Apply) StatusTimestamps() []PhaseStatusTimestamp
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" // PlanFormatBinary is the binary representation of the plan file PlanFormatBinary = "bin" // PlanFormatJSON is the JSON representation of the plan file PlanFormatJSON = "json" )
type Chunk ¶ added in v0.0.12
type Chunk struct {
// ID of run that generated the chunk
RunID string `schema:"run_id,required"`
// Phase that generated the chunk
Phase PhaseType `schema:"phase,required"`
// Position within logs.
Offset int `schema:"offset,required"`
// The chunk of logs
Data []byte
}
Chunk is a section of logs.
func (Chunk) AddEndMarker ¶ added in v0.0.12
func (Chunk) AddStartMarker ¶ added in v0.0.12
func (Chunk) Cut ¶ added in v0.0.12
func (c Chunk) Cut(opts GetChunkOptions) Chunk
Cut returns a new, smaller chunk.
func (Chunk) NextOffset ¶ added in v0.0.12
func (Chunk) RemoveEndMarker ¶ added in v0.0.12
func (Chunk) RemoveStartMarker ¶ added in v0.0.12
type ChunkService ¶ added in v0.0.12
type ChunkService interface {
// GetChunk fetches a chunk.
GetChunk(ctx context.Context, opts GetChunkOptions) (Chunk, error)
// PutChunk uploads a chunk.
PutChunk(ctx context.Context, chunk Chunk) error
}
ChunkService provides interaction with chunks.
type ChunkStore ¶ added in v0.0.8
type ChunkStore interface {
// GetChunk fetches a chunk of logs.
GetChunk(ctx context.Context, opts GetChunkOptions) (Chunk, error)
// GetChunkByID fetches a specific chunk with the given ID.
GetChunkByID(ctx context.Context, id int) (PersistedChunk, error)
// PutChunk uploads a chunk, receiving back the chunk along with a unique
// ID.
PutChunk(ctx context.Context, chunk Chunk) (PersistedChunk, error)
}
ChunkStore implementations provide a persistent store from and to which chunks can be fetched and uploaded.
type ConfigUploader ¶ added in v0.0.12
type ConfigUploader interface {
// Upload uploads the config tarball and returns a status indicating success
// or failure.
Upload(ctx context.Context, config []byte) (ConfigurationStatus, error)
// SetErrored sets the config version status to 'errored' in the store.
SetErrored(ctx context.Context) error
}
ConfigUploader uploads a config
type ConfigurationSource ¶ added in v0.0.8
type ConfigurationSource string
ConfigurationSource represents a source of a configuration version.
type ConfigurationStatus ¶ added in v0.0.8
type ConfigurationStatus string
ConfigurationStatus represents a configuration version status.
type ConfigurationVersion ¶
type ConfigurationVersion struct {
// contains filtered or unexported fields
}
ConfigurationVersion is a representation of an uploaded or ingressed Terraform configuration in A workspace must have at least one configuration version before any runs may be queued on it.
func NewConfigurationVersion ¶ added in v0.0.12
func NewConfigurationVersion(workspaceID string, opts ConfigurationVersionCreateOptions) (*ConfigurationVersion, error)
NewConfigurationVersion creates a ConfigurationVersion object from scratch
func NewTestConfigurationVersion ¶ added in v0.0.12
func NewTestConfigurationVersion(t *testing.T, ws *Workspace, opts ConfigurationVersionCreateOptions) *ConfigurationVersion
func UnmarshalConfigurationVersionResult ¶ added in v0.0.12
func UnmarshalConfigurationVersionResult(result ConfigurationVersionResult) (*ConfigurationVersion, error)
func (*ConfigurationVersion) AddStatusTimestamp ¶ added in v0.0.12
func (cv *ConfigurationVersion) AddStatusTimestamp(status ConfigurationStatus, timestamp time.Time)
func (*ConfigurationVersion) AutoQueueRuns ¶
func (cv *ConfigurationVersion) AutoQueueRuns() bool
func (*ConfigurationVersion) CreatedAt ¶ added in v0.0.12
func (cv *ConfigurationVersion) CreatedAt() time.Time
func (*ConfigurationVersion) ID ¶
func (cv *ConfigurationVersion) ID() string
func (*ConfigurationVersion) IngressAttributes ¶ added in v0.0.19
func (cv *ConfigurationVersion) IngressAttributes() *IngressAttributes
func (*ConfigurationVersion) Source ¶
func (cv *ConfigurationVersion) Source() ConfigurationSource
func (*ConfigurationVersion) Speculative ¶
func (cv *ConfigurationVersion) Speculative() bool
func (*ConfigurationVersion) Status ¶
func (cv *ConfigurationVersion) Status() ConfigurationStatus
func (*ConfigurationVersion) StatusTimestamp ¶ added in v0.0.12
func (cv *ConfigurationVersion) StatusTimestamp(status ConfigurationStatus) (time.Time, error)
func (*ConfigurationVersion) StatusTimestamps ¶
func (cv *ConfigurationVersion) StatusTimestamps() []ConfigurationVersionStatusTimestamp
func (*ConfigurationVersion) String ¶ added in v0.0.8
func (cv *ConfigurationVersion) String() string
func (*ConfigurationVersion) Upload ¶ added in v0.0.12
func (cv *ConfigurationVersion) Upload(ctx context.Context, config []byte, uploader ConfigUploader) error
Upload saves the config to the db and updates status accordingly.
func (*ConfigurationVersion) WorkspaceID ¶ added in v0.0.12
func (cv *ConfigurationVersion) WorkspaceID() string
type ConfigurationVersionCreateOptions ¶ added in v0.0.8
type ConfigurationVersionCreateOptions struct {
AutoQueueRuns *bool
Speculative *bool
*IngressAttributes
}
ConfigurationVersionCreateOptions represents the options for creating a configuration version. See dto.ConfigurationVersionCreateOptions for more details.
type ConfigurationVersionGetOptions ¶
type ConfigurationVersionGetOptions struct {
// ID of config version to retrieve
ID *string
// Get latest config version for this workspace ID
WorkspaceID *string
// A list of relations to include
Include *string `schema:"include"`
}
ConfigurationVersionGetOptions are options for retrieving a single config version. Either ID *or* WorkspaceID must be specfiied.
type ConfigurationVersionList ¶
type ConfigurationVersionList struct {
*Pagination
Items []*ConfigurationVersion
}
ConfigurationVersionList represents a list of configuration versions.
type ConfigurationVersionListOptions ¶
type ConfigurationVersionListOptions struct {
// A list of relations to include
Include *string `schema:"include"`
ListOptions
}
ConfigurationVersionListOptions are options for paginating and filtering a list of configuration versions
type ConfigurationVersionResult ¶ added in v0.0.12
type ConfigurationVersionResult struct {
ConfigurationVersionID pgtype.Text `json:"configuration_version_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
AutoQueueRuns bool `json:"auto_queue_runs"`
Source pgtype.Text `json:"source"`
Speculative bool `json:"speculative"`
Status pgtype.Text `json:"status"`
WorkspaceID pgtype.Text `json:"workspace_id"`
ConfigurationVersionStatusTimestamps []pggen.ConfigurationVersionStatusTimestamps `json:"configuration_version_status_timestamps"`
IngressAttributes *pggen.IngressAttributes `json:"ingress_attributes"`
}
ConfigurationVersionResult represents the result of a database query for a configuration version.
type ConfigurationVersionService ¶
type ConfigurationVersionService interface {
CreateConfigurationVersion(ctx context.Context, workspaceID string, opts ConfigurationVersionCreateOptions) (*ConfigurationVersion, error)
// CloneConfigurationVersion creates a new configuration version using the
// config tarball of an existing configuration version.
CloneConfigurationVersion(ctx context.Context, cvID string, opts ConfigurationVersionCreateOptions) (*ConfigurationVersion, error)
GetConfigurationVersion(ctx context.Context, id string) (*ConfigurationVersion, error)
GetLatestConfigurationVersion(ctx context.Context, workspaceID string) (*ConfigurationVersion, error)
ListConfigurationVersions(ctx context.Context, workspaceID string, opts ConfigurationVersionListOptions) (*ConfigurationVersionList, error)
// Upload handles verification and upload of the config tarball, updating
// the config version upon success or failure.
UploadConfig(ctx context.Context, id string, config []byte) error
// Download retrieves the config tarball for the given config version ID.
DownloadConfig(ctx context.Context, id string) ([]byte, error)
}
type ConfigurationVersionStatusTimestamp ¶ added in v0.0.12
type ConfigurationVersionStatusTimestamp struct {
Status ConfigurationStatus
Timestamp time.Time
}
type ConfigurationVersionStore ¶
type ConfigurationVersionStore interface {
// Creates a config version.
CreateConfigurationVersion(ctx context.Context, cv *ConfigurationVersion) error
// Get retrieves a config version.
GetConfigurationVersion(ctx context.Context, opts ConfigurationVersionGetOptions) (*ConfigurationVersion, error)
// GetConfig retrieves the config tarball for the given config version ID.
GetConfig(ctx context.Context, id string) ([]byte, error)
// List lists config versions for the given workspace.
ListConfigurationVersions(ctx context.Context, workspaceID string, opts ConfigurationVersionListOptions) (*ConfigurationVersionList, error)
// Delete deletes the config version from the store
DeleteConfigurationVersion(ctx context.Context, id string) error
// Upload uploads a config tarball for the given config version ID
UploadConfigurationVersion(ctx context.Context, id string, fn func(cv *ConfigurationVersion, uploader ConfigUploader) error) error
}
type ConnectWorkspaceOptions ¶ added in v0.0.19
type CreateAgentTokenOptions ¶ added in v0.0.19
type CreateModuleOptions ¶ added in v0.0.19
type CreateModuleOptions struct {
Name string
Provider string
Organization *Organization
Repo *ModuleRepo
}
type CreateModuleVersionOptions ¶ added in v0.0.19
type CreateTeamOptions ¶ added in v0.0.19
type CreateVariableOptions ¶ added in v0.0.20
type CreateWorkspaceOptions ¶ added in v0.0.21
type CreateWorkspaceOptions struct {
AllowDestroyPlan *bool
AutoApply *bool
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"`
Repo *WorkspaceRepo
}
CreateWorkspaceOptions represents the options for creating a new workspace.
type CurrentRunService ¶ added in v0.0.12
type CurrentRunService interface {
// SetCurrentRun sets the ID of the latest run for a workspace.
//
// Take full run obj as param
SetCurrentRun(ctx context.Context, workspaceID, runID string) (*Workspace, error)
}
CurrentRunService provides interaction with the current run for a workspace, i.e. the current, or most recently current, non-speculative, run.
type DB ¶ added in v0.0.12
type DB interface {
Database
Tx(ctx context.Context, tx func(DB) error) error
// WaitAndLock obtains a DB with a session-level advisory lock.
WaitAndLock(ctx context.Context, id int64, cb func(DB) error) error
Close()
UserStore
TeamStore
OrganizationStore
WorkspaceStore
RunStore
SessionStore
RegistrySessionStore
StateVersionStore
TokenStore
ConfigurationVersionStore
ChunkStore
AgentTokenStore
VCSProviderStore
ModuleStore
ModuleVersionStore
VariableStore
}
DB provides access to otf database
type Database ¶ added in v0.0.23
type Database interface {
pggen.Querier // generated SQL queries
// Tx provides a transaction within which to operate on the store.
Transaction(ctx context.Context, tx func(Database) error) error
// WaitAndLock obtains a DB with a session-level advisory lock.
WaitAndLock(ctx context.Context, id int64, cb func(DB) error) error
}
Database provides access to generated SQL queries as well as wrappers for performing queries within a transaction or a lock.
type DownloadModuleOptions ¶ added in v0.0.19
type DownloadModuleOptions struct {
ModuleVersionID string
}
type Downloader ¶ added in v0.0.12
type Downloader interface {
// Download version, return path.
Download(ctx context.Context, version string, w io.Writer) (path string, err error)
}
Downloader is capable of downloading a version of software.
type Entitlements ¶
type Entitlements struct {
ID string
Agents bool
AuditLogging bool
CostEstimation bool
Operations bool
PrivateModuleRegistry bool
SSO bool
Sentinel bool
StateStorage bool
Teams bool
VCSIntegrations bool
}
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 Environment ¶ added in v0.0.8
type Environment interface {
// Path returns absolute root path
Path() string
// WorkingDir returns relative path for terraform operations
WorkingDir() string
// RunTerraform invokes a terraform command
RunTerraform(cmd string, args ...string) error
// RunCLI runs an arbitrary command
RunCLI(name string, args ...string) error
// RunFunc runs a go func with access to the env
RunFunc(fn EnvironmentFunc) error
// TerraformPath is the path to the terraform bin
TerraformPath() string
// All app services should be made available to the environment
Application
// For downloading TF CLI
Downloader
// Permits job to write to output that'll be shown to the user
io.Writer
}
Environment provides a Job with access to various otf services, a working directory, and the ability to invoke arbitrary commands and go functions. Invoking commands and functions via the environment means the environment can handle canceling them if necessary.
type EnvironmentFunc ¶ added in v0.0.8
type EnvironmentFunc func(context.Context, Environment) error
EnvironmentFunc is a go func that is invoked within an environment (and with access to the environment).
type Event ¶
type Event struct {
Type EventType
Payload interface{}
}
Event represents an event in the lifecycle of an otf resource
type EventService ¶
type EventService interface {
// Watch provides access to a stream of events. The WatchOptions filters
// events. Context must be cancelled to close stream.
//
// TODO(@leg100): it would be clearer to the caller if the stream is closed by
// returning a stream object with a Close() method. The calling code would
// call Watch(), and then defer a Close(), which is more readable IMO.
Watch(context.Context, WatchOptions) (<-chan Event, error)
// WatchLogs provides access to a stream of phase logs. The WatchLogsOptions filters
// events. Context must be cancelled to close stream.
//
// TODO(@leg100): it would be clearer to the caller if the stream is closed by
// returning a stream object with a Close() method. The calling code would
// call WatchLogs(), and then defer a Close(), which is more readable IMO.
WatchLogs(context.Context, WatchLogsOptions) (<-chan Chunk, error)
}
EventService allows interacting with events. Access is authenticated.
type EventType ¶
type EventType string
EventType identifies the type of event
const ( EventOrganizationCreated EventType = "organization_created" EventOrganizationDeleted EventType = "organization_deleted" EventWorkspaceCreated EventType = "workspace_created" EventWorkspaceRenamed EventType = "workspace_renamed" EventWorkspaceDeleted EventType = "workspace_deleted" EventRunCreated EventType = "run_created" EventRunStatusUpdate EventType = "run_status_update" EventRunDeleted EventType = "run_deleted" EventRunCancel EventType = "run_cancel" EventRunForceCancel EventType = "run_force_cancel" EventError EventType = "error" EventInfo EventType = "info" EventLogChunk EventType = "log_update" )
type ExecutionMode ¶ added in v0.0.12
type ExecutionMode string
func ExecutionModePtr ¶ added in v0.0.20
func ExecutionModePtr(m ExecutionMode) *ExecutionMode
ExecutionModePtr returns a pointer to an execution mode.
type GetChunkOptions ¶
type GetChunkOptions struct {
RunID string `schema:"run_id"`
Phase PhaseType `schema:"phase"`
// Limit is the size of the chunk to retrieve
Limit int `schema:"limit"`
// Offset is the position in the data from which to retrieve the chunk.
Offset int `schema:"offset"`
}
func (GetChunkOptions) Key ¶ added in v0.0.12
func (c GetChunkOptions) Key() string
Key returns an identifier for looking up chunks in a cache
type GetModuleOptions ¶ added in v0.0.19
type HookCallback ¶ added in v0.0.23
type HookOptions ¶ added in v0.0.23
type HookOptions struct {
Identifier string
Cloud string
HookCallback
cloud.Client
}
type HookService ¶ added in v0.0.23
type HookService interface {
Hook(ctx context.Context, opts HookOptions) error
Unhook(ctx context.Context, opts UnhookOptions) error
}
HookService hooks up, and unhooks, resources to webhooks.
type HostnameService ¶ added in v0.0.19
type HostnameService interface {
Hostname() string
}
type Identity ¶ added in v0.0.12
type Identity interface {
// Human friendly identification of the entity.
String() string
// Uniquely identifies the entity.
ID() string
}
Identity is an identifiable otf entity.
type IngressAttributes ¶ added in v0.0.19
type JobWriter ¶
type JobWriter struct {
// ID of run to write logs on behalf of.
ID string
// run phase
Phase PhaseType
// LogService for uploading logs to server
LogService
logr.Logger
// contains filtered or unexported fields
}
JobWriter writes logs on behalf of a run phase.
TODO: rename to LogWriter or PhaseWriter
func NewJobWriter ¶ added in v0.0.12
type ListModulesOptions ¶ added in v0.0.19
type ListModulesOptions struct {
Organization string `schema:"organization_name,required"` // filter by organization name
}
type ListOptions ¶ added in v0.0.8
type ListOptions struct {
// The page number to request. The results vary based on the PageSize.
PageNumber int `schema:"page[number],omitempty"`
// The number of elements returned in a single page.
PageSize int `schema:"page[size],omitempty"`
}
ListOptions is used to specify pagination options when making API requests. Pagination allows breaking up large result sets into chunks, or "pages".
func (ListOptions) GetLimit ¶ added in v0.0.8
func (o ListOptions) GetLimit() int
GetLimit calculates the limit for use in SQL queries.
func (ListOptions) GetOffset ¶ added in v0.0.8
func (o ListOptions) GetOffset() int
GetOffset calculates the offset for use in SQL queries.
func (ListOptions) SanitizedPageNumber ¶ added in v0.0.16
func (o ListOptions) SanitizedPageNumber() int
SanitizedPageNumber is the page number following sanitization.
func (ListOptions) SanitizedPageSize ¶ added in v0.0.16
func (o ListOptions) SanitizedPageSize() int
SanitizedPageSize is the page size following sanitization.
type LockableApplication ¶ added in v0.0.12
type LockableApplication interface {
WithLock(ctx context.Context, id int64, cb func(Application) error) error
}
LockableApplication is an application that holds an exclusive lock with the given ID.
type LogService ¶ added in v0.0.12
type LogService ChunkService
LogService is an alias for ChunkService
type Module ¶ added in v0.0.19
type Module struct {
// contains filtered or unexported fields
}
func NewModule ¶ added in v0.0.19
func NewModule(opts CreateModuleOptions) *Module
func NewTestModule ¶ added in v0.0.19
func NewTestModule(org *Organization, opts ...NewTestModuleOption) *Module
func UnmarshalModuleRow ¶ added in v0.0.19
UnmarshalModuleRow unmarshals a database row into a module
func (*Module) Add ¶ added in v0.0.19
func (m *Module) Add(modver *ModuleVersion)
Add adds a version to a module's list of versions
func (*Module) Latest ¶ added in v0.0.19
func (m *Module) Latest() *ModuleVersion
func (*Module) MarshalLog ¶ added in v0.0.19
func (*Module) Organization ¶ added in v0.0.19
func (m *Module) Organization() *Organization
func (*Module) Repo ¶ added in v0.0.19
func (m *Module) Repo() *ModuleRepo
func (*Module) Status ¶ added in v0.0.19
func (m *Module) Status() ModuleStatus
func (*Module) UpdateStatus ¶ added in v0.0.19
func (m *Module) UpdateStatus(status ModuleStatus)
func (*Module) Version ¶ added in v0.0.19
func (m *Module) Version(version string) *ModuleVersion
Version returns the specified module version. If the empty string, then the latest version is returned. If there is no matching version or no versions at all then nil is returned.
func (*Module) Versions ¶ added in v0.0.19
func (m *Module) Versions() SortedModuleVersions
type ModuleDeleter ¶ added in v0.0.23
type ModuleList ¶ added in v0.0.19
type ModuleList struct {
*Pagination
Items []*Module
}
type ModuleRepo ¶ added in v0.0.19
type ModuleRow ¶ added in v0.0.19
type ModuleRow struct {
ModuleID pgtype.Text `json:"module_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
Name pgtype.Text `json:"name"`
Provider pgtype.Text `json:"provider"`
Status pgtype.Text `json:"status"`
Organization *pggen.Organizations `json:"organization"`
ModuleRepo *pggen.ModuleRepos `json:"module_repo"`
Webhook *pggen.Webhooks `json:"webhook"`
Versions []pggen.ModuleVersions `json:"versions"`
}
ModuleRow is a row from a database query for modules.
type ModuleService ¶ added in v0.0.19
type ModuleService interface {
// PublishModule publishes a module from a VCS repository.
PublishModule(context.Context, PublishModuleOptions) (*Module, error)
// CreateModule creates a module without a connection to a VCS repository.
CreateModule(context.Context, CreateModuleOptions) (*Module, error)
UpdateModuleStatus(ctx context.Context, opts UpdateModuleStatusOptions) (*Module, error)
ListModules(context.Context, ListModulesOptions) ([]*Module, error)
GetModule(ctx context.Context, opts GetModuleOptions) (*Module, error)
GetModuleByID(ctx context.Context, id string) (*Module, error)
GetModuleByWebhookID(ctx context.Context, id uuid.UUID) (*Module, error)
DeleteModule(ctx context.Context, id string) (*Module, error)
}
type ModuleStatus ¶ added in v0.0.19
type ModuleStatus string
const ( ModuleStatusPending ModuleStatus = "pending" ModuleStatusNoVersionTags ModuleStatus = "no_version_tags" ModuleStatusSetupFailed ModuleStatus = "setup_failed" ModuleStatusSetupComplete ModuleStatus = "setup_complete" )
func NextModuleStatus ¶ added in v0.0.19
func NextModuleStatus(current ModuleStatus, versionStatus ModuleVersionStatus) ModuleStatus
NextModuleStatus determines a new module status based on current module status and the version status (effectively a finite state machine calculating the next state to transition to).
type ModuleStore ¶ added in v0.0.19
type ModuleStore interface {
CreateModule(context.Context, *Module) error
UpdateModuleStatus(ctx context.Context, opts UpdateModuleStatusOptions) error
ListModules(context.Context, ListModulesOptions) ([]*Module, error)
GetModule(ctx context.Context, opts GetModuleOptions) (*Module, error)
GetModuleByID(ctx context.Context, id string) (*Module, error)
GetModuleByWebhookID(ctx context.Context, id uuid.UUID) (*Module, error)
DeleteModule(ctx context.Context, id string) error
}
type ModuleVersion ¶ added in v0.0.19
type ModuleVersion struct {
// contains filtered or unexported fields
}
func NewModuleVersion ¶ added in v0.0.19
func NewModuleVersion(opts CreateModuleVersionOptions) *ModuleVersion
func NewTestModuleVersion ¶ added in v0.0.19
func NewTestModuleVersion(mod *Module, version string, status ModuleVersionStatus) *ModuleVersion
func UnmarshalModuleVersionRow ¶ added in v0.0.19
func UnmarshalModuleVersionRow(row ModuleVersionRow) *ModuleVersion
UnmarshalModuleVersionRow unmarshals a database row into a module version
func (*ModuleVersion) CreatedAt ¶ added in v0.0.19
func (v *ModuleVersion) CreatedAt() time.Time
func (*ModuleVersion) ID ¶ added in v0.0.19
func (v *ModuleVersion) ID() string
func (*ModuleVersion) MarshalLog ¶ added in v0.0.19
func (v *ModuleVersion) MarshalLog() any
func (*ModuleVersion) ModuleID ¶ added in v0.0.19
func (v *ModuleVersion) ModuleID() string
func (*ModuleVersion) Status ¶ added in v0.0.19
func (v *ModuleVersion) Status() ModuleVersionStatus
func (*ModuleVersion) StatusError ¶ added in v0.0.19
func (v *ModuleVersion) StatusError() string
func (*ModuleVersion) UpdatedAt ¶ added in v0.0.19
func (v *ModuleVersion) UpdatedAt() time.Time
func (*ModuleVersion) Version ¶ added in v0.0.19
func (v *ModuleVersion) Version() string
type ModuleVersionRow ¶ added in v0.0.19
type ModuleVersionRow struct {
ModuleVersionID pgtype.Text `json:"module_version_id"`
Version pgtype.Text `json:"version"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
Status pgtype.Text `json:"status"`
StatusError pgtype.Text `json:"status_error"`
ModuleID pgtype.Text `json:"module_id"`
}
ModuleVersionRow is a module version database row
type ModuleVersionService ¶ added in v0.0.19
type ModuleVersionService interface {
CreateModuleVersion(context.Context, CreateModuleVersionOptions) (*ModuleVersion, error)
UploadModuleVersion(ctx context.Context, opts UploadModuleVersionOptions) (*ModuleVersion, error)
DownloadModuleVersion(ctx context.Context, opts DownloadModuleOptions) ([]byte, error)
}
type ModuleVersionStatus ¶ added in v0.0.19
type ModuleVersionStatus string
const ( ModuleVersionStatusPending ModuleVersionStatus = "pending" ModuleVersionStatusCloning ModuleVersionStatus = "cloning" ModuleVersionStatusCloneFailed ModuleVersionStatus = "clone_failed" ModuleVersionStatusRegIngressReqFailed ModuleVersionStatus = "reg_ingress_req_failed" ModuleVersionStatusRegIngressing ModuleVersionStatus = "reg_ingressing" ModuleVersionStatusRegIngressFailed ModuleVersionStatus = "reg_ingress_failed" ModuleVersionStatusOk ModuleVersionStatus = "ok" )
List of available registry module version statuses
type ModuleVersionStore ¶ added in v0.0.19
type ModuleVersionStore interface {
CreateModuleVersion(context.Context, *ModuleVersion) error
UpdateModuleVersionStatus(ctx context.Context, opts UpdateModuleVersionStatusOptions) (*ModuleVersion, error)
UploadModuleVersion(ctx context.Context, opts UploadModuleVersionOptions) error
DownloadModuleVersion(ctx context.Context, opts DownloadModuleOptions) ([]byte, error)
}
type ModuleVersionUploader ¶ added in v0.0.19
type ModuleVersionUploader struct {
Application
}
func (*ModuleVersionUploader) Upload ¶ added in v0.0.19
func (u *ModuleVersionUploader) Upload(ctx context.Context, opts UploadModuleVersionOptions) (*Module, *ModuleVersion, error)
Upload validates and uploads a tarball for a module version. Statuses are set accordingly for both the module version and its parent module.
type NewSessionOption ¶ added in v0.0.12
type NewSessionOption func(*Session)
func SessionExpiry ¶ added in v0.0.12
func SessionExpiry(expiry time.Time) NewSessionOption
type NewTeamOption ¶ added in v0.0.12
type NewTeamOption func(*Team)
type NewTestModuleOption ¶ added in v0.0.19
type NewTestModuleOption func(*Module)
func WithModuleRepo ¶ added in v0.0.19
func WithModuleRepo() NewTestModuleOption
func WithModuleStatus ¶ added in v0.0.19
func WithModuleStatus(status ModuleStatus) NewTestModuleOption
func WithModuleVersion ¶ added in v0.0.19
func WithModuleVersion(version string, status ModuleVersionStatus) NewTestModuleOption
type NewTestRegistrySessionOption ¶ added in v0.0.23
type NewTestRegistrySessionOption func(*RegistrySession)
func OverrideTestRegistrySessionExpiry ¶ added in v0.0.23
func OverrideTestRegistrySessionExpiry(expiry time.Time) NewTestRegistrySessionOption
type NewTestWorkspaceOption ¶ added in v0.0.19
type NewTestWorkspaceOption func(*Workspace)
func AutoApply ¶ added in v0.0.19
func AutoApply() NewTestWorkspaceOption
func WithRepo ¶ added in v0.0.19
func WithRepo(repo *WorkspaceRepo) NewTestWorkspaceOption
func WorkingDirectory ¶ added in v0.0.24
func WorkingDirectory(relativePath string) NewTestWorkspaceOption
type NewUserOption ¶ added in v0.0.12
type NewUserOption func(*User)
func WithOrganizationMemberships ¶ added in v0.0.12
func WithOrganizationMemberships(organizations ...string) NewUserOption
func WithTeamMemberships ¶ added in v0.0.12
func WithTeamMemberships(memberships ...*Team) NewUserOption
type Organization ¶
type Organization struct {
// contains filtered or unexported fields
}
Organization represents a Terraform Enterprise organization.
func NewOrganization ¶
func NewOrganization(opts OrganizationCreateOptions) (*Organization, error)
func NewTestOrganization ¶ added in v0.0.12
func NewTestOrganization(t *testing.T) *Organization
func UnmarshalOrganizationJSONAPI ¶ added in v0.0.12
func UnmarshalOrganizationJSONAPI(model *dto.Organization) *Organization
func UnmarshalOrganizationRow ¶ added in v0.0.12
func UnmarshalOrganizationRow(row pggen.Organizations) *Organization
UnmarshalOrganizationRow converts an organization database row into an organization.
func (*Organization) CreatedAt ¶ added in v0.0.12
func (org *Organization) CreatedAt() time.Time
func (*Organization) ID ¶
func (org *Organization) ID() string
func (*Organization) Name ¶
func (org *Organization) Name() string
func (*Organization) SessionRemember ¶
func (org *Organization) SessionRemember() int
func (*Organization) SessionTimeout ¶
func (org *Organization) SessionTimeout() int
func (*Organization) String ¶ added in v0.0.8
func (org *Organization) String() string
func (*Organization) UpdatedAt ¶ added in v0.0.12
func (org *Organization) UpdatedAt() time.Time
type OrganizationAccess ¶ added in v0.0.12
type OrganizationAccess struct {
ManageWorkspaces bool `schema:"manage_workspaces"` // admin access on all workspaces
ManageVCS bool `schema:"manage_vcs"` // manage VCS providers
ManageRegistry bool `schema:"manage_registry"` // manage module and provider registry
}
OrganizationAccess defines a team's organization access.
type OrganizationCreateOptions ¶ added in v0.0.8
type OrganizationCreateOptions struct {
Name *string `schema:"name,required"`
SessionRemember *int
SessionTimeout *int
}
OrganizationCreateOptions represents the options for creating an organization. See dto.OrganizationCreateOptions for more details.
func (*OrganizationCreateOptions) Validate ¶ added in v0.0.12
func (opts *OrganizationCreateOptions) Validate() error
type OrganizationList ¶
type OrganizationList struct {
*Pagination
Items []*Organization
}
OrganizationList represents a list of Organizations.
type OrganizationListOptions ¶ added in v0.0.8
type OrganizationListOptions struct {
ListOptions
}
OrganizationListOptions represents the options for listing organizations.
type OrganizationService ¶
type OrganizationService interface {
CreateOrganization(ctx context.Context, opts OrganizationCreateOptions) (*Organization, error)
EnsureCreatedOrganization(ctx context.Context, opts OrganizationCreateOptions) (*Organization, error)
GetOrganization(ctx context.Context, name string) (*Organization, error)
ListOrganizations(ctx context.Context, opts OrganizationListOptions) (*OrganizationList, error)
UpdateOrganization(ctx context.Context, name string, opts *OrganizationUpdateOptions) (*Organization, error)
DeleteOrganization(ctx context.Context, name string) error
GetEntitlements(ctx context.Context, name string) (*Entitlements, error)
}
type OrganizationStore ¶
type OrganizationStore interface {
CreateOrganization(ctx context.Context, org *Organization) error
GetOrganization(ctx context.Context, name string) (*Organization, error)
GetOrganizationByID(ctx context.Context, id string) (*Organization, error)
ListOrganizations(ctx context.Context, opts OrganizationListOptions) (*OrganizationList, error)
ListOrganizationsByUser(ctx context.Context, userID string) ([]*Organization, error)
UpdateOrganization(ctx context.Context, name string, fn func(*Organization) error) (*Organization, error)
DeleteOrganization(ctx context.Context, name string) error
GetOrganizationNameByWorkspaceID(ctx context.Context, workspaceID string) (string, error)
}
type OrganizationUpdateOptions ¶ added in v0.0.8
OrganizationUpdateOptions represents the options for updating an organization. See dto.OrganizationUpdateOptions for more details.
type Pagination ¶ added in v0.0.8
type Pagination struct {
// contains filtered or unexported fields
}
Pagination is used to return the pagination details of an API request.
func NewPagination ¶
func NewPagination(opts ListOptions, count int) *Pagination
NewPagination constructs a Pagination obj.
func UnmarshalPaginationJSONAPI ¶ added in v0.0.12
func UnmarshalPaginationJSONAPI(json *jsonapi.Pagination) *Pagination
UnmarshalPaginationJSONAPI converts a JSON-API DTO into a pagination object.
func (*Pagination) CurrentPage ¶ added in v0.0.8
func (p *Pagination) CurrentPage() int
func (*Pagination) NextPage ¶ added in v0.0.8
func (p *Pagination) NextPage() *int
NextPage returns the next page number or nil if there isn't one.
func (*Pagination) NextPageQuery ¶ added in v0.0.16
func (p *Pagination) NextPageQuery() string
NextPageQuery produces query params for the next page
func (*Pagination) PrevPage ¶ added in v0.0.12
func (p *Pagination) PrevPage() *int
PrevPage returns the previous page number or nil if there isn't one.
func (*Pagination) PrevPageQuery ¶ added in v0.0.16
func (p *Pagination) PrevPageQuery() string
PrevPageQuery produces query params for the previous page
func (*Pagination) ToJSONAPI ¶ added in v0.0.12
func (p *Pagination) ToJSONAPI() *jsonapi.Pagination
ToJSONAPI assembles a JSON-API DTO for wire serialization.
func (*Pagination) TotalCount ¶ added in v0.0.8
func (p *Pagination) TotalCount() int
func (*Pagination) TotalPages ¶ added in v0.0.8
func (p *Pagination) TotalPages() int
type PersistedChunk ¶ added in v0.0.12
PersistedChunk is a chunk that has been persisted to the backend.
func (PersistedChunk) ID ¶ added in v0.0.12
func (c PersistedChunk) ID() string
func (PersistedChunk) String ¶ added in v0.0.12
func (c PersistedChunk) String() string
type Phase ¶
type Phase interface {
// Run ID
ID() string
// phase type
Phase() PhaseType
// current phase status
Status() PhaseStatus
// Get job status timestamps
StatusTimestamps() []PhaseStatusTimestamp
// Lookup timestamp for status
StatusTimestamp(PhaseStatus) (time.Time, error)
}
Phase is a section of work performed by a run.
type PhaseFinishOptions ¶ added in v0.0.12
type PhaseFinishOptions struct {
// Errored is true if the phase finished unsuccessfully.
Errored bool `jsonapi:"attr,errored,omitempty"`
}
PhaseFinishOptions report the status of a phase upon finishing.
type PhaseStartOptions ¶ added in v0.0.12
type PhaseStartOptions struct {
AgentID string `jsonapi:"attr,agent-id,omitempty"`
}
type PhaseStatus ¶ added in v0.0.12
type PhaseStatus string
func (PhaseStatus) String ¶ added in v0.0.12
func (r PhaseStatus) String() string
type PhaseStatusTimestamp ¶ added in v0.0.12
type PhaseStatusTimestamp struct {
Status PhaseStatus
Timestamp time.Time
}
type Plan ¶
type Plan struct {
// report of planned resource changes
*ResourceReport
// contains filtered or unexported fields
}
Plan is the plan phase of a run
func (*Plan) HasChanges ¶
HasChanges determines whether plan has any changes (adds/changes/deletions).
func (Plan) Status ¶
func (p Plan) Status() PhaseStatus
func (Plan) StatusTimestamp ¶ added in v0.0.12
func (p Plan) StatusTimestamp(status PhaseStatus) (time.Time, error)
func (Plan) StatusTimestamps ¶
func (p Plan) StatusTimestamps() []PhaseStatusTimestamp
type PlanFile ¶
type PlanFile struct {
ResourceChanges []ResourceChange `json:"resource_changes"`
}
PlanFile represents the schema of a plan file
func (*PlanFile) Changes ¶
func (pf *PlanFile) Changes() (tally ResourceReport)
Changes provides a tally of the types of changes proposed in the plan file.
type PlanFormat ¶ added in v0.0.12
type PlanFormat string
PlanFormat is the format of the plan file
func (PlanFormat) CacheKey ¶ added in v0.0.12
func (f PlanFormat) CacheKey(id string) string
func (PlanFormat) SQLColumn ¶ added in v0.0.12
func (f PlanFormat) SQLColumn() string
type PubSubService ¶ added in v0.0.12
type PubSubService interface {
// Publish an event
Publish(Event)
// Subscribe creates a subscription to a stream of errors. Name is a
// unique identifier describing the subscriber.
Subscribe(ctx context.Context, name string) (<-chan Event, error)
}
PubSubService provides low-level access to pub-sub behaviours. Access is unauthenticated.
type PublishModuleOptions ¶ added in v0.0.19
type PublishModuleOptions struct {
Identifier string
ProviderID string
Organization *Organization
}
type PutChunkOptions ¶
type RegistrySession ¶ added in v0.0.19
type RegistrySession struct {
// contains filtered or unexported fields
}
RegistrySession provides access to the module registry for a short period. Intended for use with the terraform binary, which needs authenticated access to the registry in order to retrieve modules.
func NewRegistrySession ¶ added in v0.0.19
func NewRegistrySession(organization string) (*RegistrySession, error)
func NewTestRegistrySession ¶ added in v0.0.23
func NewTestRegistrySession(t *testing.T, org *Organization, opts ...NewTestRegistrySessionOption) *RegistrySession
func UnmarshalRegistrySessionJSONAPI ¶ added in v0.0.19
func UnmarshalRegistrySessionJSONAPI(dto *jsonapi.RegistrySession) *RegistrySession
func UnmarshalRegistrySessionRow ¶ added in v0.0.19
func UnmarshalRegistrySessionRow(result RegistrySessionRow) *RegistrySession
func (*RegistrySession) CanAccessOrganization ¶ added in v0.0.19
func (t *RegistrySession) CanAccessOrganization(action rbac.Action, name string) bool
func (*RegistrySession) CanAccessSite ¶ added in v0.0.19
func (*RegistrySession) CanAccessSite(action rbac.Action) bool
func (*RegistrySession) CanAccessWorkspace ¶ added in v0.0.19
func (t *RegistrySession) CanAccessWorkspace(action rbac.Action, policy *WorkspacePolicy) bool
func (*RegistrySession) Expiry ¶ added in v0.0.19
func (t *RegistrySession) Expiry() time.Time
func (*RegistrySession) ID ¶ added in v0.0.19
func (t *RegistrySession) ID() string
func (*RegistrySession) MarshalLog ¶ added in v0.0.19
func (t *RegistrySession) MarshalLog() any
func (*RegistrySession) Organization ¶ added in v0.0.19
func (t *RegistrySession) Organization() string
func (*RegistrySession) String ¶ added in v0.0.19
func (t *RegistrySession) String() string
func (*RegistrySession) Token ¶ added in v0.0.19
func (t *RegistrySession) Token() string
type RegistrySessionRow ¶ added in v0.0.19
type RegistrySessionService ¶ added in v0.0.19
type RegistrySessionService interface {
CreateRegistrySession(ctx context.Context, organization string) (*RegistrySession, error)
GetRegistrySession(ctx context.Context, token string) (*RegistrySession, error)
}
type RegistrySessionStore ¶ added in v0.0.19
type RegistrySessionStore interface {
CreateRegistrySession(ctx context.Context, session *RegistrySession) error
GetRegistrySession(ctx context.Context, token string) (*RegistrySession, error)
}
type Reporter ¶ added in v0.0.19
type Reporter struct {
Application
logr.Logger
}
Reporter reports back to VCS providers the current status of VCS-triggered runs.
func NewReporter ¶ added in v0.0.19
func NewReporter(logger logr.Logger, app Application) *Reporter
NewReporter constructs and initialises the reporter.
type ResourceChange ¶
type ResourceChange struct {
Change Change
}
ResourceChange represents a proposed change to a resource in a plan file
type ResourceReport ¶ added in v0.0.12
ResourceReport reports a summary of additions, changes, and deletions of resources in a plan or an apply.
func CompilePlanReport ¶ added in v0.0.12
func CompilePlanReport(planJSON []byte) (ResourceReport, error)
CompilePlanReport compiles a report of planned changes from a JSON representation of a plan file.
func ParseApplyOutput ¶ added in v0.0.8
func ParseApplyOutput(output string) (ResourceReport, error)
func (ResourceReport) HasChanges ¶ added in v0.0.12
func (r ResourceReport) HasChanges() bool
func (ResourceReport) String ¶ added in v0.0.19
func (r ResourceReport) String() string
type Run ¶
type Run struct {
// contains filtered or unexported fields
}
func NewRun ¶ added in v0.0.12
func NewRun(cv *ConfigurationVersion, ws *Workspace, opts RunCreateOptions) *Run
NewRun creates a new run with defaults.
func NewTestRun ¶ added in v0.0.12
func NewTestRun(t *testing.T, opts TestRunCreateOptions) *Run
NewTestRun creates a new run. Expressly for testing purposes.
func UnmarshalRunJSONAPI ¶ added in v0.0.12
func UnmarshalRunResult ¶ added in v0.0.12
func (*Run) CanAccessOrganization ¶ added in v0.0.12
func (*Run) CanAccessWorkspace ¶ added in v0.0.12
func (r *Run) CanAccessWorkspace(action rbac.Action, policy *WorkspacePolicy) bool
func (*Run) Cancel ¶
Cancel run. Returns a boolean indicating whether a cancel request should be enqueued (for an agent to kill an in progress process)
func (*Run) Cancelable ¶ added in v0.0.12
Cancelable determines whether run can be cancelled.
func (*Run) ConfigurationVersionID ¶ added in v0.0.12
func (*Run) Confirmable ¶ added in v0.0.12
Confirmable determines whether run can be confirmed.
func (*Run) Discardable ¶ added in v0.0.12
Discardable determines whether run can be discarded.
func (*Run) Done ¶ added in v0.0.12
Done determines whether run has reached an end state, e.g. applied, discarded, etc.
func (*Run) EnqueueApply ¶ added in v0.0.12
func (*Run) EnqueuePlan ¶ added in v0.0.12
EnqueuePlan enqueues a plan for the run. It also sets the run as the latest run for its workspace (speculative runs are ignored).
func (*Run) ExecutionMode ¶ added in v0.0.12
func (r *Run) ExecutionMode() ExecutionMode
func (*Run) Finish ¶
func (r *Run) Finish(phase PhaseType, opts PhaseFinishOptions) error
Finish updates the run to reflect its plan or apply phase having finished.
func (*Run) ForceCancel ¶
ForceCancel force cancels a run. A cool-off period of 10 seconds must have elapsed following a cancelation request before a run can be force canceled.
func (*Run) ForceCancelAvailableAt ¶
func (*Run) HasApply ¶ added in v0.0.12
HasApply determines whether the run has started applying yet.
func (*Run) HasChanges ¶ added in v0.0.12
func (*Run) Latest ¶ added in v0.0.12
Latest determines whether run is the latest run for a workspace, i.e. its current run, or the most recent current run.
func (*Run) Organization ¶ added in v0.0.21
func (*Run) RefreshOnly ¶
func (*Run) ReplaceAddrs ¶
func (*Run) Speculative ¶ added in v0.0.12
func (*Run) StatusTimestamp ¶ added in v0.0.12
func (*Run) StatusTimestamps ¶
func (r *Run) StatusTimestamps() []RunStatusTimestamp
func (*Run) TargetAddrs ¶
func (*Run) WorkspaceID ¶ added in v0.0.12
type RunApplyOptions ¶ added in v0.0.8
type RunApplyOptions struct {
// An optional comment about the run.
Comment *string `json:"comment,omitempty"`
}
RunApplyOptions represents the options for applying a run.
type RunCancelOptions ¶ added in v0.0.8
type RunCancelOptions struct {
// An optional explanation for why the run was canceled.
Comment *string `jsonapi:"attr,comment,omitempty"`
}
RunCancelOptions represents the options for canceling a run.
type RunCreateOptions ¶ added in v0.0.8
type RunCreateOptions struct {
IsDestroy *bool
Refresh *bool
RefreshOnly *bool
Message *string
ConfigurationVersionID *string
TargetAddrs []string
ReplaceAddrs []string
AutoApply *bool
}
RunCreateOptions represents the options for creating a new run. See dto.RunCreateOptions for further detail.
type RunDiscardOptions ¶ added in v0.0.8
type RunDiscardOptions struct {
// An optional explanation for why the run was discarded.
Comment *string `jsonapi:"attr,comment,omitempty"`
}
RunDiscardOptions represents the options for discarding a run.
type RunFactory ¶
type RunFactory struct {
ConfigurationVersionService ConfigurationVersionService
WorkspaceService WorkspaceService
}
RunFactory is a factory for constructing Run objects.
func (*RunFactory) NewRun ¶
func (f *RunFactory) NewRun(ctx context.Context, workspaceID string, opts RunCreateOptions) (*Run, error)
NewRun constructs a new run at the beginning of its lifecycle using the provided options.
type RunForceCancelOptions ¶ added in v0.0.8
type RunForceCancelOptions struct {
// An optional comment explaining the reason for the force-cancel.
Comment *string `jsonapi:"attr,comment,omitempty"`
}
RunForceCancelOptions represents the options for force-canceling a run.
type RunList ¶
type RunList struct {
*Pagination
Items []*Run
}
RunList represents a list of runs.
func UnmarshalRunListJSONAPI ¶ added in v0.0.12
UnmarshalRunListJSONAPI converts a DTO into a run list
type RunListOptions ¶
type RunListOptions struct {
ListOptions
// Filter by run statuses (with an implicit OR condition)
Statuses []RunStatus `schema:"statuses,omitempty"`
// Filter by workspace ID
WorkspaceID *string `schema:"workspace_id,omitempty"`
// Filter by organization name
Organization *string `schema:"organization_name,omitempty"`
// Filter by workspace name
WorkspaceName *string `schema:"workspace_name,omitempty"`
// Filter by speculative or non-speculative
Speculative *bool `schema:"-"`
// A list of relations to include. See available resources:
// https://www.terraform.io/docs/cloud/api/run.html#available-related-resources
Include *string `schema:"include,omitempty"`
}
RunListOptions are options for paginating and filtering a list of runs
func (RunListOptions) LogFields ¶ added in v0.0.12
func (opts RunListOptions) LogFields() (fields []interface{})
LogFields provides fields for logging
TODO: use logr marshaller instead
type RunResult ¶ added in v0.0.12
type RunResult struct {
RunID pgtype.Text `json:"run_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
ForceCancelAvailableAt pgtype.Timestamptz `json:"force_cancel_available_at"`
IsDestroy bool `json:"is_destroy"`
PositionInQueue int `json:"position_in_queue"`
Refresh bool `json:"refresh"`
RefreshOnly bool `json:"refresh_only"`
Status pgtype.Text `json:"status"`
PlanStatus pgtype.Text `json:"plan_status"`
ApplyStatus pgtype.Text `json:"apply_status"`
ReplaceAddrs []string `json:"replace_addrs"`
TargetAddrs []string `json:"target_addrs"`
AutoApply bool `json:"auto_apply"`
PlannedChanges *pggen.Report `json:"planned_changes"`
AppliedChanges *pggen.Report `json:"applied_changes"`
ConfigurationVersionID pgtype.Text `json:"configuration_version_id"`
WorkspaceID pgtype.Text `json:"workspace_id"`
Speculative bool `json:"speculative"`
ExecutionMode pgtype.Text `json:"execution_mode"`
Latest bool `json:"latest"`
OrganizationName pgtype.Text `json:"organization_name"`
IngressAttributes *pggen.IngressAttributes `json:"ingress_attributes"`
RunStatusTimestamps []pggen.RunStatusTimestamps `json:"run_status_timestamps"`
PlanStatusTimestamps []pggen.PhaseStatusTimestamps `json:"plan_status_timestamps"`
ApplyStatusTimestamps []pggen.PhaseStatusTimestamps `json:"apply_status_timestamps"`
}
RunResult represents the result of a database query for a run.
type RunService ¶
type RunService interface {
// Create a new run with the given options.
CreateRun(ctx context.Context, workspaceID string, opts RunCreateOptions) (*Run, error)
// Get retrieves a run with the given ID.
GetRun(ctx context.Context, id string) (*Run, error)
// List lists runs according to the given options.
ListRuns(ctx context.Context, opts RunListOptions) (*RunList, error)
// Delete deletes a run with the given ID.
DeleteRun(ctx context.Context, id string) error
// EnqueuePlan enqueues a plan
EnqueuePlan(ctx context.Context, id string) (*Run, error)
// Apply a run with the given ID.
//
// TODO: return run
ApplyRun(ctx context.Context, id string, opts RunApplyOptions) error
// Discard discards a run with the given ID.
//
// TODO: return run
DiscardRun(ctx context.Context, id string, opts RunDiscardOptions) error
// Cancel run.
//
// TODO: return run
CancelRun(ctx context.Context, id string, opts RunCancelOptions) error
// Forcefully cancel a run.
//
// TODO: return run
ForceCancelRun(ctx context.Context, id string, opts RunForceCancelOptions) error
// Start a run phase.
StartPhase(ctx context.Context, id string, phase PhaseType, opts PhaseStartOptions) (*Run, error)
// Finish a run phase.
FinishPhase(ctx context.Context, id string, phase PhaseType, opts PhaseFinishOptions) (*Run, error)
// GetPlanFile retrieves a run's plan file with the requested format.
GetPlanFile(ctx context.Context, id string, format PlanFormat) ([]byte, error)
// UploadPlanFile saves a run's plan file with the requested format.
UploadPlanFile(ctx context.Context, id string, plan []byte, format PlanFormat) error
// GetLockFile retrieves a run's lock file (.terraform.lock.hcl)
GetLockFile(ctx context.Context, id string) ([]byte, error)
// UploadLockFile saves a run's lock file (.terraform.lock.hcl)
UploadLockFile(ctx context.Context, id string, lockFile []byte) error
// Read and write logs for run phases.
LogService
// Tail logs of a run phase
Tail(ctx context.Context, opts GetChunkOptions) (<-chan Chunk, error)
// StartRun creates and starts a run.
StartRun(ctx context.Context, workspaceID string, opts ConfigurationVersionCreateOptions) (*Run, error)
}
RunService implementations allow interactions with runs
type RunStarter ¶ added in v0.0.19
type RunStarter struct {
Application
}
RunStarter starts a run triggered via the UI (whereas the terraform CLI takes care of calling all the API endpoints to start a run itself).
func (*RunStarter) StartRun ¶ added in v0.0.19
func (rs *RunStarter) StartRun(ctx context.Context, workspaceID string, opts ConfigurationVersionCreateOptions) (*Run, error)
type RunStatus ¶ added in v0.0.8
type RunStatus string
RunStatus represents a run state.
const ( // DefaultRefresh specifies that the state be refreshed prior to running a // plan DefaultRefresh = true // List all available run statuses supported in OTF. RunApplied RunStatus = "applied" RunApplyQueued RunStatus = "apply_queued" RunApplying RunStatus = "applying" RunCanceled RunStatus = "canceled" RunForceCanceled RunStatus = "force_canceled" RunConfirmed RunStatus = "confirmed" RunDiscarded RunStatus = "discarded" RunErrored RunStatus = "errored" RunPending RunStatus = "pending" RunPlanQueued RunStatus = "plan_queued" RunPlanned RunStatus = "planned" RunPlannedAndFinished RunStatus = "planned_and_finished" RunPlanning RunStatus = "planning" )
type RunStatusTimestamp ¶ added in v0.0.8
type RunStore ¶
type RunStore interface {
CreateRun(ctx context.Context, run *Run) error
GetRun(ctx context.Context, id string) (*Run, error)
SetPlanFile(ctx context.Context, id string, file []byte, format PlanFormat) error
GetPlanFile(ctx context.Context, id string, format PlanFormat) ([]byte, error)
SetLockFile(ctx context.Context, id string, file []byte) error
GetLockFile(ctx context.Context, id string) ([]byte, error)
ListRuns(ctx context.Context, opts RunListOptions) (*RunList, error)
// UpdateStatus updates the run's status, providing a func with which to
// perform updates in a transaction.
UpdateStatus(ctx context.Context, id string, fn func(*Run) error) (*Run, error)
CreatePlanReport(ctx context.Context, id string, report ResourceReport) error
CreateApplyReport(ctx context.Context, id string, report ResourceReport) error
DeleteRun(ctx context.Context, id string) error
}
RunStore implementations persist Run objects.
type Session ¶ added in v0.0.12
type Session struct {
// contains filtered or unexported fields
}
Session is a user session for the UI
func NewSession ¶ added in v0.0.12
NewSession constructs a new Session
func NewTestSession ¶ added in v0.0.12
func NewTestSession(t *testing.T, userID string, opts ...NewSessionOption) *Session
func UnmarshalSessionResult ¶ added in v0.0.12
func UnmarshalSessionResult(result SessionResult) *Session
type SessionResult ¶ added in v0.0.12
type SessionResult struct {
Token pgtype.Text `json:"token"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
Address pgtype.Text `json:"address"`
Expiry pgtype.Timestamptz `json:"expiry"`
UserID pgtype.Text `json:"user_id"`
}
type SessionService ¶ added in v0.0.12
type SessionService interface {
// CreateSession creates a user session.
CreateSession(ctx context.Context, userID, address string) (*Session, error)
// GetSession retrieves a session using its token.
GetSessionByToken(ctx context.Context, token string) (*Session, error)
// ListSessions lists current sessions for a user
ListSessions(ctx context.Context, userID string) ([]*Session, error)
// DeleteSession deletes the session with the given token
DeleteSession(ctx context.Context, token string) error
}
type SessionStore ¶ added in v0.0.12
type SessionStore interface {
// CreateSession persists a new session to the store.
CreateSession(ctx context.Context, session *Session) error
// GetSession retrieves a session using its token.
GetSessionByToken(ctx context.Context, token string) (*Session, error)
// ListSessions lists current sessions for a user
ListSessions(ctx context.Context, userID string) ([]*Session, error)
// DeleteSession deletes a session
DeleteSession(ctx context.Context, token string) error
}
SessionStore is a persistence store for user sessions.
type SortedModuleVersions ¶ added in v0.0.19
type SortedModuleVersions []*ModuleVersion
SortedModuleVersions is a list of module versions belonging to module, sorted by their semantic version, oldest version first
func (SortedModuleVersions) Len ¶ added in v0.0.19
func (l SortedModuleVersions) Len() int
func (SortedModuleVersions) Less ¶ added in v0.0.19
func (l SortedModuleVersions) Less(i, j int) bool
func (SortedModuleVersions) Swap ¶ added in v0.0.19
func (l SortedModuleVersions) Swap(i, j int)
type State ¶
type State struct {
Version int
Serial int64
Lineage string
Outputs map[string]StateOutput
}
State is terraform state.
func NewState ¶ added in v0.0.12
func NewState(opts StateCreateOptions, outputs ...StateOutput) *State
NewState constructs a new state
func UnmarshalState ¶ added in v0.0.12
UnmarshalState unmarshals terraform state from a raw byte slice.
type StateCreateOptions ¶ added in v0.0.12
StateCreateOptions are options for creating state
type StateOutput ¶
StateOutput is a terraform state output.
type StateVersion ¶
type StateVersion struct {
// contains filtered or unexported fields
}
StateVersion represents a Terraform Enterprise state version.
func NewStateVersion ¶ added in v0.0.12
func NewStateVersion(opts StateVersionCreateOptions) (*StateVersion, error)
NewStateVersion constructs a new state version.
func NewTestStateVersion ¶ added in v0.0.12
func NewTestStateVersion(t *testing.T, outputs ...StateOutput) *StateVersion
func UnmarshalStateVersionJSONAPI ¶ added in v0.0.12
func UnmarshalStateVersionJSONAPI(dto *jsonapi.StateVersion) *StateVersion
func UnmarshalStateVersionResult ¶ added in v0.0.12
func UnmarshalStateVersionResult(row StateVersionResult) (*StateVersion, error)
UnmarshalStateVersionResult unmarshals a database result query into a state version.
func (*StateVersion) CreatedAt ¶ added in v0.0.12
func (sv *StateVersion) CreatedAt() time.Time
func (*StateVersion) ID ¶
func (sv *StateVersion) ID() string
func (*StateVersion) Outputs ¶
func (sv *StateVersion) Outputs() []*StateVersionOutput
func (*StateVersion) Serial ¶
func (sv *StateVersion) Serial() int64
func (*StateVersion) State ¶ added in v0.0.8
func (sv *StateVersion) State() []byte
func (*StateVersion) String ¶ added in v0.0.8
func (sv *StateVersion) String() string
type StateVersionCreateOptions ¶ added in v0.0.8
type StateVersionCreateOptions struct {
Lineage *string
Serial *int64
State *string
MD5 *string
Run *Run
}
StateVersionCreateOptions represents the options for creating a state version. See dto.StateVersionCreateOptions for more details.
func (*StateVersionCreateOptions) Valid ¶ added in v0.0.12
func (opts *StateVersionCreateOptions) Valid() error
Valid validates state version create options
TODO: perform validation, check md5, etc
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 {
*Pagination
Items []*StateVersion
}
StateVersionList represents a list of state versions.
type StateVersionListOptions ¶ added in v0.0.8
type StateVersionListOptions struct {
ListOptions
Organization string `schema:"filter[organization][name],required"`
Workspace string `schema:"filter[workspace][name],required"`
}
StateVersionListOptions represents the options for listing state versions.
type StateVersionOutput ¶
type StateVersionOutput struct {
Name string
Sensitive bool
Type string
Value string
// contains filtered or unexported fields
}
func UnmarshalStateVersionOutputRow ¶ added in v0.0.12
func UnmarshalStateVersionOutputRow(row pggen.StateVersionOutputs) *StateVersionOutput
UnmarshalStateVersionOutputRow unmarshals a database row into a state version output.
func (*StateVersionOutput) ID ¶
func (svo *StateVersionOutput) ID() string
func (*StateVersionOutput) String ¶ added in v0.0.8
func (svo *StateVersionOutput) String() string
type StateVersionResult ¶ added in v0.0.12
type StateVersionResult struct {
StateVersionID pgtype.Text `json:"state_version_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
Serial int `json:"serial"`
State []byte `json:"state"`
WorkspaceID pgtype.Text `json:"workspace_id"`
StateVersionOutputs []pggen.StateVersionOutputs `json:"state_version_outputs"`
}
StateVersionResult represents the result of a database query for a state version.
type StateVersionService ¶
type StateVersionService interface {
CreateStateVersion(ctx context.Context, workspaceID string, opts StateVersionCreateOptions) (*StateVersion, error)
CurrentStateVersion(ctx context.Context, workspaceID string) (*StateVersion, error)
GetStateVersion(ctx context.Context, id string) (*StateVersion, error)
DownloadState(ctx context.Context, id string) ([]byte, error)
ListStateVersions(ctx context.Context, opts StateVersionListOptions) (*StateVersionList, error)
}
type StateVersionStore ¶
type StateVersionStore interface {
CreateStateVersion(ctx context.Context, workspaceID string, sv *StateVersion) error
GetStateVersion(ctx context.Context, opts StateVersionGetOptions) (*StateVersion, error)
GetState(ctx context.Context, id string) ([]byte, error)
ListStateVersions(ctx context.Context, opts StateVersionListOptions) (*StateVersionList, error)
DeleteStateVersion(ctx context.Context, id string) error
}
type Subject ¶ added in v0.0.12
type Subject interface {
CanAccessSite(action rbac.Action) bool
CanAccessOrganization(action rbac.Action, name string) bool
CanAccessWorkspace(action rbac.Action, policy *WorkspacePolicy) bool
Identity
}
Subject is an entity that carries out actions on resources.
type Superuser ¶ added in v0.0.19
type Superuser struct {
Username string
}
Superuser is a subject with unlimited privileges.
func (*Superuser) CanAccessOrganization ¶ added in v0.0.19
func (*Superuser) CanAccessSite ¶ added in v0.0.19
func (*Superuser) CanAccessWorkspace ¶ added in v0.0.19
func (*Superuser) CanAccessWorkspace(rbac.Action, *WorkspacePolicy) bool
type Team ¶ added in v0.0.12
type Team struct {
// contains filtered or unexported fields
}
Team is a group of users sharing a level of authorization.
func NewTeam ¶ added in v0.0.12
func NewTeam(name string, org *Organization, opts ...NewTeamOption) *Team
func NewTestOwners ¶ added in v0.0.19
func NewTestOwners(t *testing.T, org *Organization, opts ...NewTeamOption) *Team
func NewTestTeam ¶ added in v0.0.12
func NewTestTeam(t *testing.T, org *Organization, opts ...NewTeamOption) *Team
func UnmarshalTeamResult ¶ added in v0.0.12
func UnmarshalTeamResult(row TeamResult, opts ...NewTeamOption) *Team
func (*Team) Organization ¶ added in v0.0.12
func (*Team) OrganizationAccess ¶ added in v0.0.12
func (u *Team) OrganizationAccess() OrganizationAccess
func (*Team) Update ¶ added in v0.0.12
func (u *Team) Update(opts UpdateTeamOptions) error
type TeamResult ¶ added in v0.0.12
type TeamResult struct {
TeamID pgtype.Text `json:"team_id"`
Name pgtype.Text `json:"name"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
PermissionManageWorkspaces bool `json:"permission_manage_workspaces"`
PermissionManageVCS bool `json:"permission_manage_vcs"`
PermissionManageRegistry bool `json:"permission_manage_registry"`
OrganizationName pgtype.Text `json:"organization_name"`
}
TeamResult represents the result of a database query for a team.
type TeamService ¶ added in v0.0.12
type TeamService interface {
// CreateTeam creates a team with the given name belong to the named
// organization.
CreateTeam(ctx context.Context, opts CreateTeamOptions) (*Team, error)
UpdateTeam(ctx context.Context, teamID string, opts UpdateTeamOptions) (*Team, error)
// EnsureCreatedTeam retrieves a team; if they don't exist they'll be
// created.
EnsureCreatedTeam(ctx context.Context, opts CreateTeamOptions) (*Team, error)
// Get retrieves a team with the given ID
GetTeam(ctx context.Context, teamID string) (*Team, error)
// ListTeams lists teams in an organization.
ListTeams(ctx context.Context, organization string) ([]*Team, error)
// ListTeamMembers lists users that are members of the given team
ListTeamMembers(ctx context.Context, teamID string) ([]*User, error)
}
TeamService provides methods to interact with team accounts and their sessions.
type TeamStore ¶ added in v0.0.12
type TeamStore interface {
CreateTeam(ctx context.Context, team *Team) error
UpdateTeam(ctx context.Context, teamID string, fn func(*Team) error) (*Team, error)
GetTeam(ctx context.Context, name, organization string) (*Team, error)
GetTeamByID(ctx context.Context, teamID string) (*Team, error)
DeleteTeam(ctx context.Context, teamID string) error
ListTeams(ctx context.Context, organization string) ([]*Team, error)
// ListTeamMembers lists users that are members of the given team
ListTeamMembers(ctx context.Context, teamID string) ([]*User, error)
}
TeamStore is a persistence store for team accounts.
type TerraformModule ¶ added in v0.0.19
func UnmarshalTerraformModule ¶ added in v0.0.19
func UnmarshalTerraformModule(tarball []byte) (*TerraformModule, error)
func (*TerraformModule) Readme ¶ added in v0.0.19
func (m *TerraformModule) Readme() []byte
type TestRunCreateOptions ¶ added in v0.0.12
type TestRunCreateOptions struct {
ID *string // override ID of run
Speculative bool
ExecutionMode *ExecutionMode
Status RunStatus
AutoApply *bool
Repo *WorkspaceRepo
IngressAttributes *IngressAttributes
Workspace *Workspace // run's workspace; if nil a workspace is auto created
}
TestRunCreateOptions is for testing purposes only.
type Token ¶ added in v0.0.12
type Token struct {
// contains filtered or unexported fields
}
Token is a user authentication token.
func UnmarshalTokenResult ¶ added in v0.0.12
func UnmarshalTokenResult(result pggen.FindTokensByUserIDRow) *Token
func (*Token) Description ¶ added in v0.0.12
type TokenCreateOptions ¶ added in v0.0.12
type TokenCreateOptions struct {
Description string
}
type TokenService ¶ added in v0.0.12
type TokenService interface {
// CreateToken creates a user token.
CreateToken(ctx context.Context, userID string, opts *TokenCreateOptions) (*Token, error)
// ListTokens lists API tokens for a user
ListTokens(ctx context.Context, userID string) ([]*Token, error)
// DeleteToken deletes a user token.
DeleteToken(ctx context.Context, userID string, tokenID string) error
}
type TokenStore ¶ added in v0.0.12
type TokenStore interface {
// CreateToken creates a user token.
CreateToken(ctx context.Context, token *Token) error
// ListTokens lists user tokens.
ListTokens(ctx context.Context, userID string) ([]*Token, error)
// DeleteToken deletes a user token.
DeleteToken(ctx context.Context, id string) error
}
TokenStore is a persistence store for user authentication tokens.
type UnhookCallback ¶ added in v0.0.23
type UnhookOptions ¶ added in v0.0.23
type UnhookOptions struct {
HookID uuid.UUID
UnhookCallback
cloud.Client
}
type Unlocked ¶ added in v0.0.12
type Unlocked struct {
// zero identity because an unlocked workspace lock state has no identity
Identity
}
Unlocked is an unlocked workspace lock
type Unmarshaler ¶ added in v0.0.19
Unmarshaler unmarshals database rows
func (*Unmarshaler) UnmarshalVCSProviderRow ¶ added in v0.0.19
func (u *Unmarshaler) UnmarshalVCSProviderRow(row VCSProviderRow) (*VCSProvider, error)
UnmarshalVCSProviderRow unmarshals a vcs provider row from the database.
type UpdateModuleStatusOptions ¶ added in v0.0.19
type UpdateModuleStatusOptions struct {
ID string
Status ModuleStatus
}
type UpdateModuleVersionStatusOptions ¶ added in v0.0.19
type UpdateModuleVersionStatusOptions struct {
ID string
Status ModuleVersionStatus
Error string
}
type UpdateTeamOptions ¶ added in v0.0.19
type UpdateTeamOptions struct {
OrganizationAccess
}
type UpdateVariableOptions ¶ added in v0.0.20
type UpdateWorkspaceOptions ¶ added in v0.0.21
type UpdateWorkspaceOptions 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
}
UpdateWorkspaceOptions represents the options for updating a workspace.
type UploadModuleVersionOptions ¶ added in v0.0.19
type User ¶ added in v0.0.12
type User struct {
// contains filtered or unexported fields
}
User represents an otf user account.
func NewTestUser ¶ added in v0.0.12
func NewTestUser(t *testing.T, opts ...NewUserOption) *User
func NewUser ¶ added in v0.0.12
func NewUser(username string, opts ...NewUserOption) *User
func UnmarshalUserResult ¶ added in v0.0.12
func UnmarshalUserResult(row UserResult, opts ...NewUserOption) *User
func UserFromContext ¶ added in v0.0.12
UserFromContext retrieves a user from a context
func (*User) CanAccessOrganization ¶ added in v0.0.12
func (*User) CanAccessWorkspace ¶ added in v0.0.12
func (u *User) CanAccessWorkspace(action rbac.Action, policy *WorkspacePolicy) bool
func (*User) CanLock ¶ added in v0.0.12
CanLock always returns an error because nothing can replace a user lock
func (*User) CanUnlock ¶ added in v0.0.12
CanUnlock decides whether to permits requestor to unlock a user lock
func (*User) IsSiteAdmin ¶ added in v0.0.12
func (*User) IsTeamMember ¶ added in v0.0.19
IsTeamMember determines whether user is a member of the given team.
func (*User) IsUnprivilegedUser ¶ added in v0.0.12
func (*User) Organizations ¶ added in v0.0.12
func (*User) SyncMemberships ¶ added in v0.0.12
func (u *User) SyncMemberships(ctx context.Context, store UserStore, orgs []string, teams []*Team) error
SyncMemberships synchronises the user's organization and team memberships to match those given, adding and removing memberships in the persistence store accordingly.
func (*User) TeamsByOrganization ¶ added in v0.0.12
TeamsByOrganization return a user's teams filtered by organization name
type UserListOptions ¶ added in v0.0.12
UserListOptions are options for the ListUsers endpoint.
type UserResult ¶ added in v0.0.12
type UserResult struct {
UserID pgtype.Text `json:"user_id"`
Username pgtype.Text `json:"username"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
Organizations []string `json:"organizations"`
Teams []pggen.Teams `json:"teams"`
}
UserResult represents the result of a database query for a user.
type UserService ¶ added in v0.0.12
type UserService interface {
// CreateUser creates a user with the given username.
CreateUser(ctx context.Context, username string) (*User, error)
// EnsureCreatedUser retrieves a user; if they don't exist they'll be
// created.
EnsureCreatedUser(ctx context.Context, username string) (*User, error)
// Get retrieves a user according to the spec.
GetUser(ctx context.Context, spec UserSpec) (*User, error)
// SyncUserMemberships makes the user a member of the specified organizations
// and teams and removes any existing memberships not specified.
SyncUserMemberships(ctx context.Context, user *User, orgs []string, teams []*Team) (*User, error)
// ListUsers lists users.
ListUsers(ctx context.Context, opts UserListOptions) ([]*User, error)
}
UserService provides methods to interact with user accounts and their sessions.
type UserSpec ¶ added in v0.0.12
type UserStore ¶ added in v0.0.12
type UserStore interface {
CreateUser(ctx context.Context, user *User) error
GetUser(ctx context.Context, spec UserSpec) (*User, error)
// ListUsers lists users.
ListUsers(ctx context.Context, opts UserListOptions) ([]*User, error)
DeleteUser(ctx context.Context, spec UserSpec) error
// AddOrganizationMembership adds a user as a member of an organization
AddOrganizationMembership(ctx context.Context, id, orgID string) error
// RemoveOrganizationMembership removes a user as a member of an
// organization
RemoveOrganizationMembership(ctx context.Context, id, orgID string) error
// AddTeamMembership adds a user as a member of a team
AddTeamMembership(ctx context.Context, id, teamID string) error
// RemoveTeamMembership removes a user as a member of an
// team
RemoveTeamMembership(ctx context.Context, id, teamID string) error
}
UserStore is a persistence store for user accounts.
type VCSProvider ¶ added in v0.0.16
type VCSProvider struct {
// contains filtered or unexported fields
}
VCSProvider provides authenticated access to a VCS. Equivalent to an OAuthClient in TFE.
func NewTestVCSProvider ¶ added in v0.0.16
func NewTestVCSProvider(t *testing.T, organization *Organization) *VCSProvider
func (*VCSProvider) CloudConfig ¶ added in v0.0.19
func (t *VCSProvider) CloudConfig() cloud.Config
func (*VCSProvider) CreatedAt ¶ added in v0.0.16
func (t *VCSProvider) CreatedAt() time.Time
func (*VCSProvider) ID ¶ added in v0.0.16
func (t *VCSProvider) ID() string
func (*VCSProvider) MarshalLog ¶ added in v0.0.19
func (t *VCSProvider) MarshalLog() any
func (*VCSProvider) Name ¶ added in v0.0.16
func (t *VCSProvider) Name() string
func (*VCSProvider) Organization ¶ added in v0.0.21
func (t *VCSProvider) Organization() string
func (*VCSProvider) String ¶ added in v0.0.16
func (t *VCSProvider) String() string
func (*VCSProvider) Token ¶ added in v0.0.16
func (t *VCSProvider) Token() string
type VCSProviderCreateOptions ¶ added in v0.0.16
type VCSProviderFactory ¶ added in v0.0.19
VCSProviderFactory makes vcs providers
func (*VCSProviderFactory) NewVCSProvider ¶ added in v0.0.19
func (f *VCSProviderFactory) NewVCSProvider(opts VCSProviderCreateOptions) (*VCSProvider, error)
type VCSProviderRow ¶ added in v0.0.16
type VCSProviderRow struct {
VCSProviderID pgtype.Text `json:"id"`
Token pgtype.Text `json:"token"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
Name pgtype.Text `json:"name"`
Cloud pgtype.Text `json:"cloud"`
OrganizationName pgtype.Text `json:"organization_name"`
}
VCSProviderRow represents a database row for a vcs provider
type VCSProviderService ¶ added in v0.0.16
type VCSProviderService interface {
CreateVCSProvider(ctx context.Context, opts VCSProviderCreateOptions) (*VCSProvider, error)
GetVCSProvider(ctx context.Context, id string) (*VCSProvider, error)
ListVCSProviders(ctx context.Context, organization string) ([]*VCSProvider, error)
DeleteVCSProvider(ctx context.Context, id string) (*VCSProvider, error)
// GetVCSClient combines retrieving a vcs provider and construct a cloud
// client from that provider.
//
// TODO: rename vcs provider to cloud client; the central purpose of the vcs
// provider is, after all, to construct a cloud client.
GetVCSClient(ctx context.Context, providerID string) (cloud.Client, error)
}
VCSProviderService provides access to vcs providers
type VCSProviderStore ¶ added in v0.0.16
type VCSProviderStore interface {
CreateVCSProvider(ctx context.Context, provider *VCSProvider) error
GetVCSProvider(ctx context.Context, id string) (*VCSProvider, error)
ListVCSProviders(ctx context.Context, organization string) ([]*VCSProvider, error)
DeleteVCSProvider(ctx context.Context, id string) error
}
VCSProviderStore persists vcs providers
type Variable ¶ added in v0.0.20
type Variable struct {
// contains filtered or unexported fields
}
func NewTestVariable ¶ added in v0.0.20
func NewTestVariable(t *testing.T, ws *Workspace, opts CreateVariableOptions) *Variable
func NewVariable ¶ added in v0.0.20
func NewVariable(workspaceID string, opts CreateVariableOptions) (*Variable, error)
func UnmarshalVariableJSONAPI ¶ added in v0.0.20
func UnmarshalVariableListJSONAPI ¶ added in v0.0.20
func UnmarshalVariableListJSONAPI(json *dto.VariableList) []*Variable
UnmarshalVariableListJSONAPI converts a DTO into a workspace list
func UnmarshalVariableRow ¶ added in v0.0.20
func UnmarshalVariableRow(result VariableRow) *Variable
func (*Variable) Category ¶ added in v0.0.20
func (v *Variable) Category() VariableCategory
func (*Variable) Description ¶ added in v0.0.20
func (*Variable) MarshalLog ¶ added in v0.0.20
func (*Variable) Update ¶ added in v0.0.20
func (v *Variable) Update(opts UpdateVariableOptions) error
func (*Variable) WorkspaceID ¶ added in v0.0.20
type VariableCategory ¶ added in v0.0.20
type VariableCategory string
VariableCategory is the category of variable
func VariableCategoryPtr ¶ added in v0.0.20
func VariableCategoryPtr(v VariableCategory) *VariableCategory
VariableCategoryPtr returns a pointer to the given category type.
type VariableRow ¶ added in v0.0.20
type VariableRow struct {
VariableID pgtype.Text `json:"variable_id"`
Key pgtype.Text `json:"key"`
Value pgtype.Text `json:"value"`
Description pgtype.Text `json:"description"`
Category pgtype.Text `json:"category"`
Sensitive bool `json:"sensitive"`
HCL bool `json:"hcl"`
WorkspaceID pgtype.Text `json:"workspace_id"`
}
type VariableService ¶ added in v0.0.20
type VariableService interface {
CreateVariable(ctx context.Context, workspaceID string, opts CreateVariableOptions) (*Variable, error)
ListVariables(ctx context.Context, workspaceID string) ([]*Variable, error)
GetVariable(ctx context.Context, variableID string) (*Variable, error)
UpdateVariable(ctx context.Context, variableID string, opts UpdateVariableOptions) (*Variable, error)
DeleteVariable(ctx context.Context, variableID string) (*Variable, error)
}
type VariableStore ¶ added in v0.0.20
type VariableStore interface {
CreateVariable(ctx context.Context, variable *Variable) error
ListVariables(ctx context.Context, workspaceID string) ([]*Variable, error)
GetVariable(ctx context.Context, variableID string) (*Variable, error)
UpdateVariable(ctx context.Context, variableID string, updateFn func(*Variable) error) (*Variable, error)
DeleteVariable(ctx context.Context, variableID string) (*Variable, error)
}
type WatchLogsOptions ¶ added in v0.0.12
type WatchLogsOptions WatchOptions
WatchLogsOptions filters logs returned by the WatchLogs endpoint.
type WatchOptions ¶ added in v0.0.12
type WatchOptions struct {
// Name to uniquely describe the watcher. If not provided then a
// name will be auto generated.
Name *string
Organization *string `schema:"organization_name"` // filter by organization name
WorkspaceID *string `schema:"workspace_id"` // filter by workspace ID; mutually exclusive with organization filter
}
WatchOptions filters events returned by the Watch endpoint.
type Workspace ¶
type Workspace struct {
// contains filtered or unexported fields
}
Workspace represents a Terraform Enterprise workspace.
func NewTestWorkspace ¶ added in v0.0.12
func NewTestWorkspace(t *testing.T, org *Organization, opts ...NewTestWorkspaceOption) *Workspace
func NewWorkspace ¶
func NewWorkspace(opts CreateWorkspaceOptions) (*Workspace, error)
func UnmarshalWorkspaceJSONAPI ¶ added in v0.0.12
func UnmarshalWorkspaceResult ¶ added in v0.0.12
func UnmarshalWorkspaceResult(result WorkspaceResult) (*Workspace, error)
func (*Workspace) AllowDestroyPlan ¶
func (*Workspace) CanQueueDestroyPlan ¶
func (*Workspace) Description ¶
func (*Workspace) Environment ¶
func (*Workspace) ExecutionMode ¶
func (ws *Workspace) ExecutionMode() ExecutionMode
func (*Workspace) ExecutionModes ¶ added in v0.0.12
ExecutionModes returns a list of possible execution modes
func (*Workspace) FileTriggersEnabled ¶
func (*Workspace) GetLock ¶ added in v0.0.12
func (ws *Workspace) GetLock() WorkspaceLockState
func (*Workspace) GlobalRemoteState ¶
func (*Workspace) LatestRunID ¶ added in v0.0.12
func (*Workspace) Lock ¶ added in v0.0.12
func (ws *Workspace) Lock(lock WorkspaceLockState) error
Lock transfers a workspace into the given lock state
func (*Workspace) MarshalLog ¶ added in v0.0.20
func (*Workspace) MigrationEnvironment ¶
func (*Workspace) Organization ¶
func (*Workspace) QualifiedName ¶ added in v0.0.12
func (ws *Workspace) QualifiedName() WorkspaceQualifiedName
QualifiedName returns the workspace's qualified name including the name of its organization
func (*Workspace) QueueAllRuns ¶
func (*Workspace) Repo ¶ added in v0.0.19
func (ws *Workspace) Repo() *WorkspaceRepo
func (*Workspace) SetLatestRun ¶ added in v0.0.23
func (*Workspace) SourceName ¶
func (*Workspace) SpeculativeEnabled ¶
func (*Workspace) StructuredRunOutputEnabled ¶
func (*Workspace) TerraformVersion ¶
func (*Workspace) TriggerPrefixes ¶
func (*Workspace) Update ¶ added in v0.0.21
func (ws *Workspace) Update(opts UpdateWorkspaceOptions) error
Update updates the workspace with the given options.
func (*Workspace) WorkingDirectory ¶
type WorkspaceConnectionService ¶ added in v0.0.19
type WorkspaceConnectionService interface {
ConnectWorkspace(ctx context.Context, workspaceID string, opts ConnectWorkspaceOptions) error
UpdateWorkspaceRepo(ctx context.Context, workspaceID string, repo WorkspaceRepo) (*Workspace, error)
DisconnectWorkspace(ctx context.Context, workspaceID string) (*Workspace, error)
}
type WorkspaceConnector ¶ added in v0.0.19
type WorkspaceConnector interface {
Connect(ctx context.Context, workspaceID string, opts ConnectWorkspaceOptions) error
Disconnect(ctx context.Context, workspaceID string) (*Workspace, error)
}
WorkspaceConnector connects a workspace to a VCS repo, subscribing it to VCS events that trigger runs.
type WorkspaceList ¶
type WorkspaceList struct {
*Pagination
Items []*Workspace
}
WorkspaceList represents a list of Workspaces.
func UnmarshalWorkspaceListJSONAPI ¶ added in v0.0.12
func UnmarshalWorkspaceListJSONAPI(json *dto.WorkspaceList) *WorkspaceList
UnmarshalWorkspaceListJSONAPI converts a DTO into a workspace list
type WorkspaceListOptions ¶
type WorkspaceListOptions struct {
// Pagination
ListOptions
// Filter workspaces with name matching prefix.
Prefix string `schema:"search[name],omitempty"`
// Organization filters workspaces by organization name.
Organization *string `schema:"organization_name,omitempty"`
// Filter by those for which user has workspace-level permissions.
UserID *string
}
WorkspaceListOptions are options for paginating and filtering a list of Workspaces
type WorkspaceLockOptions ¶ added in v0.0.8
type WorkspaceLockOptions struct {
// Specifies the reason for locking the workspace.
Reason *string `jsonapi:"attr,reason,omitempty"`
}
WorkspaceLockOptions represents the options for locking a workspace.
type WorkspaceLockService ¶ added in v0.0.12
type WorkspaceLockState ¶ added in v0.0.12
type WorkspaceLockState interface {
// CanLock checks whether it can be locked by subject
CanLock(subject Identity) error
// CanUnlock checks whether it can be unlocked by subject
CanUnlock(subject Identity, force bool) error
// A lock state has an identity, i.e. the name of the run or user that has
// locked the workspace
Identity
}
WorkspaceLockState is the state a workspace lock is currently in (i.e. unlocked, run-locked, or user-locked)
func LockFromContext ¶ added in v0.0.12
func LockFromContext(ctx context.Context) (WorkspaceLockState, error)
LockFromContext retrieves a workspace lock from a context
type WorkspacePermission ¶ added in v0.0.12
WorkspacePermission binds a role to a team.
func UnmarshalWorkspacePermissionResult ¶ added in v0.0.12
func UnmarshalWorkspacePermissionResult(row WorkspacePermissionResult) (*WorkspacePermission, error)
type WorkspacePermissionResult ¶ added in v0.0.12
type WorkspacePermissionResult struct {
Role pgtype.Text `json:"role"`
Team *pggen.Teams `json:"team"`
Organization *pggen.Organizations `json:"organization"`
}
WorkspacePermissionResult represents the result of a database query for a workspace permission.
type WorkspacePermissionService ¶ added in v0.0.12
type WorkspacePermissionService interface {
SetWorkspacePermission(ctx context.Context, workspaceID, team string, role rbac.Role) error
ListWorkspacePermissions(ctx context.Context, workspaceID string) ([]*WorkspacePermission, error)
UnsetWorkspacePermission(ctx context.Context, workspaceID, team string) error
}
type WorkspacePolicy ¶ added in v0.0.12
type WorkspacePolicy struct {
Organization string
WorkspaceID string
Permissions []*WorkspacePermission
}
WorkspacePolicy binds workspace permissions to a workspace
type WorkspaceQualifiedName ¶ added in v0.0.12
WorkspaceQualifiedName is the workspace's fully qualified name including the name of its organization
type WorkspaceRepo ¶ added in v0.0.19
type WorkspaceRepo struct {
ProviderID string
WebhookID uuid.UUID
Identifier string // identifier is <repo_owner>/<repo_name>
Branch string // branch for which applies are run
WorkspaceID string
}
WorkspaceRepo represents a connection between a workspace and a VCS repository.
TODO: rename WorkspaceConnection
func NewTestWorkspaceRepo ¶ added in v0.0.19
func NewTestWorkspaceRepo(provider *VCSProvider) *WorkspaceRepo
type WorkspaceResult ¶ added in v0.0.12
type WorkspaceResult struct {
WorkspaceID pgtype.Text `json:"workspace_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
AllowDestroyPlan bool `json:"allow_destroy_plan"`
AutoApply bool `json:"auto_apply"`
CanQueueDestroyPlan bool `json:"can_queue_destroy_plan"`
Description pgtype.Text `json:"description"`
Environment pgtype.Text `json:"environment"`
ExecutionMode pgtype.Text `json:"execution_mode"`
FileTriggersEnabled bool `json:"file_triggers_enabled"`
GlobalRemoteState bool `json:"global_remote_state"`
MigrationEnvironment pgtype.Text `json:"migration_environment"`
Name pgtype.Text `json:"name"`
QueueAllRuns bool `json:"queue_all_runs"`
SpeculativeEnabled bool `json:"speculative_enabled"`
SourceName pgtype.Text `json:"source_name"`
SourceURL pgtype.Text `json:"source_url"`
StructuredRunOutputEnabled bool `json:"structured_run_output_enabled"`
TerraformVersion pgtype.Text `json:"terraform_version"`
TriggerPrefixes []string `json:"trigger_prefixes"`
WorkingDirectory pgtype.Text `json:"working_directory"`
LockRunID pgtype.Text `json:"lock_run_id"`
LockUserID pgtype.Text `json:"lock_user_id"`
LatestRunID pgtype.Text `json:"latest_run_id"`
OrganizationName pgtype.Text `json:"organization_name"`
UserLock *pggen.Users `json:"user_lock"`
RunLock *pggen.Runs `json:"run_lock"`
WorkspaceRepo *pggen.WorkspaceRepos `json:"workspace_repo"`
Webhook *pggen.Webhooks `json:"webhook"`
}
WorkspaceResult represents the result of a database query for a workspace.
type WorkspaceService ¶
type WorkspaceService interface {
CreateWorkspace(ctx context.Context, opts CreateWorkspaceOptions) (*Workspace, error)
GetWorkspace(ctx context.Context, workspaceID string) (*Workspace, error)
GetWorkspaceByName(ctx context.Context, organization, workspace string) (*Workspace, error)
ListWorkspaces(ctx context.Context, opts WorkspaceListOptions) (*WorkspaceList, error)
// ListWorkspacesByWebhookID retrieves workspaces by webhook ID.
//
// TODO: rename to ListConnectedWorkspaces
ListWorkspacesByWebhookID(ctx context.Context, id uuid.UUID) ([]*Workspace, error)
UpdateWorkspace(ctx context.Context, workspaceID string, opts UpdateWorkspaceOptions) (*Workspace, error)
DeleteWorkspace(ctx context.Context, workspaceID string) (*Workspace, error)
WorkspaceLockService
CurrentRunService
WorkspacePermissionService
WorkspaceConnectionService
}
type WorkspaceStore ¶
type WorkspaceStore interface {
CreateWorkspace(ctx context.Context, ws *Workspace) error
GetWorkspace(ctx context.Context, workspaceID string) (*Workspace, error)
GetWorkspaceByName(ctx context.Context, organization, workspace string) (*Workspace, error)
ListWorkspaces(ctx context.Context, opts WorkspaceListOptions) (*WorkspaceList, error)
ListWorkspacesByUserID(ctx context.Context, userID string, organization string, opts ListOptions) (*WorkspaceList, error)
ListWorkspacesByWebhookID(ctx context.Context, id uuid.UUID) ([]*Workspace, error)
UpdateWorkspace(ctx context.Context, workspaceID string, ws func(ws *Workspace) error) (*Workspace, error)
DeleteWorkspace(ctx context.Context, workspaceID string) error
GetWorkspaceIDByRunID(ctx context.Context, runID string) (string, error)
GetWorkspaceIDByStateVersionID(ctx context.Context, svID string) (string, error)
GetWorkspaceIDByCVID(ctx context.Context, cvID string) (string, error)
// CreateWorkspaceRepo creates a workspace repo in the persistence store.
CreateWorkspaceRepo(ctx context.Context, workspaceID string, repo WorkspaceRepo) (*Workspace, error)
// UpdateWorkspaceRepo updates a workspace's repo in the persistence store.
UpdateWorkspaceRepo(ctx context.Context, workspaceID string, repo WorkspaceRepo) (*Workspace, error)
// DeleteWorkspaceRepo deletes a workspace's repo from the persistence
// store, returning the workspace without the repo as well the original repo, or an
// error.
DeleteWorkspaceRepo(ctx context.Context, workspaceID string) (*Workspace, error)
WorkspaceLockService
CurrentRunService
WorkspacePermissionService
}
WorkspaceStore is a persistence store for workspaces.
type WorkspaceUnlockOptions ¶ added in v0.0.12
type WorkspaceUnlockOptions struct {
// Specifies the reason for locking the workspace.
Reason *string `jsonapi:"attr,reason,omitempty"`
// Force unlock of workspace
Force bool
}
WorkspaceUnlockOptions represents the options for unlocking a workspace.
Source Files
¶
- agent_token.go
- apply.go
- authz.go
- cache.go
- chunk.go
- configuration_version.go
- configuration_version_unmarshaller.go
- entitlements.go
- environment.go
- errors.go
- events.go
- git.go
- hcl_rewriter.go
- hook.go
- hostname.go
- job_writer.go
- module.go
- module_version.go
- organization.go
- organization_unmarshaller.go
- otf.go
- pagination.go
- parse_apply_output.go
- phase.go
- plan.go
- plan_file.go
- publisher.go
- registry_session.go
- reporter.go
- run.go
- run_factory.go
- run_factory_test_helpers.go
- run_starter.go
- run_unmarshaller.go
- session.go
- ssl.go
- state.go
- state_version.go
- state_version_output.go
- team.go
- team_unmarshaller.go
- terraform_module.go
- test_helpers.go
- token.go
- triggerer.go
- unpack.go
- user.go
- user_unmarshaller.go
- variable.go
- vcs_provider.go
- version.go
- workspace.go
- workspace_connector.go
- workspace_factory.go
- workspace_lock.go
- workspace_repo.go
- workspace_unmarshaller.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. |
|
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 cloud provides types for use with cloud providers.
|
Package cloud provides types for use with cloud providers. |
|
Package cmd provides CLI functionality.
|
Package cmd provides CLI functionality. |
|
otf
command
|
|
|
otf-agent
command
|
|
|
otfd
command
|
|
|
Package github provides github related code
|
Package github provides github related code |
|
Package gitlab provides gitlab related code
|
Package gitlab provides gitlab related code |
|
Package hooks manages webhooks on VCS repos.
|
Package hooks manages webhooks on VCS repos. |
|
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. |
|
decode
Package decode contains decoders for various HTTP artefacts
|
Package decode contains decoders for various HTTP artefacts |
|
dto
Package dto provides DTO models for serialization/deserialization to/from JSON-API
|
Package dto provides DTO models for serialization/deserialization to/from JSON-API |
|
html
Package html provides the otf web app, serving up HTML formatted pages and associated assets (CSS, JS, etc).
|
Package html provides the otf web app, serving up HTML formatted pages and associated assets (CSS, JS, etc). |
|
html/paths
Package paths provides rails-style path helpers for use with the web app.
|
Package paths provides rails-style path helpers for use with the web app. |
|
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 module is reponsible for registry modules
|
Package module is reponsible for registry modules |
|
Package semver wraps golang.org/x/mod/semver, relaxing the requirement for semantic versions to be prefixed with "v".
|
Package semver wraps golang.org/x/mod/semver, relaxing the requirement for semantic versions to be prefixed with "v". |
|
Package sql implements persistent storage using the sql database.
|
Package sql implements persistent storage using the sql database. |
|
Package triggerer handles triggering things in response to incoming VCS events.
|
Package triggerer handles triggering things in response to incoming VCS events. |