image

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 34 Imported by: 61

Documentation

Index

Constants

View Source
const SingularitySquashFSLayer = "application/vnd.sylabs.sif.layer.v1.squashfs"

Variables

This section is empty.

Functions

func ParseReference added in v0.0.2

func ParseReference(imageStr string) (imageRef string, originalRef string, err error)

Types

type AdditionalMetadata

type AdditionalMetadata func(*Image) error

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

type FileCatalog struct {
	*sync.RWMutex
	filetree.Index
	// contains filtered or unexported fields
}

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

func (c *FileCatalog) Add(f file.Reference, m file.Metadata, l *Layer, opener file.Opener)

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

func (i *Image) Cleanup() error

Cleanup removes all temporary files created from parsing the image. Future calls to image will not function correctly after this call.

func (*Image) FileContentsByRef

func (i *Image) FileContentsByRef(ref file.Reference) (io.ReadCloser, error)

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

func (i *Image) FileContentsFromSquash(path file.Path) (io.ReadCloser, error)

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

func (i *Image) FilesByMIMETypeFromSquash(mimeTypes ...string) ([]file.Reference, error)

FilesByMIMETypeFromSquash returns file references for files that match at least one of the given MIME types. Deprecated: please use SquashedSearchContext().SearchByMIMEType() instead.

func (*Image) IDs

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

func (*Image) OpenPathFromSquash

func (i *Image) OpenPathFromSquash(path file.Path) (io.ReadCloser, error)

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

func (i *Image) OpenReference(ref file.Reference) (io.ReadCloser, error)

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

func (i *Image) Read() error

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

func (i *Image) SquashedTree() filetree.Reader

SquashedTree returns the pre-computed image squash file tree.

type Layer

type Layer struct {

	// Metadata contains select layer attributes
	Metadata LayerMetadata
	// Tree is a filetree that represents the structure of the layer tar contents ("diff tree")
	Tree filetree.Reader
	// SquashedTree is a filetree that represents the combination of this layers diff tree and all diff trees
	// in lower layers relative to this one.
	SquashedTree filetree.Reader

	SquashedSearchContext filetree.Searcher
	SearchContext         filetree.Searcher
	// contains filtered or unexported fields
}

Layer represents a single layer within a container image.

func NewLayer

func NewLayer(layer v1.Layer) *Layer

NewLayer provides a new, unread layer object.

func (*Layer) FileContents

func (l *Layer) FileContents(path file.Path) (io.ReadCloser, error)

FileContents reads the file contents for the given path from the underlying layer blob, relative to the layers "diff tree". An error is returned if there is no file at the given path and layer or the read operation cannot continue. Deprecated: use OpenPath() instead.

func (*Layer) FileContentsFromSquash

func (l *Layer) FileContentsFromSquash(path file.Path) (io.ReadCloser, error)

FileContentsFromSquash reads the file contents for the given path from the underlying layer blob, relative to the layers squashed file tree. An error is returned if there is no file at the given path and layer or the read operation cannot continue. Deprecated: use OpenPathFromSquash() instead.

func (*Layer) FilesByMIMEType

func (l *Layer) FilesByMIMEType(mimeTypes ...string) ([]file.Reference, error)

FilesByMIMEType returns file references for files that match at least one of the given MIME types relative to each layer tree. Deprecated: use SearchContext().SearchByMIMEType() instead.

func (*Layer) FilesByMIMETypeFromSquash

func (l *Layer) FilesByMIMETypeFromSquash(mimeTypes ...string) ([]file.Reference, error)

FilesByMIMETypeFromSquash returns file references for files that match at least one of the given MIME types relative to the squashed file tree representation. Deprecated: use SquashedSearchContext().SearchByMIMEType() instead.

func (*Layer) OpenPath

func (l *Layer) OpenPath(path file.Path) (io.ReadCloser, error)

OpenPath reads the file contents for the given path from the underlying layer blob, relative to the layers "diff tree". An error is returned if there is no file at the given path and layer or the read operation cannot continue.

func (*Layer) OpenPathFromSquash

func (l *Layer) OpenPathFromSquash(path file.Path) (io.ReadCloser, error)

OpenPathFromSquash reads the file contents for the given path from the underlying layer blob, relative to the layers squashed file tree. An error is returned if there is no file at the given path and layer or the read operation cannot continue.

func (*Layer) Read

func (l *Layer) Read(catalog *FileCatalog, idx int, uncompressedLayersCacheDir string) error

Read parses information from the underlying layer tar into this struct. This includes layer metadata, the layer file tree, and the layer squash 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
}

LayerMetadata 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

func NewPlatform(specifier string) (*Platform, error)

func (*Platform) String

func (p *Platform) String() string

type Provider

type Provider interface {
	Name() string
	Provide(context.Context) (*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

	// MTLS configuration
	ClientCert string
	ClientKey  string
}

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
	CAFileOrDir           string
}

RegistryOptions for the OCI registry provider and containerd 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 selects the credentials used to authenticate with a registry. Returns an authn.Authenticator object capable for handling high level credentials for the registry.

func (RegistryOptions) TLSConfig

func (r RegistryOptions) TLSConfig(registry string) (*tls.Config, error)

TLSConfig selects the tls.Config object for handling TLS authentication with a registry.

type Source

type Source = string
const (
	UnknownSource          Source = ""
	ContainerdDaemonSource Source = "containerd"
	DockerTarballSource    Source = "docker-archive"
	DockerDaemonSource     Source = "docker"
	OciDirectorySource     Source = "oci-dir"
	OciTarballSource       Source = "oci-archive"
	OciRegistrySource      Source = "oci-registry"
	PodmanDaemonSource     Source = "podman"
	SingularitySource      Source = "singularity"
)

Directories

Path Synopsis
oci

Jump to

Keyboard shortcuts

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