Documentation
¶
Index ¶
- type AgentUpdate
- type CommandTrace
- type DB
- func (db *DB) Bun() *bun.DB
- func (db *DB) ClearFailure(ctx context.Context, name, prov, pkg string) error
- func (db *DB) Close() error
- func (db *DB) Delete(ctx context.Context, name, provider, pkg string) error
- func (db *DB) Get(ctx context.Context, name, provider, pkg string) (*ToolCache, error)
- func (db *DB) GetDotsSnapshot(ctx context.Context) (*DotsSnapshot, bool, error)
- func (db *DB) GetMetadata(ctx context.Context, name, provider, pkg string) (*ToolMetadata, error)
- func (db *DB) GetPackageAvailability(ctx context.Context, name, provider, pkg string) (*PackageAvailability, error)
- func (db *DB) GetState(ctx context.Context, key string) (string, error)
- func (db *DB) GetUpdateMetadata(ctx context.Context, providerName, pkg, version string) (*UpdateMetadata, error)
- func (db *DB) List(ctx context.Context) ([]*ToolCache, error)
- func (db *DB) ListAgentUpdates(ctx context.Context) ([]AgentUpdate, error)
- func (db *DB) ListByProvider(ctx context.Context, provider string) ([]*ToolCache, error)
- func (db *DB) ListCommandTraces(ctx context.Context, limit int) ([]CommandTrace, error)
- func (db *DB) ListDiscovered(ctx context.Context) ([]*ToolCache, error)
- func (db *DB) ListFailed(ctx context.Context) ([]*ToolCache, error)
- func (db *DB) ListMetadata(ctx context.Context) ([]*ToolMetadata, error)
- func (db *DB) MarkFailed(ctx context.Context, name, prov, pkg, errMsg string) error
- func (db *DB) MarkInstalled(ctx context.Context, name, provider, pkg, version string) error
- func (db *DB) MarkPrivilegeRequired(ctx context.Context, name, prov, pkg, requirement, reason string) error
- func (db *DB) MarkTapTrusted(ctx context.Context, name string, at time.Time) error
- func (db *DB) MarkTracked(ctx context.Context, name, provider, pkg string) error
- func (db *DB) MarkTrackedBatch(ctx context.Context, tools []TrackedTool) error
- func (db *DB) MarkUninstalled(ctx context.Context, name, provider, pkg string) error
- func (db *DB) MarkUntracked(ctx context.Context, name, provider, pkg string) error
- func (db *DB) MarkUpgradeFailed(ctx context.Context, name, prov, pkg, errMsg string) error
- func (db *DB) Migrate(ctx context.Context) error
- func (db *DB) PruneDiscovered(ctx context.Context, cutoff time.Time) error
- func (db *DB) PruneDiscoveredProviders(ctx context.Context, cutoff time.Time, scopes []DiscoveredProviderScope) error
- func (db *DB) ReconcileTracked(ctx context.Context, desired []*ToolCache, migrations ...TrackedAliasMigration) error
- func (db *DB) RecordCommandTrace(ctx context.Context, trace *CommandTrace) error
- func (db *DB) ReplaceAgentUpdates(ctx context.Context, updates []AgentUpdate) error
- func (db *DB) ReplaceDotsSnapshot(ctx context.Context, entries []*DotStatusCache, gitStatus string, ...) error
- func (db *DB) SetState(ctx context.Context, key, value string) error
- func (db *DB) TrustedTaps(ctx context.Context) (map[string]bool, error)
- func (db *DB) UpdateDescription(ctx context.Context, name, prov, pkg, description string) error
- func (db *DB) UpdateDescriptionBatch(ctx context.Context, updates []DescriptionUpdate) error
- func (db *DB) UpdateOutdated(ctx context.Context, name, provider, pkg string, outdated bool, ...) error
- func (db *DB) UpdateOutdatedBatch(ctx context.Context, updates []OutdatedUpdate) error
- func (db *DB) Upsert(ctx context.Context, t *ToolCache) error
- func (db *DB) UpsertBatch(ctx context.Context, tools []*ToolCache) error
- func (db *DB) UpsertDiscovered(ctx context.Context, name, provider, installedWith, version string) error
- func (db *DB) UpsertDiscoveredBatch(ctx context.Context, entries []DiscoveredUpsert) error
- func (db *DB) UpsertMetadataBatch(ctx context.Context, updates []MetadataUpdate) error
- func (db *DB) UpsertPackageAvailability(ctx context.Context, availability PackageAvailability) error
- func (db *DB) UpsertUpdateMetadata(ctx context.Context, metadata UpdateMetadata) error
- func (db *DB) UpsertUpdateMetadataBatch(ctx context.Context, updates []UpdateMetadata) error
- type DescriptionUpdate
- type DiscoveredProviderScope
- type DiscoveredUpsert
- type DotSnapshotMeta
- type DotStatusCache
- type DotsSnapshot
- type LocalState
- type MetadataUpdate
- type OutdatedUpdate
- type PackageAvailability
- type ToolCache
- type ToolCacheKey
- type ToolMetadata
- type TrackedAliasMigration
- type TrackedTool
- type TrustedTap
- type UpdateMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentUpdate ¶ added in v0.10.16
type AgentUpdate struct {
bun.BaseModel `bun:"table:agent_update_cache,alias:auc"`
ID int64 `bun:"id,pk,autoincrement"`
Package string `bun:"package,notnull"`
Current string `bun:"current,notnull,default:''"`
Latest string `bun:"latest,notnull,default:''"`
Source string `bun:"source,notnull,default:''"`
CheckedAt time.Time `bun:"checked_at,notnull"`
}
AgentUpdate — the last apm outdated answer, cached so the Agents view can show known updates before a fresh check finishes, the way tool_cache does for tools.
type CommandTrace ¶ added in v0.8.6
type CommandTrace struct {
bun.BaseModel `bun:"table:command_traces,alias:ct"`
ID int64 `bun:"id,pk,autoincrement"`
StartedAt time.Time `bun:"started_at,notnull"`
FinishedAt time.Time `bun:"finished_at,notnull"`
DurationMS int64 `bun:"duration_ms,notnull,default:0"`
Reason string `bun:"reason,notnull,default:''"`
Command string `bun:"command,type:TEXT,notnull"`
Status string `bun:"status,notnull,default:''"`
ExitCode sql.NullInt64 `bun:"exit_code"`
Error string `bun:"error,type:TEXT,notnull,default:''"`
Stdout string `bun:"stdout,type:TEXT,notnull,default:''"`
Stderr string `bun:"stderr,type:TEXT,notnull,default:''"`
}
CommandTrace — Intentionally compact: stdout, stderr, and error all arrive already truncated and redacted.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func OpenContext ¶ added in v0.9.22
OpenContext lets cancellation stop the WAL retry loop before a competing writer exhausts the busy budget.
func (*DB) ClearFailure ¶ added in v0.2.0
ClearFailure — For operations that were cancelled rather than failed; installed state is untouched.
func (*DB) GetDotsSnapshot ¶ added in v0.7.1
func (*DB) GetMetadata ¶ added in v0.2.0
func (*DB) GetPackageAvailability ¶ added in v0.8.5
func (*DB) GetUpdateMetadata ¶ added in v0.8.0
func (*DB) ListAgentUpdates ¶ added in v0.10.16
func (db *DB) ListAgentUpdates(ctx context.Context) ([]AgentUpdate, error)
func (*DB) ListByProvider ¶
func (*DB) ListCommandTraces ¶ added in v0.8.6
func (*DB) ListMetadata ¶ added in v0.2.0
func (db *DB) ListMetadata(ctx context.Context) ([]*ToolMetadata, error)
func (*DB) MarkFailed ¶
MarkFailed — Creates a stub row if none exists yet.
func (*DB) MarkInstalled ¶
MarkInstalled — Also clears the outdated flag: the tool is now at the latest version.
func (*DB) MarkPrivilegeRequired ¶ added in v0.2.0
func (db *DB) MarkPrivilegeRequired(ctx context.Context, name, prov, pkg, requirement, reason string) error
MarkPrivilegeRequired — Creates a stub row if none exists yet.
func (*DB) MarkTapTrusted ¶ added in v0.8.5
func (*DB) MarkTracked ¶
MarkTracked — Best-effort promotion of a discovered row to config-tracked; a missing row is a no-op.
func (*DB) MarkTrackedBatch ¶ added in v0.7.0
func (db *DB) MarkTrackedBatch(ctx context.Context, tools []TrackedTool) error
MarkTrackedBatch — Best-effort: rows that do not exist are ignored.
func (*DB) MarkUninstalled ¶
func (*DB) MarkUntracked ¶ added in v0.10.3
MarkUntracked demotes one concrete cache identity after config stops owning it.
func (*DB) MarkUpgradeFailed ¶ added in v0.9.22
MarkUpgradeFailed — Unlike MarkFailed, leaves an existing installation marked present.
func (*DB) Migrate ¶
Migrate — Idempotent: re-runs add missing columns and swallow "duplicate column" errors.
func (*DB) PruneDiscovered ¶
func (*DB) PruneDiscoveredProviders ¶ added in v0.10.2
func (*DB) ReconcileTracked ¶
func (db *DB) ReconcileTracked(ctx context.Context, desired []*ToolCache, migrations ...TrackedAliasMigration) error
ReconcileTracked marks desired keys tracked, applies explicit alias migrations, deletes stale missing rows, and demotes other installed rows to honest discoveries. Provider compatibility policy belongs to the app.
func (*DB) RecordCommandTrace ¶ added in v0.8.6
func (db *DB) RecordCommandTrace(ctx context.Context, trace *CommandTrace) error
RecordCommandTrace — Also prunes beyond the retention limit. Callers should treat errors as non-fatal.
func (*DB) ReplaceAgentUpdates ¶ added in v0.10.16
func (db *DB) ReplaceAgentUpdates(ctx context.Context, updates []AgentUpdate) error
ReplaceAgentUpdates swaps the whole cached answer: apm reports the workspace, not one package at a time.
func (*DB) ReplaceDotsSnapshot ¶ added in v0.7.1
func (*DB) TrustedTaps ¶ added in v0.8.5
func (*DB) UpdateDescription ¶
UpdateDescription — Never changes install/config state.
func (*DB) UpdateDescriptionBatch ¶
func (db *DB) UpdateDescriptionBatch(ctx context.Context, updates []DescriptionUpdate) error
UpdateDescriptionBatch — Never changes install/config state.
func (*DB) UpdateOutdated ¶
func (*DB) UpdateOutdatedBatch ¶
func (db *DB) UpdateOutdatedBatch(ctx context.Context, updates []OutdatedUpdate) error
UpdateOutdatedBatch — One transaction so SQLite batches the writes into a single fsync; rolls back on first error.
func (*DB) UpsertBatch ¶
UpsertBatch — One transaction so SQLite batches the writes into a single fsync; rolls back on first error.
func (*DB) UpsertDiscovered ¶
func (db *DB) UpsertDiscovered(ctx context.Context, name, provider, installedWith, version string) error
UpsertDiscovered — Records a locally-installed, unconfigured tool; never overwrites a config-tracked row.
func (*DB) UpsertDiscoveredBatch ¶
func (db *DB) UpsertDiscoveredBatch(ctx context.Context, entries []DiscoveredUpsert) error
func (*DB) UpsertMetadataBatch ¶ added in v0.2.0
func (db *DB) UpsertMetadataBatch(ctx context.Context, updates []MetadataUpdate) error
UpsertMetadataBatch — Never changes install/config state, so uninstalled and unconfigured tools are fine.
func (*DB) UpsertPackageAvailability ¶ added in v0.8.5
func (db *DB) UpsertPackageAvailability(ctx context.Context, availability PackageAvailability) error
func (*DB) UpsertUpdateMetadata ¶ added in v0.8.0
func (db *DB) UpsertUpdateMetadata(ctx context.Context, metadata UpdateMetadata) error
func (*DB) UpsertUpdateMetadataBatch ¶ added in v0.8.0
func (db *DB) UpsertUpdateMetadataBatch(ctx context.Context, updates []UpdateMetadata) error
type DescriptionUpdate ¶
type DiscoveredProviderScope ¶ added in v0.10.2
type DiscoveredUpsert ¶
type DotSnapshotMeta ¶ added in v0.7.1
type DotStatusCache ¶ added in v0.7.1
type DotStatusCache struct {
bun.BaseModel `bun:"table:dot_status_cache,alias:dsc"`
ID int64 `bun:"id,pk,autoincrement"`
Name string `bun:"name,notnull"`
Package string `bun:"package,notnull,default:''"`
Variant bool `bun:"variant,notnull,default:false"`
SourcePath string `bun:"source_path,notnull,default:''"`
TargetPath string `bun:"target_path,notnull,default:''"`
ConfigPath string `bun:"config_path,notnull,default:''"`
Health string `bun:"health,notnull,default:''"`
State string `bun:"state,notnull,default:''"`
ActionsJSON string `bun:"actions_json,type:TEXT,notnull,default:''"`
Group string `bun:"group_name,notnull,default:''"`
FileCount int `bun:"file_count,notnull,default:0"`
CountsJSON string `bun:"counts_json,type:TEXT,notnull,default:''"`
IsDir bool `bun:"is_dir,notnull,default:false"`
ChildrenJSON string `bun:"children_json,type:TEXT,notnull,default:''"`
Position int `bun:"position,notnull,default:0"`
ObservedAt time.Time `bun:"observed_at,notnull"`
}
type DotsSnapshot ¶ added in v0.7.1
type DotsSnapshot struct {
Entries []*DotStatusCache
GitStatus string
DiscoveredCount int
ObservedAt time.Time
}
type LocalState ¶ added in v0.4.5
type LocalState struct {
bun.BaseModel `bun:"table:local_state,alias:ls"`
Key string `bun:"key,pk,notnull"`
Value string `bun:"value,notnull"`
UpdatedAt time.Time `bun:"updated_at,notnull"`
}
LocalState — Lives in the cache DB, not settings.json, because these rows describe this checkout/host.
type MetadataUpdate ¶ added in v0.2.0
type MetadataUpdate struct {
Name string
Provider string
Package string
Version string
Description string
SourceType string
SourceOwner string
SourceRepo string
SourceURL string
Privilege string
PrivilegeReason string
ArtifactKind string // provider-specific artifact kind, e.g. "formula" or "cask" for brew
SelfUpdates bool // cask the manager cannot upgrade (manual installer; app self-updates)
}
type OutdatedUpdate ¶
type OutdatedUpdate struct {
Name string
Provider string
Package string
Outdated bool
OutdatedUnknown bool
LatestVersion string
}
OutdatedUpdate — OutdatedUnknown records a provider that can upgrade the tool but cannot say whether it needs upgrading; it is never set together with Outdated.
type PackageAvailability ¶ added in v0.8.5
type PackageAvailability struct {
bun.BaseModel `bun:"table:package_availability,alias:pa"`
ID int64 `bun:"id,pk,autoincrement"`
Name string `bun:"name,notnull"`
Provider string `bun:"provider,notnull"`
Package string `bun:"package,notnull"`
Available bool `bun:"available,notnull,default:false"`
Reason string `bun:"reason,notnull,default:''"`
CheckedAt time.Time `bun:"checked_at,notnull"`
}
type ToolCache ¶
type ToolCache struct {
bun.BaseModel `bun:"table:tool_cache,alias:tc"`
ID int64 `bun:"id,pk,autoincrement"`
Name string `bun:"name,notnull"`
Provider string `bun:"provider,notnull"`
Package string `bun:"package,notnull"`
Installed bool `bun:"installed,notnull,default:false"`
InstalledWith string `bun:"installed_with,notnull,default:''"`
Version sql.NullString `bun:"version"`
Outdated bool `bun:"outdated,notnull,default:false"`
OutdatedUnknown bool `bun:"outdated_unknown,notnull,default:false"`
LatestVersion sql.NullString `bun:"latest_version"`
Description sql.NullString `bun:"description"`
LastChecked time.Time `bun:"last_checked,notnull"`
FailedAt *time.Time `bun:"failed_at"`
FailureCount int `bun:"failure_count,notnull,default:0"`
LastError sql.NullString `bun:"last_error"`
Tracked bool `bun:"tracked,notnull,default:true"`
Privilege string `bun:"privilege,notnull,default:''"`
PrivilegeReason sql.NullString `bun:"privilege_reason"`
PrivilegeAt *time.Time `bun:"privilege_at"`
Options map[string]string `bun:"-"`
UpdateBlocked string `bun:"-"`
UpdateBlockedUntil *time.Time `bun:"-"`
UpdateAvailableAt *time.Time `bun:"-"`
UpdateDateSource string `bun:"-"`
}
type ToolCacheKey ¶ added in v0.10.2
type ToolCacheKey struct {
Name, Provider, Package string
}
type ToolMetadata ¶ added in v0.2.0
type ToolMetadata struct {
bun.BaseModel `bun:"table:tool_metadata,alias:tm"`
ID int64 `bun:"id,pk,autoincrement"`
Name string `bun:"name,notnull"`
Provider string `bun:"provider,notnull"`
Package string `bun:"package,notnull"`
Version sql.NullString `bun:"version"`
Description sql.NullString `bun:"description"`
SourceType string `bun:"source_type,notnull,default:''"`
SourceOwner string `bun:"source_owner,notnull,default:''"`
SourceRepo string `bun:"source_repo,notnull,default:''"`
SourceURL sql.NullString `bun:"source_url"`
Privilege string `bun:"privilege,notnull,default:''"`
PrivilegeReason sql.NullString `bun:"privilege_reason"`
ArtifactKind string `bun:"artifact_kind,notnull,default:''"`
SelfUpdates bool `bun:"self_updates,notnull,default:false"`
UpdatedAt time.Time `bun:"updated_at,notnull"`
}
ToolMetadata — Cached independently from install/config state.
type TrackedAliasMigration ¶ added in v0.10.2
type TrackedAliasMigration struct {
From, To ToolCacheKey
InstalledWith string
}
type TrackedTool ¶ added in v0.7.0
type TrustedTap ¶ added in v0.8.5
type TrustedTap struct {
bun.BaseModel `bun:"table:trusted_taps,alias:tt"`
Name string `bun:"name,pk"`
TrustedAt time.Time `bun:"trusted_at,notnull"`
}
TrustedTap — Lets tap sync skip the `brew trust` call on later runs.
type UpdateMetadata ¶ added in v0.8.0
type UpdateMetadata struct {
bun.BaseModel `bun:"table:update_metadata,alias:um"`
ID int64 `bun:"id,pk,autoincrement"`
Provider string `bun:"provider,notnull"`
Package string `bun:"package,notnull"`
Version string `bun:"version,notnull"`
AvailableAt time.Time `bun:"available_at,notnull"`
DateSource string `bun:"date_source,notnull"`
CheckedAt time.Time `bun:"checked_at,notnull"`
}
UpdateMetadata — Keyed by concrete provider/manager: availability timestamps only mean something for the PM that reported them.