imagepruning

package
v1.2.0-main Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package imagepruning is a generated GoMock package.

Index

Constants

View Source
const (
	RefTypePodman   = "podman"   // Container images for podman apps (compose, quadlet, container)
	RefTypeCRI      = "cri"      // Container images for Kubernetes/Helm workloads
	RefTypeArtifact = "artifact" // OCI artifacts (volumes, etc.)
	RefTypeHelm     = "helm"     // Helm charts (stored in helm cache, not image storage)
)

RefType constants for tracking what pulled each image

View Source
const (
	// ReferencesFileName is the name of the file that stores image and artifact references
	ReferencesFileName = "image-artifact-references.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EligibleItems

type EligibleItems struct {
	Images    []ImageRef // Podman images eligible for removal
	Artifacts []ImageRef // Podman artifacts eligible for removal
	CRI       []ImageRef // CRI images eligible for removal
	Helm      []ImageRef // Helm charts eligible for removal
}

EligibleItems holds lists of eligible items for pruning, organized by type.

type ImageArtifactReferences

type ImageArtifactReferences struct {
	Timestamp  string     `json:"timestamp"`
	References []ImageRef `json:"references"` // Single list of all references (no categorization)
}

ImageArtifactReferences holds all image and artifact references from specs. References are stored without categorization during recording. Categorization happens during pruning when we can check if they exist as images or artifacts.

type ImagePruningConfig

type ImagePruningConfig = config.ImagePruning

ImagePruningConfig holds configuration for image pruning operations. This type is defined in internal/agent/config/config.go as config.ImagePruning and is aliased here for backward compatibility and clarity.

type ImageRef

type ImageRef struct {
	Image string           `json:"image"`
	Owner v1beta1.Username `json:"owner"`
	Type  string           `json:"type"` // One of RefType* constants
}

ImageRef represents a reference to an image, artifact, or helm chart with its source type.

type Manager

type Manager interface {
	// Prune removes unused container images and OCI artifacts after successful spec reconciliation.
	// It preserves images required for current and desired operations.
	Prune(ctx context.Context) error
	// RecordReferences records all image and artifact references from current and desired specs to a file.
	// This ensures the references file exists and is kept up to date even when pruning is disabled,
	// so that when pruning is later enabled, it has accurate historical data to work with.
	// current and desired are the device specs to extract references from.
	RecordReferences(ctx context.Context, current, desired *v1beta1.Device) error
	// ReloadConfig reloads the pruning configuration from the agent config.
	// This is called when the agent receives a SIGHUP signal to reload configuration.
	ReloadConfig(ctx context.Context, cfg *config.Config) error

	// PrunePending indicates whether a prune operation is pending due to config change.
	PrunePending() bool
}

Manager provides the public API for managing image pruning operations.

func New

func New(
	podmanClientFactory client.PodmanFactory,
	rootPodmanClient *client.Podman,
	clients client.CLIClients,
	specManager spec.Manager,
	rwFactory fileio.ReadWriterFactory,
	readWriter fileio.ReadWriter,
	log *log.PrefixLogger,
	config ImagePruningConfig,
	dataDir string,
) Manager

New creates a new pruning manager instance.

Dependencies:

  • podmanClient: Podman client for image/artifact operations
  • clients: CLI clients for Helm and Kube operations
  • specManager: Spec manager for reading current and desired specs
  • readWriter: File I/O interface for any file operations
  • log: Logger for structured logging
  • config: Pruning configuration (enabled flag, etc.)
  • dataDir: Directory where data files are stored

type MockManager

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

MockManager is a mock of Manager interface.

func NewMockManager

func NewMockManager(ctrl *gomock.Controller) *MockManager

NewMockManager creates a new mock instance.

func (*MockManager) EXPECT

func (m *MockManager) EXPECT() *MockManagerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockManager) Prune

func (m *MockManager) Prune(ctx context.Context) error

Prune mocks base method.

func (*MockManager) PrunePending

func (m *MockManager) PrunePending() bool

PrunePending mocks base method.

func (*MockManager) RecordReferences

func (m *MockManager) RecordReferences(ctx context.Context, current, desired *v1beta1.Device) error

RecordReferences mocks base method.

func (*MockManager) ReloadConfig

func (m *MockManager) ReloadConfig(ctx context.Context, cfg *config.Config) error

ReloadConfig mocks base method.

type MockManagerMockRecorder

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

MockManagerMockRecorder is the mock recorder for MockManager.

func (*MockManagerMockRecorder) Prune

func (mr *MockManagerMockRecorder) Prune(ctx any) *gomock.Call

Prune indicates an expected call of Prune.

func (*MockManagerMockRecorder) PrunePending

func (mr *MockManagerMockRecorder) PrunePending() *gomock.Call

PrunePending indicates an expected call of PrunePending.

func (*MockManagerMockRecorder) RecordReferences

func (mr *MockManagerMockRecorder) RecordReferences(ctx, current, desired any) *gomock.Call

RecordReferences indicates an expected call of RecordReferences.

func (*MockManagerMockRecorder) ReloadConfig

func (mr *MockManagerMockRecorder) ReloadConfig(ctx, cfg any) *gomock.Call

ReloadConfig indicates an expected call of ReloadConfig.

Jump to

Keyboard shortcuts

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