Documentation ¶
Index ¶
- Constants
- Variables
- type AdditionalMetadata
- func WithArchitecture(architecture, variant string) AdditionalMetadata
- func WithConfig(config []byte) AdditionalMetadata
- func WithManifest(manifest []byte) AdditionalMetadata
- func WithManifestDigest(digest string) AdditionalMetadata
- func WithOS(o string) AdditionalMetadata
- func WithPlatform(platform string) AdditionalMetadata
- func WithRepoDigests(digests ...string) AdditionalMetadata
- func WithTags(tags ...string) AdditionalMetadata
- type FileCatalog
- type FileCatalogReader
- type Image
- func (i *Image) Cleanup() error
- func (i *Image) FileContentsByRef(ref file.Reference) (io.ReadCloser, error)
- func (i *Image) FileContentsFromSquash(path file.Path) (io.ReadCloser, error)
- func (i *Image) FilesByMIMETypeFromSquash(mimeTypes ...string) ([]file.Reference, error)
- func (i *Image) IDs() []string
- func (i *Image) OpenPathFromSquash(path file.Path) (io.ReadCloser, error)
- func (i *Image) OpenReference(ref file.Reference) (io.ReadCloser, error)
- func (i *Image) Read() error
- func (i *Image) ResolveLinkByImageSquash(ref file.Reference, options ...filetree.LinkResolutionOption) (*file.Resolution, error)
- func (i *Image) ResolveLinkByLayerSquash(ref file.Reference, layer int, options ...filetree.LinkResolutionOption) (*file.Resolution, error)
- func (i *Image) SquashedTree() filetree.Reader
- type LayerMetadata
- type Metadata
- type Platform
- type Provider
- type RegistryCredentials
- type RegistryOptions
- type Source
Constants ¶
const SchemeSeparator = ":"
Variables ¶
var AllSources = []Source{ DockerTarballSource, DockerDaemonSource, OciDirectorySource, OciTarballSource, OciRegistrySource, PodmanDaemonSource, SingularitySource, }
Functions ¶
This section is empty.
Types ¶
type AdditionalMetadata ¶
func WithArchitecture ¶
func WithArchitecture(architecture, variant string) AdditionalMetadata
func WithConfig ¶
func WithConfig(config []byte) AdditionalMetadata
func WithManifest ¶
func WithManifest(manifest []byte) AdditionalMetadata
func WithManifestDigest ¶
func WithManifestDigest(digest string) AdditionalMetadata
func WithOS ¶
func WithOS(o string) AdditionalMetadata
func WithPlatform ¶
func WithPlatform(platform string) AdditionalMetadata
func WithRepoDigests ¶
func WithRepoDigests(digests ...string) AdditionalMetadata
func WithTags ¶
func WithTags(tags ...string) AdditionalMetadata
type FileCatalog ¶
FileCatalog represents all file metadata and source tracing for all files contained within the image layer blobs (i.e. everything except for the image index/manifest/metadata files).
func NewFileCatalog ¶
func NewFileCatalog() *FileCatalog
NewFileCatalog returns an empty FileCatalog.
func (*FileCatalog) Add ¶
Add creates a new FileCatalogEntry for the given file reference and metadata, cataloged by the ID of the file reference (overwriting any existing entries without warning).
func (*FileCatalog) Layer ¶
func (c *FileCatalog) Layer(f file.Reference) *Layer
func (*FileCatalog) Open ¶
func (c *FileCatalog) Open(f file.Reference) (io.ReadCloser, error)
Open returns a io.ReadCloser for the given file reference. The underlying io.ReadCloser will not attempt to allocate resources until the first read is performed.
type FileCatalogReader ¶
type FileCatalogReader interface { Layer(file.Reference) *Layer Open(file.Reference) (io.ReadCloser, error) filetree.IndexReader }
type Image ¶
type Image struct { // Metadata contains select image attributes Metadata Metadata // Layers contains the rich layer objects in build order Layers []*Layer // FileCatalog contains all file metadata for all files in all layers FileCatalog FileCatalogReader SquashedSearchContext filetree.Searcher // contains filtered or unexported fields }
Image represents a container image.
func New ¶
func New(image v1.Image, tmpDirGen *file.TempDirGenerator, contentCacheDir string, additionalMetadata ...AdditionalMetadata) *Image
New provides a new (unread) image object.
func NewImage ¶
func NewImage(image v1.Image, tmpDirGen *file.TempDirGenerator, contentCacheDir string, additionalMetadata ...AdditionalMetadata) *Image
NewImage provides a new (unread) image object. Deprecated: use New() instead
func (*Image) Cleanup ¶
Cleanup removes all temporary files created from parsing the image. Future calls to image will not function correctly after this call.
func (*Image) FileContentsByRef ¶
FileContentsByRef fetches file contents for a single file reference, regardless of the source layer. If the path does not exist an error is returned. Deprecated: please use OpenReference() instead.
func (*Image) FileContentsFromSquash ¶
FileContentsFromSquash fetches file contents for a single path, relative to the image squash tree. If the path does not exist an error is returned. Deprecated: use OpenPathFromSquash() instead.
func (*Image) FilesByMIMETypeFromSquash ¶
FilesByMIMETypeFromSquash returns file references for files that match at least one of the given MIME types. Deprecated: please use SquashedSearchContext().SearchByMIMEType() instead.
func (*Image) OpenPathFromSquash ¶
OpenPathFromSquash fetches file contents for a single path, relative to the image squash tree. If the path does not exist an error is returned.
func (*Image) OpenReference ¶
OpenReference fetches file contents for a single file reference, regardless of the source layer. If the path does not exist an error is returned.
func (*Image) Read ¶
Read parses information from the underlying image tar into this struct. This includes image metadata, layer metadata, layer file trees, and layer squash trees (which implies the image squash tree).
func (*Image) ResolveLinkByImageSquash ¶
func (i *Image) ResolveLinkByImageSquash(ref file.Reference, options ...filetree.LinkResolutionOption) (*file.Resolution, error)
ResolveLinkByImageSquash resolves a symlink or hardlink for the given file reference relative to the result from the image squash. If the given file reference is not a link type, or is a unresolvable (dead) link, then the given file reference is returned.
func (*Image) ResolveLinkByLayerSquash ¶
func (i *Image) ResolveLinkByLayerSquash(ref file.Reference, layer int, options ...filetree.LinkResolutionOption) (*file.Resolution, error)
ResolveLinkByLayerSquash resolves a symlink or hardlink for the given file reference relative to the result from the layer squash of the given layer index argument. If the given file reference is not a link type, or is a unresolvable (dead) link, then the given file reference is returned.
func (*Image) SquashedTree ¶
SquashedTree returns the pre-computed image squash file tree.
type LayerMetadata ¶
type LayerMetadata struct { Index uint // Digest is the sha256 digest of the layer contents (the docker "diff id") Digest string MediaType v1Types.MediaType // Size in bytes of the layer content size Size int64 }
Metadata represents container layer metadata.
type Metadata ¶
type Metadata struct { // ID is the sha256 of this image config json (not manifest) ID string // Size in bytes of all the image layer content sizes (does not include config / manifest / index metadata sizes) Size int64 Config v1.ConfigFile MediaType v1Types.MediaType // --- below fields are optional metadata Tags []name.Tag RawManifest []byte ManifestDigest string RawConfig []byte RepoDigests []string Architecture string Variant string OS string }
Metadata represents container image metadata.
type Platform ¶
type Platform struct { // Architecture field specifies the CPU architecture, for example // `amd64` or `ppc64`. Architecture string `json:"architecture"` // OS specifies the operating system, for example `linux` or `windows`. OS string `json:"os"` // Variant is an optional field specifying a variant of the CPU, for // example `v7` to specify ARMv7 when architecture is `arm`. Variant string `json:"variant,omitempty"` }
Platform is a subset of the supported fields from specs "github.com/opencontainers/image-spec/specs-go/v1.Platform"
func NewPlatform ¶
type Provider ¶
type Provider interface {
Provide(context.Context, ...AdditionalMetadata) (*Image, error)
}
Provider is an abstraction for any object that provides image objects (e.g. the docker daemon API, a tar file of an OCI image, podman varlink API, etc.).
type RegistryCredentials ¶
type RegistryCredentials struct { Authority string Username string Password string Token string // Explicitly pass in the Authenticator, allowing for things like // k8schain to be passed through explicitly. Authenticator authn.Authenticator }
RegistryCredentials contains any information necessary to authenticate against an OCI-distribution-compliant registry (either with basic auth, or bearer token, or ggcr authenticator implementation). Note: only valid for the OCI registry provider.
type RegistryOptions ¶
type RegistryOptions struct { InsecureSkipTLSVerify bool InsecureUseHTTP bool Credentials []RegistryCredentials Keychain authn.Keychain Platform string }
RegistryOptions for the OCI registry provider. If no specific Credential is found in the RegistryCredentials, will check for Keychain, and barring that will use Default Keychain.
func (RegistryOptions) Authenticator ¶
func (r RegistryOptions) Authenticator(registry string) authn.Authenticator
Authenticator returns an object capable of authenticating against the given registry. If no credentials match the given registry, or there is partial information configured, then nil is returned.
type Source ¶
type Source uint8
Source is a concrete a selection of valid concrete image providers.
func DetectSource ¶
DetectSource takes a user string and determines the image source (e.g. the docker daemon, a tar file, etc.) returning the string subset representing the image (or nothing if it is unknown). note: parsing is done relative to the given string and environmental evidence (i.e. the given filesystem) to determine the actual source.
func DetectSourceFromPath ¶
DetectSourceFromPath will distinguish between a oci-layout dir, oci-archive, and a docker-archive for a given filesystem.
func DetermineDefaultImagePullSource ¶
DetermineDefaultImagePullSource takes an image reference string as input, and determines a Source to use to pull the image. If the input doesn't specify an image reference (i.e. an image that can be _pulled_), UnknownSource is returned. Otherwise, if the Docker daemon is available, DockerDaemonSource is returned, and if not, OciRegistrySource is returned.
func ParseSourceScheme ¶
ParseSourceScheme attempts to resolve a concrete image source selection from a scheme in a user string.