workspaces

package
v0.0.0-...-699ca5e Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DriftDetection

type DriftDetection struct {
	Enabled  bool   `json:"enabled"`
	Schedule string `json:"schedule"`
}

type UpdateWorkspaceParams

type UpdateWorkspaceParams struct {
	AgentId *uuid.UUID `json:"agent_id,omitempty"`
}

type Workspace

type Workspace struct {
	ID        uuid.UUID  `gorm:"type:uuid;default:gen_random_uuid()" json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `sql:"index" json:"deleted_at"`

	// Name of the workspace
	Name string `gorm:"index:idx_name,unique" json:"name"`
	// Does the workspace allow destroy plans
	AllowDestroy bool `json:"allow_destroy"`
	// Does the workspace auto apply planned runs
	AutoApply bool `json:"auto_apply"`
	// Schedule the workspace for auto destruction
	AutoDestroyAt *time.Time `json:"auto_destroy_at" sql:"index"`
	// How our applies executed? Possible values are
	// - apply_on_pull_request
	// - apply_on_merge
	ExecutionMode string `json:"execution_mode"`
	// Configuration for the VCS containing the IaC
	Vcs WorkspaceVcsConnection `gorm:"embedded;embeddedPrefix:vcs_" json:"vcs"`
	// The opentofu version for the workspace
	// Can be set to 'latest' to always pull the latest available version
	Version string `json:"version"`
	// Is the workspace currently locked
	Locked bool `json:"locked"`
	// Lock configuration
	// TODO: Just move this to top level fields, no need
	// to embed this as a separate object
	Lock WorkspaceLock `gorm:"embedded;embeddedPrefix:lock_" json:"lock,omitempty"`
	// ID of the owning organization
	OrganizationID uuid.UUID                 `gorm:"index:idx_name,unique" json:"organization_id"`
	Organization   organization.Organization `json:"-"`

	// Agent configuration
	AgentID *uuid.UUID  `json:"-"`
	Agent   agent.Agent `json:"agent,omitempty"`

	// DriftDetection
	DriftDetection DriftDetection `gorm:"embedded;embeddedPrefix:drift_detection_" json:"drift_detection"`
}

type WorkspaceLock

type WorkspaceLock struct {
	// Who is the workspace locked by. Should be either
	// - user ID
	// - execution ID
	By string `json:"by"`
	// Time the workspace was locked at
	At string `json:"at"`
	// Lock ID
	Id string `json:"id"`
}

type WorkspaceVcsConnection

type WorkspaceVcsConnection struct {
	// The Git URL for the workspace
	Source string `json:"source"`
	// Which branch we're applying / watching for PRs to
	Branch string `json:"branch"`
	// Patterns to match for executing
	Patterns []string `json:"patterns" gorm:"serializer:json"`
	// Prefixes to match for executing
	Prefixes []string `json:"prefixes" gorm:"serializer:json"`
	// Specify the working directory
	WorkingDirectory string `json:"working_directory"`
}

type WorkspacesRepository

type WorkspacesRepository interface {
	Save(workspace *Workspace) error
	Update(workspace *Workspace) (*Workspace, error)
	Lock(workspace *Workspace) error
	Unlock(workspace *Workspace) error
	Delete(workspaceId string) error
	FindById(organizationId uuid.UUID, workspaceId string) (*Workspace, error)
	FindAll() ([]Workspace, error)
	FindAllForOrg(organizationId uuid.UUID) ([]Workspace, error)
}

func NewWorkspacesRepository

func NewWorkspacesRepository(db *gorm.DB) WorkspacesRepository

type WorkspacesRepositoryImpl

type WorkspacesRepositoryImpl struct {
	Db *gorm.DB
}

func (WorkspacesRepositoryImpl) Delete

func (w WorkspacesRepositoryImpl) Delete(workspaceId string) error

func (WorkspacesRepositoryImpl) FindAll

func (w WorkspacesRepositoryImpl) FindAll() ([]Workspace, error)

func (WorkspacesRepositoryImpl) FindAllForOrg

func (w WorkspacesRepositoryImpl) FindAllForOrg(organizationId uuid.UUID) ([]Workspace, error)

func (WorkspacesRepositoryImpl) FindById

func (w WorkspacesRepositoryImpl) FindById(organizationId uuid.UUID, workspaceId string) (*Workspace, error)

func (WorkspacesRepositoryImpl) Lock

func (w WorkspacesRepositoryImpl) Lock(workspace *Workspace) error

func (WorkspacesRepositoryImpl) Save

func (w WorkspacesRepositoryImpl) Save(workspace *Workspace) error

func (WorkspacesRepositoryImpl) Unlock

func (w WorkspacesRepositoryImpl) Unlock(workspace *Workspace) error

func (WorkspacesRepositoryImpl) Update

func (w WorkspacesRepositoryImpl) Update(workspace *Workspace) (*Workspace, error)

type WorkspacesService

type WorkspacesService interface {
	Create(workspace *Workspace) error
	Update(workspace *Workspace) error
	Delete(workspaceId string) error
	FindById(workspaceId string) (*Workspace, error)
	FindAll() ([]Workspace, error)
}

func NewWorkspacesServiceImpl

func NewWorkspacesServiceImpl(repository WorkspacesRepository, validate *validator.Validate) WorkspacesService

type WorkspacesServiceImpl

type WorkspacesServiceImpl struct {
	Repository WorkspacesRepository
	Validate   *validator.Validate
}

func (WorkspacesServiceImpl) Create

func (s WorkspacesServiceImpl) Create(workspace *Workspace) error

func (WorkspacesServiceImpl) Delete

func (s WorkspacesServiceImpl) Delete(workspaceId string) error

func (WorkspacesServiceImpl) FindAll

func (s WorkspacesServiceImpl) FindAll() ([]Workspace, error)

func (WorkspacesServiceImpl) FindById

func (s WorkspacesServiceImpl) FindById(workspaceId string) (*Workspace, error)

func (WorkspacesServiceImpl) Update

func (s WorkspacesServiceImpl) Update(workspace *Workspace) error

Jump to

Keyboard shortcuts

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