Documentation
¶
Index ¶
Constants ¶
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 ¶
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 ¶
BaseConfigDir returns the root directory for workspace-scoped base configs.
func BaseConfigPath ¶
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 ¶
ValidateName checks whether a workspace name can be safely reused as a label value and filesystem path segment.
Types ¶
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 ¶
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 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.