image

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2019 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoSuchCtr indicates the requested container does not exist
	ErrNoSuchCtr = errors.New("no such container")
	// ErrNoSuchPod indicates the requested pod does not exist
	ErrNoSuchPod = errors.New("no such pod")
	// ErrNoSuchImage indicates the requested image does not exist
	ErrNoSuchImage = errors.New("no such image")
)

Copied directly from libpod errors to avoid circular imports

View Source
var (
	// DockerArchive is the transport we prepend to an image name
	// when saving to docker-archive
	DockerArchive = dockerarchive.Transport.Name()
	// OCIArchive is the transport we prepend to an image name
	// when saving to oci-archive
	OCIArchive = ociarchive.Transport.Name()
	// DirTransport is the transport for pushing and pulling
	// images to and from a directory
	DirTransport = directory.Transport.Name()
	// DockerTransport is the transport for docker registries
	DockerTransport = docker.Transport.Name()
	// AtomicTransport is the transport for atomic registries
	AtomicTransport = "atomic"
	// DefaultTransport is a prefix that we apply to an image name
	// NOTE: This is a string prefix, not actually a transport name usable for transports.Get();
	// and because syntaxes of image names are transport-dependent, the prefix is not really interchangeable;
	// each user implicitly assumes the appended string is a Docker-like reference.
	DefaultTransport = DockerTransport + "://"
	// DefaultLocalRegistry is the default local registry for local image operations
	// Remote pulls will still use defined registries
	DefaultLocalRegistry = "localhost"
)
View Source
var ErrRepoTagNotFound = errors.New("unable to match user input to any specific repotag")

ErrRepoTagNotFound is the error returned when the image id given doesn't match a rep tag in store

Functions

func GetAdditionalTags added in v0.5.4

func GetAdditionalTags(images []string) ([]reference.NamedTagged, error)

GetAdditionalTags returns a list of reference.NamedTagged for the additional tags given in images

func GetImageBaseName added in v1.0.0

func GetImageBaseName(input string) (string, error)

GetImageBaseName uses decompose and string splits to obtain the base name of an image. Doing this here because it beats changing the imageParts struct names to be exported as well.

func GetLayersMapWithImageInfo added in v1.2.0

func GetLayersMapWithImageInfo(imageruntime *Runtime) (map[string]*LayerInfo, error)

GetLayersMapWithImageInfo returns map of image-layers, with associated information like RepoTags, parent and list of child layers.

func GetSystemContext added in v0.3.3

func GetSystemContext(signaturePolicyPath, authFilePath string, forceCompress bool) *types.SystemContext

GetSystemContext Constructs a new containers/image/types.SystemContext{} struct from the given signaturePolicy path

func IsValidImageURI added in v1.0.0

func IsValidImageURI(imguri string) (bool, error)

IsValidImageURI checks if image name has valid format

func ReposToMap added in v0.3.4

func ReposToMap(repotags []string) (map[string][]string, error)

ReposToMap parses the specified repotags and returns a map with repositories as keys and the corresponding arrays of tags as values.

Types

type DockerRegistryOptions added in v0.3.3

type DockerRegistryOptions struct {
	// DockerRegistryCreds is the user name and password to supply in case
	// we need to pull an image from a registry, and it requires us to
	// authenticate.
	DockerRegistryCreds *types.DockerAuthConfig
	// DockerCertPath is the location of a directory containing CA
	// certificates which will be used to verify the registry's certificate
	// (all files with names ending in ".crt"), and possibly client
	// certificates and private keys (pairs of files with the same name,
	// except for ".cert" and ".key" suffixes).
	DockerCertPath string
	// DockerInsecureSkipTLSVerify turns off verification of TLS
	// certificates and allows connecting to registries without encryption
	// - or forces it on even if registries.conf has the registry configured as insecure.
	DockerInsecureSkipTLSVerify types.OptionalBool
}

DockerRegistryOptions encapsulates settings that affect how we connect or authenticate to a remote registry.

func (DockerRegistryOptions) GetSystemContext added in v0.3.3

