image

package
v2.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: BSD-3-Clause Imports: 59 Imported by: 0

Documentation

Overview

Package image owns Docker image operations, metadata, attestations, and routes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildVolumeUsageMap

func BuildVolumeUsageMap(containers []container.Summary, projectIDByName map[string]string) map[string][]imagetypes.UsedBy

func MapDockerImagesToDTOs

func MapDockerImagesToDTOs(dockerImages []image.Summary, usageMap map[string][]imagetypes.UsedBy, updateMap map[string]*imageupdate.ImageUpdateRecord, vulnerabilityMap map[string]*vulnerabilitytypes.ScanSummary) []imagetypes.Summary

func RegisterImages

func RegisterImages(api huma.API, dockerService *docker.DockerClientService, imageService *ImageService, imageUpdateService *imageupdate.ImageUpdateService, settingsService *settings.SettingsService, buildService *build.BuildService, activityService *activity.ActivityService, uploadService *upload.UploadService, appCtx handlerutil.ActivityAppContext)

RegisterImages registers image management routes using Huma.

func ShouldRetryAnonymousPull

func ShouldRetryAnonymousPull(pullOptions client.ImagePullOptions, pullErr error) bool

Types

type BuildImageInput

type BuildImageInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Body          buildtypes.BuildRequest
}

type Dependencies

type Dependencies struct {
	Docker      *docker.DockerClientService
	ImageUpdate *imageupdate.ImageUpdateService
	Settings    *settings.SettingsService
	Build       *build.BuildService
	Activity    *activity.ActivityService
	Upload      *upload.UploadService
}

type ExportImageInput

type ExportImageInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ImageName     string `path:"name" doc:"Image ID or image reference"`
}

type GetImageAttestationsInput

type GetImageAttestationsInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ImageName     string `path:"name" doc:"Image ID or image reference"`
	Platform      string `query:"platform" doc:"OCI platform selector, for example linux/amd64"`
	PredicateType string `query:"predicateType" doc:"Exact in-toto predicate type URI to include"`
	WithStatement bool   `query:"statement" default:"false" doc:"Include verbatim statement JSON bodies"`
}

type GetImageAttestationsOutput

type GetImageAttestationsOutput struct {
	Body base.ApiResponse[image.AttestationList]
}

type GetImageBuildInput

type GetImageBuildInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	BuildID       string `path:"buildId" doc:"Build ID"`
}

type GetImageBuildOutput

type GetImageBuildOutput struct {
	Body base.ApiResponse[image.BuildRecord]
}

type GetImageHistoryInput

type GetImageHistoryInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ImageName     string `path:"name" doc:"Image ID or image reference"`
}

type GetImageHistoryOutput

type GetImageHistoryOutput struct {
	Body base.ApiResponse[[]image.HistoryItem]
}

type GetImageInput

type GetImageInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ImageID       string `path:"imageId" doc:"Image ID"`
}

type GetImageOutput

type GetImageOutput struct {
	Body base.ApiResponse[image.DetailSummary]
}

type GetImageUsageCountsInput

type GetImageUsageCountsInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
}

type GetImageUsageCountsOutput

type GetImageUsageCountsOutput struct {
	Body base.ApiResponse[image.UsageCounts]
}

type ImageAttestationQuery

type ImageAttestationQuery struct {
	Platform         string
	PredicateType    string
	IncludeStatement bool
}

type ImageHandler

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

ImageHandler provides Huma-based image management endpoints.

func (*ImageHandler) BuildImage

func (h *ImageHandler) BuildImage(ctx context.Context, input *BuildImageInput) (*huma.StreamResponse, error)

BuildImage builds a Docker image with streaming progress.

func (*ImageHandler) ExportImage

func (h *ImageHandler) ExportImage(ctx context.Context, input *ExportImageInput) (*huma.StreamResponse, error)

ExportImage streams a Docker image tar archive.

func (*ImageHandler) GetImage

func (h *ImageHandler) GetImage(ctx context.Context, input *GetImageInput) (*GetImageOutput, error)

GetImage returns an image by ID.

func (*ImageHandler) GetImageAttestations

func (h *ImageHandler) GetImageAttestations(ctx context.Context, input *GetImageAttestationsInput) (*GetImageAttestationsOutput, error)

GetImageAttestations returns in-toto attestation statements attached to an image.

func (*ImageHandler) GetImageBuild

func (h *ImageHandler) GetImageBuild(ctx context.Context, input *GetImageBuildInput) (*GetImageBuildOutput, error)

GetImageBuild returns a single build history entry.

func (*ImageHandler) GetImageHistory

func (h *ImageHandler) GetImageHistory(ctx context.Context, input *GetImageHistoryInput) (*GetImageHistoryOutput, error)

