@@ -4,30 +4,29 @@ import (
44 "fmt"
55
66 "github.com/google/uuid"
7- "github.com/nebari-dev/nebi/internal/models"
87)
98
109// ListWorkspaces returns all workspaces.
11- func (s * Store ) ListWorkspaces () ([]models. Workspace , error ) {
12- var wss []models. Workspace
10+ func (s * Store ) ListWorkspaces () ([]LocalWorkspace , error ) {
11+ var wss []LocalWorkspace
1312 if err := s .db .Find (& wss ).Error ; err != nil {
1413 return nil , fmt .Errorf ("listing workspaces: %w" , err )
1514 }
1615 return wss , nil
1716}
1817
1918// GetWorkspace returns a workspace by ID.
20- func (s * Store ) GetWorkspace (id uuid.UUID ) (* models. Workspace , error ) {
21- var ws models. Workspace
19+ func (s * Store ) GetWorkspace (id uuid.UUID ) (* LocalWorkspace , error ) {
20+ var ws LocalWorkspace
2221 if err := s .db .Where ("id = ?" , id ).First (& ws ).Error ; err != nil {
2322 return nil , fmt .Errorf ("getting workspace: %w" , err )
2423 }
2524 return & ws , nil
2625}
2726
2827// FindWorkspaceByPath returns the workspace at the given path, or nil if not found.
29- func (s * Store ) FindWorkspaceByPath (path string ) (* models. Workspace , error ) {
30- var ws models. Workspace
28+ func (s * Store ) FindWorkspaceByPath (path string ) (* LocalWorkspace , error ) {
29+ var ws LocalWorkspace
3130 result := s .db .Where ("path = ?" , path ).First (& ws )
3231 if result .Error != nil {
3332 if result .RowsAffected == 0 {
@@ -39,8 +38,8 @@ func (s *Store) FindWorkspaceByPath(path string) (*models.Workspace, error) {
3938}
4039
4140// FindWorkspaceByName returns the first workspace with the given name, or nil if not found.
42- func (s * Store ) FindWorkspaceByName (name string ) (* models. Workspace , error ) {
43- var ws models. Workspace
41+ func (s * Store ) FindWorkspaceByName (name string ) (* LocalWorkspace , error ) {
42+ var ws LocalWorkspace
4443 result := s .db .Where ("name = ?" , name ).First (& ws )
4544 if result .Error != nil {
4645 if result .RowsAffected == 0 {
@@ -52,8 +51,8 @@ func (s *Store) FindWorkspaceByName(name string) (*models.Workspace, error) {
5251}
5352
5453// FindGlobalWorkspaceByName returns the first global workspace with the given name.
55- func (s * Store ) FindGlobalWorkspaceByName (name string ) (* models. Workspace , error ) {
56- var ws models. Workspace
54+ func (s * Store ) FindGlobalWorkspaceByName (name string ) (* LocalWorkspace , error ) {
55+ var ws LocalWorkspace
5756 result := s .db .Where ("name = ? AND is_global = ?" , name , true ).First (& ws )
5857 if result .Error != nil {
5958 if result .RowsAffected == 0 {
@@ -65,12 +64,12 @@ func (s *Store) FindGlobalWorkspaceByName(name string) (*models.Workspace, error
6564}
6665
6766// CreateWorkspace creates a new workspace record.
68- func (s * Store ) CreateWorkspace (ws * models. Workspace ) error {
67+ func (s * Store ) CreateWorkspace (ws * LocalWorkspace ) error {
6968 if ws .ID == uuid .Nil {
7069 ws .ID = uuid .New ()
7170 }
7271 if ws .Status == "" {
73- ws .Status = models . WsStatusReady
72+ ws .Status = "ready"
7473 }
7574 if ws .Source == "" {
7675 ws .Source = "local"
@@ -82,11 +81,11 @@ func (s *Store) CreateWorkspace(ws *models.Workspace) error {
8281}
8382
8483// SaveWorkspace updates an existing workspace record.
85- func (s * Store ) SaveWorkspace (ws * models. Workspace ) error {
84+ func (s * Store ) SaveWorkspace (ws * LocalWorkspace ) error {
8685 return s .db .Save (ws ).Error
8786}
8887
8988// DeleteWorkspace removes a workspace by ID (hard delete).
9089func (s * Store ) DeleteWorkspace (id uuid.UUID ) error {
91- return s .db .Unscoped ().Where ("id = ?" , id ).Delete (& models. Workspace {}).Error
90+ return s .db .Unscoped ().Where ("id = ?" , id ).Delete (& LocalWorkspace {}).Error
9291}
0 commit comments