image

package
v1.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package image manages the built-image catalog: provenance written by the pipeline build step, read APIs for the UI, and a retention GC that never collects a digest a live deployment or pinned release references.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound  = errors.New("image not found")
	ErrInUse     = errors.New("image is referenced by a live deployment or pinned release")
	ErrNoDigest  = errors.New("image digest is required")
	ErrNoWorkspc = errors.New("workspace is required")
)

Functions

This section is empty.

Types

type GCReport

type GCReport struct {
	Deleted   int   `json:"deleted"`
	Protected int   `json:"protected"`
	FreedBy   int64 `json:"freed_bytes"`
}

GCReport summarizes a sweep.

type RecordInput

type RecordInput struct {
	WorkspaceID   uint
	Repository    string // repo name, e.g. "miabi/app-5"
	Tag           string // human tag, e.g. the run number
	Digest        string // sha256:… (image id for a local-only build)
	SizeBytes     int64
	ApplicationID *uint
	PipelineRunID *uint
	Commit        string
	Runner        string // "internal" | "<runner-name>"
}

RecordInput is the provenance written after a successful build.

type Remover

type Remover interface {
	RemoveImage(ctx context.Context, ref string, force bool) error
}

Remover deletes a built image from the node it lives on. The service stays node-agnostic; callers supply the local engine client (docker.Client satisfies this). A nil Remover skips physical removal (DB-only).

type RetentionPolicy

type RetentionPolicy struct {
	KeepPerApp int
	MinAge     time.Duration
}

RetentionPolicy bounds the catalog: keep at least the newest KeepPerApp images per application, and only ever collect images older than MinAge. Protected images (live/pinned releases) are exempt regardless.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the image catalog: write provenance, list, and GC.

func NewService

func NewService(images *repositories.ImageRepository, releases *repositories.ReleaseRepository) *Service

NewService wires the image catalog service.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, workspaceID, id uint, remover Remover) error

Delete removes a catalog image (and its physical layer via remover) unless it is protected by a live or pinned release.

func (*Service) GC

func (s *Service) GC(ctx context.Context, policy RetentionPolicy, remover Remover) (GCReport, error)

GC applies retention across all workspaces. It keeps the newest KeepPerApp images per app, never deletes an image referenced by a live or pinned release, and only collects images older than MinAge. remover may be nil (DB-only).

func (*Service) Get

func (s *Service) Get(workspaceID, id uint) (*models.Image, error)

Get returns one catalog image scoped to the workspace.

func (*Service) List

func (s *Service) List(workspaceID uint, appID *uint) ([]models.Image, error)

List returns the workspace's catalog, optionally narrowed to one application.

func (*Service) Record

func (s *Service) Record(in RecordInput) (*models.Image, error)

Record stores (or updates) the catalog entry for a freshly built image. The (workspace, digest) pair is unique, so re-recording the same digest updates provenance rather than duplicating — building the same content twice yields one row.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL