image

package
v0.0.0-...-890248b Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package image provides Docker image management services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateReference

func ValidateReference(reference string) error

ValidateReference validates an image reference.

Types

type BuildCallback

type BuildCallback func(progress BuildProgress)

BuildCallback is called for each build progress event.

type BuildOptions

type BuildOptions struct {
	Tags         []string           `json:"tags"`         // Image tags (e.g., ["myimage:latest"])
	Dockerfile   string             `json:"dockerfile"`   // Path to Dockerfile (default: "Dockerfile")
	BuildArgs    map[string]*string `json:"build_args"`   // Build arguments
	Target       string             `json:"target"`       // Target build stage
	NoCache      bool               `json:"no_cache"`     // Don't use cache
	Pull         bool               `json:"pull"`         // Always pull base images
	Remove       bool               `json:"remove"`       // Remove intermediate containers
	ForceRemove  bool               `json:"force_remove"` // Always remove intermediate containers
	Labels       map[string]string  `json:"labels"`       // Labels to apply to the image
	Platform     string             `json:"platform"`     // Target platform (e.g., "linux/amd64")
	SquashLayers bool               `json:"squash"`       // Squash layers into one
}

BuildOptions contains options for building an image.

type BuildProgress

type BuildProgress struct {
	Stream   string `json:"stream,omitempty"`
	Status   string `json:"status,omitempty"`
	Progress string `json:"progress,omitempty"`
	Error    string `json:"error,omitempty"`
	ID       string `json:"id,omitempty"`
}

BuildProgress represents a build progress message.

type BuildResult

type BuildResult struct {
	ImageID string   `json:"image_id"`
	Tags    []string `json:"tags"`
}

BuildResult contains the result of an image build.

type Service

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

Service provides Docker image management operations.

func NewService

func NewService(hostService *hostservice.Service, log *logger.Logger) *Service

NewService creates a new image service.

func (*Service) Build

func (s *Service) Build(ctx context.Context, hostID uuid.UUID, buildContext io.Reader, opts BuildOptions, callback BuildCallback) (*BuildResult, error)

Build builds a Docker image from a build context. The buildContext should be a tar archive containing the Dockerfile and any files needed for the build. The callback is called for each progress message from the build.

func (*Service) BuildFromDockerfile

func (s *Service) BuildFromDockerfile(ctx context.Context, hostID uuid.UUID, dockerfile string, opts BuildOptions, callback BuildCallback) (*BuildResult, error)

BuildFromDockerfile builds an image from a Dockerfile string. This is a convenience method that creates a tar context with just the Dockerfile.

func (*Service) CheckUpdate

func (s *Service) CheckUpdate(ctx context.Context, hostID uuid.UUID, reference string) (*models.ImageUpdateInfo, error)

CheckUpdate checks if a newer version of an image is available.

func (*Service) Exists

func (s *Service) Exists(ctx context.Context, hostID uuid.UUID, reference string) (bool, error)

Exists checks if an image exists.

func (*Service) Get

func (s *Service) Get(ctx context.Context, hostID uuid.UUID, imageID string) (*models.Image, error)

Get returns a specific image by ID.

func (*Service) GetDigest

func (s *Service) GetDigest(ctx context.Context, hostID uuid.UUID, reference string) (string, error)

GetDigest returns the digest of an image.

func (*Service) GetHistory

func (s *Service) GetHistory(ctx context.Context, hostID uuid.UUID, imageID string) ([]*models.ImageLayer, error)

GetHistory retrieves image layer history.

func (*Service) GetSize

func (s *Service) GetSize(ctx context.Context, hostID uuid.UUID, reference string) (int64, error)

GetSize returns the size of an image.

func (*Service) List

func (s *Service) List(ctx context.Context, hostID uuid.UUID) ([]*models.Image, error)

List returns all images on a host.

func (*Service) ListByReference

func (s *Service) ListByReference(ctx context.Context, hostID uuid.UUID, reference string) ([]*models.Image, error)

ListByReference returns images matching a reference pattern.

func (*Service) ListDangling

func (s *Service) ListDangling(ctx context.Context, hostID uuid.UUID) ([]*models.Image, error)

ListDangling returns dangling images on a host.

func (*Service) Prune

func (s *Service) Prune(ctx context.Context, hostID uuid.UUID, dangling bool) (*models.PruneResult, error)

Prune removes unused images.

func (*Service) Pull

func (s *Service) Pull(ctx context.Context, hostID uuid.UUID, reference string, auth *models.RegistryAuthConfig) error

Pull pulls an image from a registry.

func (*Service) PullWithProgress

func (s *Service) PullWithProgress(ctx context.Context, hostID uuid.UUID, reference string, auth *models.RegistryAuthConfig) (<-chan docker.PullProgress, error)

PullWithProgress pulls an image and returns a progress channel.

func (*Service) Push

func (s *Service) Push(ctx context.Context, hostID uuid.UUID, reference string, auth *models.RegistryAuthConfig) (<-chan docker.PullProgress, error)

Push pushes an image to a registry.

func (*Service) Remove

func (s *Service) Remove(ctx context.Context, hostID uuid.UUID, imageID string, force bool) error

Remove removes an image.

func (*Service) Search

func (s *Service) Search(ctx context.Context, hostID uuid.UUID, term string, limit int, auth *models.RegistryAuthConfig) ([]registry.SearchResult, error)

Search searches for images in registries.

func (*Service) Tag

func (s *Service) Tag(ctx context.Context, hostID uuid.UUID, source, target string) error

Tag tags an image.

Jump to

Keyboard shortcuts

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