Documentation
¶
Overview ¶
Package snapshots manages point-in-time snapshots of deployed services, capturing the Docker image tag, environment variables, and resource config.
Index ¶
- type CreateRequest
- type ListFilter
- type Manager
- func (m *Manager) CleanExpired(ctx context.Context, maxPerService int, maxAge time.Duration) (int, error)
- func (m *Manager) Create(ctx context.Context, tenantID, serviceID string, req CreateRequest) (*Snapshot, error)
- func (m *Manager) Delete(ctx context.Context, tenantID, snapshotID string) error
- func (m *Manager) Get(ctx context.Context, tenantID, snapshotID string) (*Snapshot, error)
- func (m *Manager) GetEnvKeys(ctx context.Context, tenantID, snapshotID string) (map[string]string, error)
- func (m *Manager) List(ctx context.Context, tenantID string, limit, offset int, filter *ListFilter) ([]*Snapshot, error)
- func (m *Manager) RestoreEnvVars(ctx context.Context, tenantID, snapshotID string) (map[string]string, error)
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateRequest ¶
CreateRequest holds the user-supplied fields for creating a snapshot.
type ListFilter ¶
type ListFilter struct {
ServiceID string // exact match on service_id
Name string // substring match on name (LIKE %name%)
Since int64 // filter created_at >= since (unix timestamp)
}
ListFilter holds optional filter parameters for listing snapshots.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides snapshot CRUD backed by SQLite and Docker.
func NewManager ¶
NewManager creates a snapshot Manager.
func (*Manager) CleanExpired ¶
func (m *Manager) CleanExpired(ctx context.Context, maxPerService int, maxAge time.Duration) (int, error)
CleanExpired removes snapshots that exceed per-service count or age limits. It deletes the oldest snapshots first when over the count limit and removes any snapshot older than maxAge. Returns the number of snapshots removed.
func (*Manager) Create ¶
func (m *Manager) Create(ctx context.Context, tenantID, serviceID string, req CreateRequest) (*Snapshot, error)
Create captures a snapshot from a running service. It tags the service's Docker image, copies encrypted env vars, and stores resource config.
func (*Manager) Delete ¶
Delete removes a snapshot and attempts to untag the associated Docker image.
func (*Manager) GetEnvKeys ¶
func (m *Manager) GetEnvKeys(ctx context.Context, tenantID, snapshotID string) (map[string]string, error)
GetEnvKeys returns the env var keys stored in a snapshot with masked values. This allows callers to see which env vars exist without revealing their values.
type Snapshot ¶
type Snapshot struct {
ID string `json:"id"`
TenantID string `json:"tenant_id"`
ServiceID string `json:"service_id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
ImageRef string `json:"image_ref"`
ResourceConfig string `json:"resource_config,omitempty"`
Port int `json:"port"`
CreatedAt int64 `json:"created_at"`
}
Snapshot represents a point-in-time capture of a service's image, port, and resource configuration.