Documentation
¶
Index ¶
- func ContentHash(data string) string
- func DefaultDataDir() (string, error)
- func MigrateServerDB(db *gorm.DB) error
- func TomlContentHash(data string) (string, error)
- type Config
- type Credentials
- type LocalWorkspace
- type Store
- func (s *Store) Close() error
- func (s *Store) CreateWorkspace(ws *LocalWorkspace) error
- func (s *Store) DB() *gorm.DB
- func (s *Store) DataDir() string
- func (s *Store) DeleteWorkspace(id uuid.UUID) error
- func (s *Store) FindGlobalWorkspaceByName(name string) (*LocalWorkspace, error)
- func (s *Store) FindWorkspaceByName(name string) (*LocalWorkspace, error)
- func (s *Store) FindWorkspaceByPath(path string) (*LocalWorkspace, error)
- func (s *Store) GetWorkspace(id uuid.UUID) (*LocalWorkspace, error)
- func (s *Store) GlobalWorkspaceDir(id string) string
- func (s *Store) IsGlobalWorkspace(ws *LocalWorkspace) bool
- func (s *Store) ListWorkspaces() ([]LocalWorkspace, error)
- func (s *Store) LoadCredentials() (*Credentials, error)
- func (s *Store) LoadServerURL() (string, error)
- func (s *Store) SaveCredentials(creds *Credentials) error
- func (s *Store) SaveServerURL(url string) error
- func (s *Store) SaveWorkspace(ws *LocalWorkspace) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentHash ¶
ContentHash returns the hex-encoded SHA-256 hash of the given data.
func DefaultDataDir ¶
DefaultDataDir returns ~/.local/share/nebi/ on Linux, platform equivalent elsewhere.
func MigrateServerDB ¶
MigrateServerDB creates store tables on an external DB (used by local-mode server).
func TomlContentHash ¶
TomlContentHash parses data as TOML, canonicalizes it via sorted-key JSON, and returns the hex-encoded SHA-256 hash. This makes the hash insensitive to whitespace and formatting differences in the TOML source.
Types ¶
type Credentials ¶
type Credentials struct {
ID int `gorm:"primarykey"`
Token string `gorm:"not null;default:''"`
Username string `gorm:"not null;default:''"`
}
Credentials stores auth info for the configured nebi server.
func (Credentials) TableName ¶
func (Credentials) TableName() string
type LocalWorkspace ¶
type LocalWorkspace struct {
ID uuid.UUID `gorm:"type:text;primary_key" json:"id"`
Name string `gorm:"not null" json:"name"`
Status string `gorm:"not null;default:'ready'" json:"status"`
PackageManager string `gorm:"not null" json:"package_manager"`
Path string `gorm:"" json:"path,omitempty"`
Source string `gorm:"default:'managed'" json:"source"`
OriginName string `json:"origin_name,omitempty"`
OriginTag string `json:"origin_tag,omitempty"`
OriginAction string `json:"origin_action,omitempty"`
OriginTomlHash string `json:"origin_toml_hash,omitempty"`
OriginLockHash string `json:"origin_lock_hash,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
LocalWorkspace represents a workspace tracked by the CLI in its local SQLite database. This is separate from models.Workspace which is used by the server.
func (*LocalWorkspace) BeforeCreate ¶
func (w *LocalWorkspace) BeforeCreate(tx *gorm.DB) error
BeforeCreate hook to generate UUID.
func (LocalWorkspace) TableName ¶
func (LocalWorkspace) TableName() string
TableName ensures GORM uses the "workspaces" table.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages the local nebi SQLite database via GORM.
func (*Store) CreateWorkspace ¶
func (s *Store) CreateWorkspace(ws *LocalWorkspace) error
CreateWorkspace creates a new workspace record.
func (*Store) DeleteWorkspace ¶
DeleteWorkspace removes a workspace by ID (hard delete).
func (*Store) FindGlobalWorkspaceByName ¶
func (s *Store) FindGlobalWorkspaceByName(name string) (*LocalWorkspace, error)
FindGlobalWorkspaceByName returns the first global workspace with the given name. A workspace is global if its path is inside the store's managed workspaces directory.
func (*Store) FindWorkspaceByName ¶
func (s *Store) FindWorkspaceByName(name string) (*LocalWorkspace, error)
FindWorkspaceByName returns the first workspace with the given name, or nil if not found.
func (*Store) FindWorkspaceByPath ¶
func (s *Store) FindWorkspaceByPath(path string) (*LocalWorkspace, error)
FindWorkspaceByPath returns the workspace at the given path, or nil if not found.
func (*Store) GetWorkspace ¶
func (s *Store) GetWorkspace(id uuid.UUID) (*LocalWorkspace, error)
GetWorkspace returns a workspace by ID.
func (*Store) GlobalWorkspaceDir ¶
GlobalWorkspaceDir returns the directory for a global workspace identified by its UUID.
func (*Store) IsGlobalWorkspace ¶
func (s *Store) IsGlobalWorkspace(ws *LocalWorkspace) bool
IsGlobalWorkspace returns true if the workspace path is inside nebi's managed data directory.
func (*Store) ListWorkspaces ¶
func (s *Store) ListWorkspaces() ([]LocalWorkspace, error)
ListWorkspaces returns all workspaces.
func (*Store) LoadCredentials ¶
func (s *Store) LoadCredentials() (*Credentials, error)
LoadCredentials reads stored credentials.
func (*Store) LoadServerURL ¶
LoadServerURL returns the configured server URL.
func (*Store) SaveCredentials ¶
func (s *Store) SaveCredentials(creds *Credentials) error
SaveCredentials writes credentials.
func (*Store) SaveServerURL ¶
SaveServerURL stores the server URL.
func (*Store) SaveWorkspace ¶
func (s *Store) SaveWorkspace(ws *LocalWorkspace) error
SaveWorkspace updates an existing workspace record.