Documentation
¶
Overview ¶
Package image provides Docker image management services.
Index ¶
- func ValidateReference(reference string) error
- type BuildCallback
- type BuildOptions
- type BuildProgress
- type BuildResult
- type Service
- func (s *Service) Build(ctx context.Context, hostID uuid.UUID, buildContext io.Reader, ...) (*BuildResult, error)
- func (s *Service) BuildFromDockerfile(ctx context.Context, hostID uuid.UUID, dockerfile string, opts BuildOptions, ...) (*BuildResult, error)
- func (s *Service) CheckUpdate(ctx context.Context, hostID uuid.UUID, reference string) (*models.ImageUpdateInfo, error)
- func (s *Service) Exists(ctx context.Context, hostID uuid.UUID, reference string) (bool, error)
- func (s *Service) Get(ctx context.Context, hostID uuid.UUID, imageID string) (*models.Image, error)
- func (s *Service) GetDigest(ctx context.Context, hostID uuid.UUID, reference string) (string, error)
- func (s *Service) GetHistory(ctx context.Context, hostID uuid.UUID, imageID string) ([]*models.ImageLayer, error)
- func (s *Service) GetSize(ctx context.Context, hostID uuid.UUID, reference string) (int64, error)
- func (s *Service) List(ctx context.Context, hostID uuid.UUID) ([]*models.Image, error)
- func (s *Service) ListByReference(ctx context.Context, hostID uuid.UUID, reference string) ([]*models.Image, error)
- func (s *Service) ListDangling(ctx context.Context, hostID uuid.UUID) ([]*models.Image, error)
- func (s *Service) Prune(ctx context.Context, hostID uuid.UUID, dangling bool) (*models.PruneResult, error)
- func (s *Service) Pull(ctx context.Context, hostID uuid.UUID, reference string, ...) error
- func (s *Service) PullWithProgress(ctx context.Context, hostID uuid.UUID, reference string, ...) (<-chan docker.PullProgress, error)
- func (s *Service) Push(ctx context.Context, hostID uuid.UUID, reference string, ...) (<-chan docker.PullProgress, error)
- func (s *Service) Remove(ctx context.Context, hostID uuid.UUID, imageID string, force bool) error
- func (s *Service) Search(ctx context.Context, hostID uuid.UUID, term string, limit int, ...) ([]registry.SearchResult, error)
- func (s *Service) Tag(ctx context.Context, hostID uuid.UUID, source, target string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateReference ¶
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 ¶
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) 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) 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 ¶
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.