func (o DockerRegistryOptions) GetSystemContext(parent *types.SystemContext, additionalDockerArchiveTags []reference.NamedTagged) *types.SystemContext

GetSystemContext constructs a new system context from a parent context. the values in the DockerRegistryOptions, and other parameters.

type History added in v0.6.4

type History struct {
	ID        string     `json:"id"`
	Created   *time.Time `json:"created"`
	CreatedBy string     `json:"createdBy"`
	Size      int64      `json:"size"`
	Comment   string     `json:"comment"`
}

History contains the history information of an image

type Image

type Image struct {
	inspect.ImageData
	inspect.ImageResult

	InputName string
	Local     bool
	// contains filtered or unexported fields
}

Image is the primary struct for dealing with images It is still very much a work in progress

func (*Image) Annotations added in v0.3.4

func (i *Image) Annotations(ctx context.Context) (map[string]string, error)

Annotations returns the annotations of an image

func (*Image) Comment added in v0.4.4

func (i *Image) Comment(ctx context.Context, manifestType string) (string, error)

Comment returns the Comment for an image depending on its ManifestType

func (*Image) Containers added in v0.4.4

func (i *Image) Containers() ([]string, error)

Containers a list of container IDs associated with the image

func (*Image) Created added in v0.3.3

func (i *Image) Created() time.Time

Created returns the time the image was created

func (*Image) Dangling added in v0.3.4

func (i *Image) Dangling() bool

Dangling returns a bool if the image is "dangling"

func (*Image) Decompose added in v0.3.3

func (i *Image) Decompose() error

Decompose an Image

func (*Image) Digest added in v0.3.3

func (i *Image) Digest() digest.Digest

Digest returns the image's digest

func (*Image) DriverData added in v0.3.4

func (i *Image) DriverData() (*inspect.Data, error)

DriverData gets the driver data from the store on a layer

func (*Image) GetChildren added in v0.7.2

func (i *Image) GetChildren() ([]string, error)

GetChildren returns a list of the imageIDs that depend on the image

func (*Image) GetConfigBlob added in v1.2.0

func (i *Image) GetConfigBlob(ctx context.Context) (*manifest.Schema2Image, error)

GetConfigBlob returns a schema2image. If the image is not a schema2, then it will return an error

func (*Image) GetHealthCheck added in v1.2.0

func (i *Image) GetHealthCheck(ctx context.Context) (*manifest.Schema2HealthConfig, error)

GetHealthCheck returns a HealthConfig for an image. This function only works with schema2 images.

func (*Image) GetLabel added in v0.10.1

func (i *Image) GetLabel(ctx context.Context, label string) (string, error)

GetLabel Returns a case-insensitive match of a given label

func (*Image) GetParent added in v0.7.2

func (i *Image) GetParent() (*Image, error)

GetParent returns the image ID of the parent. Return nil if a parent is not found.

func (*Image) History added in v0.3.4

func (i *Image) History(ctx context.Context) ([]*History, error)

History gets the history of an image and information about its layers

func (*Image) ID

func (i *Image) ID() string

ID returns the image ID as a string

func (*Image) InputIsID added in v0.3.4

func (i *Image) InputIsID() bool

InputIsID returns a bool if the user input for an image is the image's partial or full id

func (*Image) Inspect added in v0.3.4

func (i *Image) Inspect(ctx context.Context) (*inspect.ImageData, error)

Inspect returns an image's inspect data

func (*Image) IsParent added in v0.7.2

func (i *Image) IsParent() (bool, error)

IsParent goes through the layers in the store and checks if i.TopLayer is the parent of any other layer in store. Double check that image with that layer exists as well.

func (*Image) Labels added in v0.3.4

func (i *Image) Labels(ctx context.Context) (map[string]string, error)

Labels returns the image's labels

func (*Image) Layer added in v0.3.4

func (i *Image) Layer() (*storage.Layer, error)

Layer returns the image's top layer

func (*Image) Manifest added in v0.3.4

func (i *Image) Manifest(ctx context.Context) ([]byte, string, error)

Manifest returns the image's manifest as a byte array and manifest type as a string. The manifest type is MediaTypeImageManifest from ociv1.