GetImageHistory returns Docker image layer history.

func (*ImageHandler) GetImageUsageCounts

func (h *ImageHandler) GetImageUsageCounts(ctx context.Context, input *GetImageUsageCountsInput) (*GetImageUsageCountsOutput, error)

GetImageUsageCounts returns counts of images by usage status.

func (*ImageHandler) ListImageBuilds

func (h *ImageHandler) ListImageBuilds(ctx context.Context, input *ListImageBuildsInput) (*ListImageBuildsOutput, error)

ListImageBuilds returns a paginated list of image build history entries.

func (*ImageHandler) ListImages

func (h *ImageHandler) ListImages(ctx context.Context, input *ListImagesInput) (*ListImagesOutput, error)

ListImages returns a paginated list of images.

func (*ImageHandler) PruneImages

func (h *ImageHandler) PruneImages(ctx context.Context, input *PruneImagesInput) (*PruneImagesOutput, error)

PruneImages removes unused Docker images.

func (*ImageHandler) PullImage

func (h *ImageHandler) PullImage(ctx context.Context, input *PullImageInput) (*huma.StreamResponse, error)

PullImage pulls a Docker image with streaming progress.

func (*ImageHandler) RemoveImage

func (h *ImageHandler) RemoveImage(ctx context.Context, input *RemoveImageInput) (*RemoveImageOutput, error)

RemoveImage removes a Docker image.

func (*ImageHandler) SearchImages

func (h *ImageHandler) SearchImages(ctx context.Context, input *SearchImagesInput) (*SearchImagesOutput, error)

SearchImages searches Docker Hub images.

func (*ImageHandler) TagImage

func (h *ImageHandler) TagImage(ctx context.Context, input *TagImageInput) (*TagImageOutput, error)

TagImage adds a repository tag to an image.

func (*ImageHandler) UploadImage

func (h *ImageHandler) UploadImage(ctx context.Context, input *UploadImageInput) (*UploadImageOutput, error)

UploadImage uploads a Docker image from a tar archive.

type ImageService

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

func NewImageService

func NewImageService(db *database.DB, dockerService *docker.DockerClientService, registryService *registry.ContainerRegistryService, imageUpdateService *imageupdate.ImageUpdateService, vulnerabilityService *vulnerability.VulnerabilityService, eventService *event.EventService) *ImageService

func (*ImageService) BuildProjectIDMap

func (s *ImageService) BuildProjectIDMap(ctx context.Context, containers []container.Summary) map[string]string

BuildProjectIDMap returns a map of compose project name → project ID for any containers that carry the com.docker.compose.project label. The lookup uses a short-TTL cache shared across all callers of this ImageService instance.

func (*ImageService) ExportImage

func (s *ImageService) ExportImage(ctx context.Context, imageName string) (io.ReadCloser, error)

ExportImage returns a tar stream for one Docker image.

func (*ImageService) GetImageAttestations

func (s *ImageService) GetImageAttestations(ctx context.Context, imageName string, query ImageAttestationQuery) (*imagetypes.AttestationList, error)

GetImageAttestations returns in-toto attestations attached to a local image or registry reference.

func (*ImageService) GetImageDetail

func (s *ImageService) GetImageDetail(ctx context.Context, id string) (*imagetypes.DetailSummary, error)

GetImageDetail returns a DetailSummary for the given image ID. It fetches ImageInspect and ImageList concurrently so the size field reflects the same metric shown in the image table (docker image ls / docker system df).

func (*ImageService) GetImageHistory

func (s *ImageService) GetImageHistory(ctx context.Context, imageName string) ([]imagetypes.HistoryItem, error)

GetImageHistory returns layer history for an image.

func (*ImageService) GetUpdateInfoByImageIDs

func (s *ImageService) GetUpdateInfoByImageIDs(ctx context.Context, imageIDs []string) (map[string]*imagetypes.UpdateInfo, error)

GetUpdateInfoByImageIDs returns a map of image ID to UpdateInfo for the given image IDs. This is used by the container service to populate update info for containers.

func (*ImageService) GetUpdateInfoByImageRefs

func (s *ImageService) GetUpdateInfoByImageRefs(ctx context.Context, imageRefs []string) (map[string]*imagetypes.UpdateInfo, error)

GetUpdateInfoByImageRefs returns persisted update information keyed by the original image reference string.

func (*ImageService) ImageExistsLocally

func (s *ImageService) ImageExistsLocally(ctx context.Context, imageName string) (bool, error)

func (*ImageService) ImageLastTagTime added in v2.8.1

func (s *ImageService) ImageLastTagTime(ctx context.Context, imageName string) (time.Time, error)

ImageLastTagTime returns when the local image was last tagged, zero when the engine doesn't report it. Pull-policy refresh windows compare against this timestamp, the same clock compose v5.5.0 uses.

