Documentation
¶
Overview ¶
Package core/migrate.go defines schema migrations applied in order.
Package core defines the shared types and interfaces used across CLI and TUI layers.
Package core — resource type display labels, kept provider-specific since the same short code can mean different things (or not exist) across cloud vendors.
Index ¶
- func Columns(resourceType string) []string
- func DefaultDBPath() string
- func ResourceTypeLabel(provider, resourceType string) string
- type DB
- func (d *DB) Close() error
- func (d *DB) GetLastSyncTime(provider, profile, resourceType string) (time.Time, error)
- func (d *DB) InsertSyncLog(provider, profile, resourceType, region string) (int64, error)
- func (d *DB) ListProviders() ([]Provider, error)
- func (d *DB) ListResources(provider, profile, resourceType, region string) ([]Resource, error)
- func (d *DB) SearchResources(provider, profile, resourceType, query string) ([]Resource, error)
- func (d *DB) UpdateSyncLog(id int64, status, errMsg string, count int) error
- func (d *DB) UpsertProvider(p Provider) error
- func (d *DB) UpsertResources(resources []Resource) error
- type Provider
- type ProviderDetector
- type ProviderError
- type Resource
- type ResourceFetcher
- type SyncLog
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResourceTypeLabel ¶
ResourceTypeLabel returns the human-readable label for a provider's resource type code, or "" if the provider/code isn't known — callers should fall back to showing the bare code in that case.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps a SQLite database connection.
func (*DB) GetLastSyncTime ¶
GetLastSyncTime returns the last successful sync time for a provider+profile+resource type.
func (*DB) InsertSyncLog ¶
InsertSyncLog creates a new sync log entry.
func (*DB) ListProviders ¶
ListProviders returns all detected providers.
func (*DB) ListResources ¶
ListResources returns resources filtered by provider, profile, type, and optional region.
func (*DB) SearchResources ¶
SearchResources searches resources by name or ID.
func (*DB) UpdateSyncLog ¶
UpdateSyncLog updates a sync log entry with completion info.
func (*DB) UpsertProvider ¶
UpsertProvider inserts or updates a provider record.
func (*DB) UpsertResources ¶
UpsertResources batch inserts or updates resources.
type Provider ¶
type Provider struct {
Name string `json:"name"`
CLIPath string `json:"cli_path"`
ConfigPath string `json:"config_path"`
Profiles []string `json:"profiles"`
Regions []string `json:"regions"`
ProfileRegions map[string][]string `json:"profile_regions"` // profile name → regions
ActiveProfile string `json:"active_profile"` // TUI 选中的 profile,CLI 调用时传 --profile
DetectedAt time.Time `json:"detected_at"`
}
Provider represents a detected cloud provider with CLI access.
type ProviderDetector ¶
type ProviderDetector interface {
Name() string
Detect(ctx context.Context) (*Provider, error)
ResourceTypes() []string
Fetchers() []ResourceFetcher
}
ProviderDetector can scan for and detect a cloud provider.
type ProviderError ¶
ProviderError represents a cloud CLI execution failure.
func (*ProviderError) Error ¶
func (e *ProviderError) Error() string
type Resource ¶
type Resource struct {
Provider string `json:"provider"`
Profile string `json:"profile"`
ResourceType string `json:"resource_type"`
Region string `json:"region"`
ResourceID string `json:"resource_id"`
ResourceName string `json:"resource_name"`
Status string `json:"status"`
RawJSON string `json:"raw_json"`
SyncedAt time.Time `json:"synced_at"`
}
Resource represents a single cloud resource cached in SQLite.
func Sync ¶
func Sync(ctx context.Context, db *DB, provider *Provider, fetcher ResourceFetcher, region string) ([]Resource, error)
Sync fetches resources from a provider if the cache is stale, then returns the list.
func SyncAndList ¶
func SyncAndList(ctx context.Context, db *DB, provider *Provider, fetcher ResourceFetcher, region string) ([]Resource, error)
SyncAndList forces a sync and returns fresh results.