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 CredentialStore
- type Credentials
- type FileCredentialStore
- type KeyringStore
- type LocalPublication
- type LocalRegistry
- type LocalWorkspace
- type Store
- func (s *Store) ClearCredentials() error
- func (s *Store) Close() error
- func (s *Store) CreatePublication(pub *LocalPublication) error
- func (s *Store) CreateRegistry(reg *LocalRegistry) error
- func (s *Store) CreateWorkspace(ws *LocalWorkspace) error
- func (s *Store) DB() *gorm.DB
- func (s *Store) DataDir() string
- func (s *Store) DeleteRegistry(id uuid.UUID) error
- func (s *Store) DeleteWorkspace(id uuid.UUID) error
- func (s *Store) FindWorkspaceByName(name string) (*LocalWorkspace, error)
- func (s *Store) FindWorkspaceByPath(path string) (*LocalWorkspace, error)
- func (s *Store) FindWorkspacesByName(name string) ([]LocalWorkspace, error)
- func (s *Store) GetDefaultRegistry() (*LocalRegistry, error)
- func (s *Store) GetRegistryByName(name string) (*LocalRegistry, error)
- func (s *Store) GetWorkspace(id uuid.UUID) (*LocalWorkspace, error)
- func (s *Store) ListPublications() ([]LocalPublication, error)
- func (s *Store) ListPublicationsByWorkspace(workspaceID uuid.UUID) ([]LocalPublication, error)
- func (s *Store) ListRegistries() ([]LocalRegistry, error)
- 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 CredentialStore ¶ added in v0.10.2
type CredentialStore interface {
SetPassword(registryName, password string) error
GetPassword(registryName string) (string, error)
DeletePassword(registryName string) error
}
CredentialStore provides password storage for registry credentials.
func NewCredentialStore ¶ added in v0.10.2
func NewCredentialStore(dataDir string) CredentialStore
NewCredentialStore returns a KeyringStore if available, otherwise a FileCredentialStore. Prints a warning to stderr when falling back to file-based storage.
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 FileCredentialStore ¶ added in v0.10.2
type FileCredentialStore struct {
Path string
// contains filtered or unexported fields
}
FileCredentialStore is a plaintext fallback for environments without a keychain.
func (*FileCredentialStore) DeletePassword ¶ added in v0.10.2
func (f *FileCredentialStore) DeletePassword(registryName string) error
func (*FileCredentialStore) GetPassword ¶ added in v0.10.2
func (f *FileCredentialStore) GetPassword(registryName string) (string, error)
func (*FileCredentialStore) SetPassword ¶ added in v0.10.2
func (f *FileCredentialStore) SetPassword(registryName, password string) error
type KeyringStore ¶ added in v0.10.2
type KeyringStore struct{}
KeyringStore stores credentials in the OS keychain via go-keyring.
func (*KeyringStore) DeletePassword ¶ added in v0.10.2
func (k *KeyringStore) DeletePassword(registryName string) error
func (*KeyringStore) GetPassword ¶ added in v0.10.2
func (k *KeyringStore) GetPassword(registryName string) (string, error)
func (*KeyringStore) SetPassword ¶ added in v0.10.2
func (k *KeyringStore) SetPassword(registryName, password string) error
type LocalPublication ¶ added in v0.10.2
type LocalPublication struct {
ID uuid.UUID `gorm:"type:text;primary_key" json:"id"`
WorkspaceID uuid.UUID `gorm:"type:text;index;not null" json:"workspace_id"`
RegistryID uuid.UUID `gorm:"type:text;index;not null" json:"registry_id"`
Repository string `gorm:"not null" json:"repository"`
Tag string `gorm:"not null" json:"tag"`
Digest string `json:"digest"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
LocalPublication records a workspace publication to an OCI registry from the CLI.
func (*LocalPublication) BeforeCreate ¶ added in v0.10.2
func (p *LocalPublication) BeforeCreate(tx *gorm.DB) error
BeforeCreate hook to generate UUID.
func (LocalPublication) TableName ¶ added in v0.10.2
func (LocalPublication) TableName() string
TableName ensures GORM uses the "local_publications" table.
type LocalRegistry ¶ added in v0.10.2
type LocalRegistry struct {
ID uuid.UUID `gorm:"type:text;primary_key" json:"id"`
Name string `gorm:"uniqueIndex;not null" json:"name"`
URL string `gorm:"not null" json:"url"`
Username string `json:"username"`
IsDefault bool `gorm:"default:false" json:"is_default"`
Namespace string `json:"namespace"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
LocalRegistry represents an OCI registry configured in the local CLI store. Credentials (passwords) are stored in the OS keychain, not in SQLite.
func (*LocalRegistry) BeforeCreate ¶ added in v0.10.2
func (r *LocalRegistry) BeforeCreate(tx *gorm.DB) error
BeforeCreate hook to generate UUID.
func (LocalRegistry) TableName ¶ added in v0.10.2
func (LocalRegistry) TableName() string
TableName ensures GORM uses the "local_registries" table.
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"`
OriginID string `json:"origin_id,omitempty"`
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) ClearCredentials ¶ added in v0.10.2
ClearCredentials removes stored credentials and server URL.
func (*Store) CreatePublication ¶ added in v0.10.2
func (s *Store) CreatePublication(pub *LocalPublication) error
CreatePublication creates a new local publication record.
func (*Store) CreateRegistry ¶ added in v0.10.2
func (s *Store) CreateRegistry(reg *LocalRegistry) error
CreateRegistry creates a new local registry record.
func (*Store) CreateWorkspace ¶
func (s *Store) CreateWorkspace(ws *LocalWorkspace) error
CreateWorkspace creates a new workspace record.
func (*Store) DeleteRegistry ¶ added in v0.10.2
DeleteRegistry removes a registry by ID (hard delete).
func (*Store) DeleteWorkspace ¶
DeleteWorkspace removes a workspace by ID (hard delete).
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) FindWorkspacesByName ¶
func (s *Store) FindWorkspacesByName(name string) ([]LocalWorkspace, error)
FindWorkspacesByName returns all workspaces with the given name. Multiple workspaces can share the same name since path is the unique identifier.
func (*Store) GetDefaultRegistry ¶ added in v0.10.2
func (s *Store) GetDefaultRegistry() (*LocalRegistry, error)
GetDefaultRegistry returns the default registry (is_default=true).
func (*Store) GetRegistryByName ¶ added in v0.10.2
func (s *Store) GetRegistryByName(name string) (*LocalRegistry, error)
GetRegistryByName returns a registry by name.
func (*Store) GetWorkspace ¶
func (s *Store) GetWorkspace(id uuid.UUID) (*LocalWorkspace, error)
GetWorkspace returns a workspace by ID.
func (*Store) ListPublications ¶ added in v0.10.2
func (s *Store) ListPublications() ([]LocalPublication, error)
ListPublications returns all local publications, most recent first.
func (*Store) ListPublicationsByWorkspace ¶ added in v0.10.2
func (s *Store) ListPublicationsByWorkspace(workspaceID uuid.UUID) ([]LocalPublication, error)
ListPublicationsByWorkspace returns publications for a specific workspace.
func (*Store) ListRegistries ¶ added in v0.10.2
func (s *Store) ListRegistries() ([]LocalRegistry, error)
ListRegistries returns all local registries.
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.