func (*ImageService) ListImagesPaginated

func (s *ImageService) ListImagesPaginated(ctx context.Context, params pagination.QueryParams) ([]imagetypes.Summary, pagination.Response, error)

func (*ImageService) LoadImageFromReader

func (s *ImageService) LoadImageFromReader(ctx context.Context, reader io.Reader, fileName string, user common.User, maxSizeBytes int64) (*imagetypes.LoadResult, error)

func (*ImageService) PruneImages

func (*ImageService) PullImage

func (s *ImageService) PullImage(ctx context.Context, imageName string, progressWriter io.Writer, user common.User, externalCreds []containerregistry.Credential) error

func (*ImageService) PullOptionsWithAuth

func (s *ImageService) PullOptionsWithAuth(ctx context.Context, imageRef string, externalCreds []containerregistry.Credential) (client.ImagePullOptions, error)

func (*ImageService) ReconcilePulledImageUpdate

func (s *ImageService) ReconcilePulledImageUpdate(ctx context.Context, imageName string) error

func (*ImageService) RemoveImage

func (s *ImageService) RemoveImage(ctx context.Context, id string, force bool, user common.User) error

func (*ImageService) SearchImages

func (s *ImageService) SearchImages(ctx context.Context, term string) ([]imagetypes.SearchResult, error)

SearchImages searches the configured Docker registry for images.

func (*ImageService) TagImage

func (s *ImageService) TagImage(ctx context.Context, source string, req imagetypes.TagRequest, user common.User) error

TagImage adds a repository tag to an existing image.

type ListImageBuildsInput

type ListImageBuildsInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Search        string `query:"search" doc:"Search query"`
	Sort          string `query:"sort" doc:"Column to sort by"`
	Order         string `query:"order" default:"desc" doc:"Sort direction (asc or desc)"`
	Start         int    `query:"start" default:"0" doc:"Start index for pagination"`
	Limit         int    `query:"limit" default:"20" doc:"Number of items per page"`
	Status        string `query:"status" doc:"Filter by status"`
	Provider      string `query:"provider" doc:"Filter by provider"`
}

type ListImageBuildsOutput

type ListImageBuildsOutput struct {
	Body base.Paginated[image.BuildRecord]
}

type ListImagesInput

type ListImagesInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Search        string `query:"search" doc:"Search query"`
	Sort          string `query:"sort" doc:"Column to sort by"`
	Order         string `query:"order" default:"asc" doc:"Sort direction (asc or desc)"`
	Start         int    `query:"start" default:"0" doc:"Start index for pagination"`
	Limit         int    `query:"limit" default:"20" doc:"Number of items per page"`
	InUse         string `query:"inUse" doc:"Filter by in-use status (true/false)"`
	Updates       string `query:"updates" doc:"Filter by update availability (true/false)"`
}

type ListImagesOutput

type ListImagesOutput struct {
	Body base.Paginated[image.Summary]
}

type Module

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

func New

func New(service *ImageService, deps Dependencies) *Module

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(api huma.API, appCtx handlerutil.ActivityAppContext)

func (*Module) Service

func (m *Module) Service() *ImageService

type PruneImagesInput

type PruneImagesInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Dangling      bool   `query:"dangling" doc:"Only remove dangling images"`
	Body          *struct {
		Mode     *string             `json:"mode,omitempty"`
		Until    *string             `json:"until,omitempty"`
		Dangling *bool               `json:"dangling,omitempty"`
		Filters  map[string][]string `json:"filters,omitempty"`
	}
}

type PruneImagesOutput

type PruneImagesOutput struct {
	Body base.ApiResponse[image.PruneReport]
}

type PullImageInput

type PullImageInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Body          image.PullOptions
}

type RemoveImageInput

type RemoveImageInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ImageID       string `path:"imageId" doc:"Image ID"`
	Force         bool   `query:"force" doc:"Force removal"`
}

type RemoveImageOutput

type RemoveImageOutput struct {
	Body base.ApiResponse[base.MessageResponse]
}

type SearchImagesInput

type SearchImagesInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Term          string `query:"term" doc:"Search term"`
}

type SearchImagesOutput

type SearchImagesOutput struct {
	Body base.ApiResponse[[]image.SearchResult]
}

type TagImageInput

type TagImageInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ImageName     string `path:"name" doc:"Image ID or image reference"`
	Body          image.TagRequest
}

type TagImageOutput

type TagImageOutput struct {
	Body base.ApiResponse[base.MessageResponse]
}

type UploadImageInput

type UploadImageInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Body          uploadtypes.ConsumeRequest
}

type UploadImageOutput

type UploadImageOutput struct {
	Body base.ApiResponse[image.LoadResult]
}

Jump to

Keyboard shortcuts

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