image

package
v0.0.0-...-bd1a880 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrImageNotFound    = errors.New("image not found")
	ErrImageInspection  = errors.New("failed to inspect image")
	ErrImageListing     = errors.New("failed to list images")
	ErrImageHistory     = errors.New("failed to get image history")
	ErrInvalidImageID   = errors.New("invalid image ID or reference")
	ErrContextCancelled = errors.New("operation cancelled")
)

Common errors

Functions

This section is empty.

Types

type BuildOptions

type BuildOptions struct {
	Context        io.Reader
	ContextDir     string
	Dockerfile     string
	Tags           []string
	BuildArgs      map[string]*string
	NoCache        bool
	Remove         bool
	ForceRemove    bool
	PullParent     bool
	ProgressOutput io.Writer
	BuildLabels    map[string]string
	Target         string
	Platform       string
	RegistryAuth   string
}

BuildOptions defines options for building images

type Inspector

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

Inspector provides methods for inspecting Docker images

func NewInspector

func NewInspector(client InspectorClient, logger *logrus.Logger) *Inspector

NewInspector creates a new image inspector

func (*Inspector) FormatImageSize

func (i *Inspector) FormatImageSize(size int64) string

FormatImageSize formats the image size in a human-readable format

func (*Inspector) GetAllTags

func (i *Inspector) GetAllTags(ctx context.Context, imageID string) ([]string, error)

GetAllTags returns all tags for an image

func (*Inspector) GetImageCommand

func (i *Inspector) GetImageCommand(ctx context.Context, imageIDOrName string) ([]string, error)

GetImageCommand returns the default command of an image

func (*Inspector) GetImageCreationTime

func (i *Inspector) GetImageCreationTime(ctx context.Context, imageIDOrName string) (time.Time, error)

GetImageCreationTime returns the creation time of an image

func (*Inspector) GetImageDigest

func (i *Inspector) GetImageDigest(ctx context.Context, imageIDOrName string) (string, error)

GetImageDigest extracts the digest from an image

func (*Inspector) GetImageEntrypoint

func (i *Inspector) GetImageEntrypoint(ctx context.Context, imageIDOrName string) ([]string, error)

GetImageEntrypoint returns the entrypoint of an image

func (*Inspector) GetImageEnvironment

func (i *Inspector) GetImageEnvironment(ctx context.Context, imageIDOrName string) ([]string, error)

GetImageEnvironment returns the environment variables of an image

func (*Inspector) GetImageExposedPorts

func (i *Inspector) GetImageExposedPorts(ctx context.Context, imageIDOrName string) (map[string]struct{}, error)

GetImageExposedPorts returns the exposed ports of an image as map[string]struct{}

func (*Inspector) GetImageLabels

func (i *Inspector) GetImageLabels(ctx context.Context, imageIDOrName string) (map[string]string, error)

GetImageLabels returns the labels of an image

func (*Inspector) GetImageLayers

func (i *Inspector) GetImageLayers(ctx context.Context, imageIDOrName string) ([]string, error)

GetImageLayers returns the layers of an image

func (*Inspector) GetImageOSArch

func (i *Inspector) GetImageOSArch(ctx context.Context, imageIDOrName string) (string, string, error)

GetImageOSArch returns the OS and architecture of an image

func (*Inspector) GetImageSize

func (i *Inspector) GetImageSize(ctx context.Context, imageIDOrName string) (int64, error)

GetImageSize returns the size of an image in bytes

func (*Inspector) GetTotalImageDiskUsage

func (i *Inspector) GetTotalImageDiskUsage(ctx context.Context) (int64, error)

GetTotalImageDiskUsage returns the total disk space used by all images

func (*Inspector) GetTotalImagesCount

func (i *Inspector) GetTotalImagesCount(ctx context.Context) (int, error)

GetTotalImagesCount returns the total number of images

func (*Inspector) History

func (i *Inspector) History(ctx context.Context, imageIDOrName string) ([]imagetypes.HistoryResponseItem, error)

History returns the history of a Docker image

func (*Inspector) ImageExists

func (i *Inspector) ImageExists(ctx context.Context, imageIDOrName string) (bool, error)

ImageExists checks if an image exists

func (*Inspector) Inspect

func (i *Inspector) Inspect(ctx context.Context, imageIDOrName string) (types.ImageInspect, error)

Inspect returns detailed information about a Docker image

func (*Inspector) List

func (i *Inspector) List(ctx context.Context, options ListOptions) ([]imagetypes.Summary, error)

List returns a list of Docker images based on the provided options

type InspectorClient

type InspectorClient interface {
	ImageList(ctx context.Context, options imagetypes.ListOptions) ([]imagetypes.Summary, error)
	ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error)
	ImageHistory(ctx context.Context, imageID string, options ...client.ImageHistoryOption) ([]imagetypes.HistoryResponseItem, error) // Added options parameter
}

InspectorClient defines the interface for Docker client methods used by the image inspector.

type ListOptions

type ListOptions struct {
	All                bool
	FilterLabels       map[string]string
	FilterDanglingOnly bool
	MatchName          string
	FilterBefore       string
	FilterSince        string
	FilterReference    string
}

ListOptions defines options for listing images

type PruneOptions

type PruneOptions struct {
	FilterLabels map[string]string
	FilterUntil  string
	All          bool
}

PruneOptions defines options for pruning images

type PullOptions

type PullOptions struct {
	All            bool
	Platform       string
	RegistryAuth   string
	ProgressOutput io.Writer
	Quiet          bool
}

PullOptions defines options for pulling images

type RemoveOptions

type RemoveOptions struct {
	Force         bool
	PruneChildren bool
}

RemoveOptions defines options for removing images

type SearchOptions

type SearchOptions struct {
	Limit           int
	FilterStars     int
	FilterAutomated bool
	FilterOfficial  bool
}

SearchOptions defines options for searching images

type Service

type Service interface {
	ImagePull(ctx context.Context, refStr string, options image.PullOptions) (io.ReadCloser, error)
	ImageInspectWithRaw(ctx context.Context, imageID string) (image.InspectResponse, []byte, error)               // Use direct type
	ImageRemove(ctx context.Context, imageID string, options image.RemoveOptions) ([]image.DeleteResponse, error) // Use direct type
	List(ctx context.Context, options ListOptions) ([]imagetypes.Summary, error)                                  // Use imagetypes.Summary
	Build(ctx context.Context, options BuildOptions) (io.ReadCloser, error)
	Tag(ctx context.Context, imageID, ref string) error
	Inspect(ctx context.Context, imageID string) (imagetypes.InspectResponse, error)                      // Use types.ImageInspect
	History(ctx context.Context, imageID string) ([]imagetypes.HistoryResponseItem, error)                // Use imagetypes.HistoryResponseItem
	Prune(ctx context.Context, options PruneOptions) (imagetypes.PruneReport, error)                      // Use imagetypes.PruneReport
	Search(ctx context.Context, term string, options SearchOptions) ([]registrytypes.SearchResult, error) // Use registrytypes.SearchResult
}

Service defines the interface for Docker image operations Aligned with interfaces.ImageService

func NewService

func NewService(dockerManager docker.Manager, logger *logrus.Logger) Service

NewService creates a new image service implementation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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