workspace

package
v2.16.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BaseConfigDirName is the directory below DAGsDir that stores workspace-scoped config.
	BaseConfigDirName = "workspaces"
	// BaseConfigFileName is the file name for a workspace-scoped base config.
	BaseConfigFileName = "base.yaml"
)

Variables

View Source
var (
	ErrWorkspaceNotFound      = errors.New("workspace not found")
	ErrWorkspaceAlreadyExists = errors.New("workspace with this name already exists")
	ErrInvalidWorkspaceName   = errors.New("invalid workspace name")
	ErrInvalidWorkspaceID     = errors.New("invalid workspace ID")
)

Common errors for workspace store operations.

Functions

func BaseConfigDir

func BaseConfigDir(dagsDir string) string

BaseConfigDir returns the root directory for workspace-scoped base configs.

func BaseConfigPath

func BaseConfigPath(dagsDir, name string) string

BaseConfigPath returns the workspace-scoped base config path for name.

func BaseConfigStem

func BaseConfigStem() string

BaseConfigStem returns the base configuration file name without its extension.

func ValidateName

func ValidateName(name string) error

ValidateName checks whether a workspace name can be safely reused as a label value and filesystem path segment.

func WorkspaceNameFromLabels added in v2.13.0

func WorkspaceNameFromLabels(labels Labels) (string, bool)

WorkspaceNameFromLabels returns the valid workspace label, if one is present.

Types

type Labels added in v2.13.0

type Labels interface {
	Get(key string) []string
}

Labels provides label values by key.

type Store

type Store interface {
	// Create stores a new workspace.
	// Returns ErrWorkspaceAlreadyExists if a workspace with the same name exists.
	Create(ctx context.Context, ws *Workspace) error

	// GetByID retrieves a workspace by its unique ID.
	// Returns ErrWorkspaceNotFound if the workspace does not exist.
	GetByID(ctx context.Context, id string) (*Workspace, error)

	// GetByName retrieves a workspace by its name.
	// Returns ErrWorkspaceNotFound if the workspace does not exist.
	GetByName(ctx context.Context, name string) (*Workspace, error)

	// List returns all workspaces in the store.
	List(ctx context.Context) ([]*Workspace, error)

	// Update modifies an existing workspace.
	// Returns ErrWorkspaceNotFound if the workspace does not exist.
	Update(ctx context.Context, ws *Workspace) error

	// Delete removes a workspace by its ID.
	// Returns ErrWorkspaceNotFound if the workspace does not exist.
	Delete(ctx context.Context, id string) error
}

Store defines the interface for workspace persistence operations. Implementations must be safe for concurrent use.

type Workspace

type Workspace struct {
	ID          string
	Name        string
	Description string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

Workspace is the domain model for a cockpit workspace.

func NewWorkspace

func NewWorkspace(name, description string) *Workspace

NewWorkspace creates a Workspace with a new UUID and current timestamps.

func (*Workspace) ToStorage

func (w *Workspace) ToStorage() *WorkspaceForStorage

ToStorage converts a Workspace to WorkspaceForStorage.

type WorkspaceFilter added in v2.13.0

type WorkspaceFilter struct {
	Enabled           bool
	Workspaces        []string
	IncludeUnlabelled bool
}

WorkspaceFilter restricts list and search results to allowed workspaces.

func (*WorkspaceFilter) MatchesLabels added in v2.13.0

func (f *WorkspaceFilter) MatchesLabels(labels Labels) bool

MatchesLabels reports whether labels are visible under the filter.

type WorkspaceForStorage

type WorkspaceForStorage struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

WorkspaceForStorage is used for JSON serialization to persistent storage.

func (*WorkspaceForStorage) ToWorkspace

func (s *WorkspaceForStorage) ToWorkspace() *Workspace

ToWorkspace converts WorkspaceForStorage back to Workspace.

type WorkspaceLabelState added in v2.13.0

type WorkspaceLabelState int

WorkspaceLabelState describes whether labels contain a usable workspace.

const (
	// WorkspaceLabelMissing means no workspace label is present.
	WorkspaceLabelMissing WorkspaceLabelState = iota
	// WorkspaceLabelValid means exactly one valid workspace label value is present.
	WorkspaceLabelValid
	// WorkspaceLabelInvalid means a workspace label is present but malformed or ambiguous.
	WorkspaceLabelInvalid
)

func WorkspaceLabelFromLabels added in v2.13.0

func WorkspaceLabelFromLabels(labels Labels) (string, WorkspaceLabelState)

WorkspaceLabelFromLabels returns the workspace label and its validity state.

Jump to

Keyboard shortcuts

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