func (*Image) MatchRepoTag added in v0.3.4

func (i *Image) MatchRepoTag(input string) (string, error)

MatchRepoTag takes a string and tries to match it against an image's repotags

func (*Image) MatchesID added in v0.3.3

func (i *Image) MatchesID(id string) bool

MatchesID returns a bool based on if the input id matches the image's id

func (*Image) Names added in v0.3.3

func (i *Image) Names() []string

Names returns a string array of names associated with the image

func (*Image) PushImageToHeuristicDestination added in v0.8.1

func (i *Image) PushImageToHeuristicDestination(ctx context.Context, destination, manifestMIMEType, authFile, signaturePolicyPath string, writer io.Writer, forceCompress bool, signingOptions SigningOptions, dockerRegistryOptions *DockerRegistryOptions, additionalDockerArchiveTags []reference.NamedTagged) error

PushImageToHeuristicDestination pushes the given image to "destination", which is heuristically parsed. Use PushImageToReference if the destination is known precisely.

func (*Image) PushImageToReference added in v0.8.1

func (i *Image) PushImageToReference(ctx context.Context, dest types.ImageReference, manifestMIMEType, authFile, signaturePolicyPath string, writer io.Writer, forceCompress bool, signingOptions SigningOptions, dockerRegistryOptions *DockerRegistryOptions, additionalDockerArchiveTags []reference.NamedTagged) error

PushImageToReference pushes the given image to a location described by the given path

func (*Image) Remove

func (i *Image) Remove(force bool) error

Remove an image; container removal for the image must be done outside the context of images TODO: the force param does nothing as of now. Need to move container handling logic here eventually.

func (*Image) RepoDigests added in v0.4.4

func (i *Image) RepoDigests() ([]string, error)

RepoDigests returns a string array of repodigests associated with the image

func (*Image) Save added in v1.1.0

func (i *Image) Save(ctx context.Context, source, format, output string, moreTags []string, quiet, compress bool) error

Save writes a container image to the filesystem

func (*Image) Size added in v0.3.3

func (i *Image) Size(ctx context.Context) (*uint64, error)

Size returns the size of the image

func (*Image) TagImage added in v0.3.3

func (i *Image) TagImage(tag string) error

TagImage adds a tag to the given image

func (*Image) ToImageRef added in v0.3.4

func (i *Image) ToImageRef(ctx context.Context) (types.Image, error)

ToImageRef returns an image reference type from an image TODO: Hopefully we can remove this exported function for mheon

func (*Image) TopLayer added in v0.3.3

func (i *Image) TopLayer() string

TopLayer returns the top layer id as a string

func (*Image) UntagImage added in v0.3.4

func (i *Image) UntagImage(tag string) error

UntagImage removes a tag from the given image

type LayerInfo added in v1.2.0

type LayerInfo struct {
	// Layer ID
	ID string
	// Parent ID of current layer.
	ParentID string
	// ChildID of current layer.
	// there can be multiple children in case of fork
	ChildID []string
	// RepoTag will have image repo names, if layer is top layer of image
	RepoTags []string
	// Size stores Uncompressed size of layer.
	Size int64
}

LayerInfo keeps information of single layer

type Runtime added in v0.3.3

type Runtime struct {
	SignaturePolicyPath string
	EventsLogFilePath   string
	// contains filtered or unexported fields
}

Runtime contains the store

func NewImageRuntimeFromOptions added in v0.3.4

func NewImageRuntimeFromOptions(options storage.StoreOptions) (*Runtime, error)

NewImageRuntimeFromOptions creates an Image Runtime including the store given store options

func NewImageRuntimeFromStore added in v0.3.4

func NewImageRuntimeFromStore(store storage.Store) *Runtime

NewImageRuntimeFromStore creates an ImageRuntime based on a provided store

func (*Runtime) GetImages added in v0.3.3

func (ir *Runtime) GetImages() ([]*Image, error)

GetImages retrieves all images present in storage

func (*Runtime) GetPruneImages added in v0.12.1

func (ir *Runtime) GetPruneImages(all bool) ([]*Image, error)

