Documentation
¶
Overview ¶
Package storageinv builds the volume and stopped-container inventory the Storage page shows, and owns the rule that keeps database data from being offered for deletion.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DatabaseOwner ¶
DatabaseOwner returns the database a volume name belongs to, or "".
func IsProtectedVolume ¶
IsProtectedVolume reports whether v must never be offered for deletion by any cleanup path: a db- name, or a volume a database resource owns.
func IsProtectedVolumeName ¶
IsProtectedVolumeName is the name-only form of IsProtectedVolume for delete paths that hold a volume name and nothing else.
Types ¶
type Container ¶
type Container struct {
ID string `json:"id"`
Name string `json:"name"`
SizeBytes *int64 `json:"size_bytes,omitempty"`
OwnerApp string `json:"owner_app,omitempty"`
ExitedAt *time.Time `json:"exited_at,omitempty"`
}
Container is one stopped container row.
func BuildContainers ¶
func BuildContainers(raw []docker.InventoryContainer, o Owners) []Container
BuildContainers joins stopped containers with their owning app, taken from the Levelrail label first and the container name second.
type Owners ¶
type Owners struct {
// VolumeApp maps a Docker volume name to the app declaring it.
VolumeApp map[string]string
// Databases are the names of every managed database resource.
Databases map[string]bool
// Referenced holds every volume name desired state still references.
Referenced map[string]bool
// ContainerApp resolves an app from a container name, or "".
ContainerApp func(name string) string
}
Owners is the desired-state knowledge ownership is resolved from.
type Source ¶
type Source interface {
ListAllVolumes(ctx context.Context) ([]docker.InventoryVolume, error)
ListStoppedContainers(ctx context.Context) ([]docker.InventoryContainer, error)
}
Source is the read side of a Docker daemon. *docker.Client satisfies it.
type Volume ¶
type Volume struct {
Name string `json:"name"`
SizeBytes *int64 `json:"size_bytes,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
InUse bool `json:"in_use"`
Labels map[string]string `json:"labels,omitempty"`
OwnerApp string `json:"owner_app,omitempty"`
// Database is the database resource owning the volume, when one does.
Database string `json:"database,omitempty"`
IsDatabase bool `json:"is_database"`
Orphaned bool `json:"orphaned"`
Protected bool `json:"protected"`
// ProtectReason is plain text for the Reason column, empty when unprotected.
ProtectReason string `json:"protect_reason,omitempty"`
}
Volume is one inventory row.
func BuildVolumes ¶
func BuildVolumes(raw []docker.InventoryVolume, o Owners) []Volume
BuildVolumes joins raw Docker volumes with ownership. A volume is orphaned when nothing in desired state references it, no container mounts it and no database owns it.