// Package registry is responsible for fetching data from the backend registry // and providing the data for the UI components. package registry import ( "context" "errors" "time" ) // ErrNotFound should be returned for missing repositories/manifests. var ErrNotFound = errors.New("registry resource not found") type Provider interface { Repositories(ctx context.Context) ([]Repository, error) Repository(ctx context.Context, name string) (Repository, error) Manifest(ctx context.Context, repository, digest string) (Manifest, error) } type Repository struct { Name string `json:"name"` UpdatedAt time.Time `json:"updated_at"` Age string `json:"age,omitempty"` Tags []Tag `json:"tags"` } type Tag struct { Name string `json:"name"` Aliases []string `json:"aliases,omitempty"` UpdatedAt time.Time `json:"updated_at"` Age string `json:"age,omitempty"` Platforms string `json:"platforms,omitempty"` SizeBytes int64 `json:"size_bytes,omitempty"` ManifestDigest string `json:"manifest_digest"` } type Manifest struct { Repository string `json:"repository"` Digest string `json:"digest"` Kind string `json:"kind"` // "index" for a list; "image" for layers. SizeBytes int64 `json:"size_bytes,omitempty"` // Registry-reported image total, when available. Tags []TagReference `json:"tags"` Platforms []PlatformManifest `json:"platforms,omitempty"` Layers []Layer `json:"layers,omitempty"` } func (m Manifest) TotalSizeBytes() int64 { if m.SizeBytes > 0 { return m.SizeBytes } var total int64 for _, layer := range m.Layers { total += layer.SizeBytes } return total } type TagReference struct { Name string `json:"name"` UpdatedAt time.Time `json:"updated_at"` Age string `json:"age,omitempty"` ManifestDigest string `json:"manifest_digest"` } type PlatformManifest struct { Platform string `json:"platform"` Variant string `json:"variant,omitempty"` SizeBytes int64 `json:"size_bytes"` Digest string `json:"digest"` } type Layer struct { Digest string `json:"digest"` SizeBytes int64 `json:"size_bytes"` }