GetPruneImages returns a slice of images that have no names/unused

func (*Runtime) Import added in v0.3.4

func (ir *Runtime) Import(ctx context.Context, path, reference string, writer io.Writer, signingOptions SigningOptions, imageConfig ociv1.Image) (*Image, error)

Import imports and image into the store and returns an image

func (*Runtime) LoadFromArchiveReference added in v0.8.1

func (ir *Runtime) LoadFromArchiveReference(ctx context.Context, srcRef types.ImageReference, signaturePolicyPath string, writer io.Writer) ([]*Image, error)

LoadFromArchiveReference creates a new image object for images pulled from a tar archive and the like (podman load) This function is needed because it is possible for a tar archive to have multiple tags for one image

func (*Runtime) New added in v0.3.3

func (ir *Runtime) New(ctx context.Context, name, signaturePolicyPath, authfile string, writer io.Writer, dockeroptions *DockerRegistryOptions, signingoptions SigningOptions, forcePull bool, label *string) (*Image, error)

New creates a new image object where the image could be local or remote

func (*Runtime) NewFromLocal added in v0.3.3

func (ir *Runtime) NewFromLocal(name string) (*Image, error)

NewFromLocal creates a new image object that is intended to only deal with local images already in the store (or its aliases)

func (*Runtime) PruneImages added in v1.0.1

func (ir *Runtime) PruneImages(all bool) ([]string, error)

PruneImages prunes dangling and optionally all unused images from the local image store

func (*Runtime) Shutdown added in v0.3.3

func (ir *Runtime) Shutdown(force bool) error

Shutdown closes down the storage and require a bool arg as to whether it should do so forcibly.

type SearchFilter added in v1.1.0

type SearchFilter struct {
	// Stars describes the minimal amount of starts of an image.
	Stars int
	// IsAutomated decides if only images from automated builds are displayed.
	IsAutomated types.OptionalBool
	// IsOfficial decides if only official images are displayed.
	IsOfficial types.OptionalBool
}

SearchFilter allows filtering the results of SearchImages.

func ParseSearchFilter added in v1.1.0

func ParseSearchFilter(filter []string) (*SearchFilter, error)

ParseSearchFilter turns the filter into a SearchFilter that can be used for searching images.

type SearchOptions added in v1.1.0

type SearchOptions struct {
	// Filter allows to filter the results.
	Filter SearchFilter
	// Limit limits the number of queries per index (default: 25). Must be
	// greater than 0 to overwrite the default value.
	Limit int
	// NoTrunc avoids the output to be truncated.
	NoTrunc bool
	// Authfile is the path to the authentication file.
	Authfile string
	// InsecureSkipTLSVerify allows to skip TLS verification.
	InsecureSkipTLSVerify types.OptionalBool
}

SearchOptions are used to control the behaviour of SearchImages.

type SearchResult added in v1.1.0

type SearchResult struct {
	// Index is the image index (e.g., "docker.io" or "quay.io")
	Index string
	// Name is the canoncical name of the image (e.g., "docker.io/library/alpine").
	Name string
	// Description of the image.
	Description string
	// Stars is the number of stars of the image.
	Stars int
	// Official indicates if it's an official image.
	Official string
	// Automated indicates if the image was created by an automated build.
	Automated string
}

SearchResult is holding image-search related data.

func SearchImages added in v1.1.0

func SearchImages(term string, options SearchOptions) ([]SearchResult, error)

SearchImages searches images based on term and the specified SearchOptions in all registries.

func (*SearchResult) HeaderMap added in v1.1.0

func (s *SearchResult) HeaderMap() map[string]string

HeaderMap returns the headers of a SearchResult.

type SigningOptions added in v0.3.3

type SigningOptions struct {
	// RemoveSignatures directs us to remove any signatures which are already present.
	RemoveSignatures bool
	// SignBy is a key identifier of some kind, indicating that a signature should be generated using the specified private key and stored with the image.
	SignBy string
}

SigningOptions encapsulates settings that control whether or not we strip or add signatures to images when writing them.

Jump to

Keyboard shortcuts

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