container

package
v0.97.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 26 Imported by: 10

Documentation

Overview

package container implements a client for a container registry. It can be used to upload container images.

Index

Constants

View Source
const (
	DefaultUserAgent  = "osbuild-composer/1.0"
	DefaultPolicyPath = "/etc/containers/policy.json"
)

Variables

This section is empty.

Functions

func ApplyDefaultDomainPath

func ApplyDefaultDomainPath(target, defaultDomain, defaultPath string) (string, bool)

ApplyDefaultPath checks if the target includes a domain and if it doesn't adds the default ones to the returned string. If also returns a bool indicating whether the defaults were applied

func GetDefaultAuthFile

func GetDefaultAuthFile() string

GetDefaultAuthFile returns the authentication file to use for the current environment.

This is basically a re-implementation of `getPathToAuthWithOS` from containers/image/pkg/docker/config/config.go[1], but we ensure that the returned path is either accessible. This is needed since any other error than os.ErrNotExist will lead to an overall failure and thus prevent any operation even with public resources.

[1] https://github.com/containers/image/blob/55ea76c7db702ed1af60924a0b57c8da533d9e5a/pkg/docker/config/config.go#L506

Types

type Client

type Client struct {
	Target reference.Named // the target object to interact with

	ReportWriter io.Writer // used for writing status reports, defaults to os.Stdout

	PrecomputeDigests bool // precompute digest in order to avoid uploads
	MaxRetries        int  // how often to retry http requests

	UserAgent string // user agent string to use for requests, defaults to DefaultUserAgent
	// contains filtered or unexported fields
}

A Client to interact with the given Target object at a container registry, like e.g. uploading an image to. All mentioned defaults are only set when using the NewClient constructor.

func NewClient

func NewClient(target string) (*Client, error)

NewClient constructs a new Client for target with default options. It will add the "latest" tag if target does not contain it.

func (*Client) GetAuthFilePath

func (cl *Client) GetAuthFilePath() string

GetAuthFilePath gets the location of the `containers-auth.json(5)` file.

func (*Client) GetManifest

func (cl *Client) GetManifest(ctx context.Context, instanceDigest digest.Digest, local bool) (r RawManifest, err error)

GetManifest fetches the raw manifest data from the server. If digest is not empty it will override any given tag for the Client's Target.

func (*Client) GetTLSVerify

func (cl *Client) GetTLSVerify() *bool

GetSkipTLSVerify returns current TLS verification state.

func (*Client) Resolve

func (cl *Client) Resolve(ctx context.Context, name string, local bool) (Spec, error)

Resolve the Client's Target to the manifest digest and the corresponding image id which is the digest of the configuration object. It uses the architecture and variant specified via SetArchitectureChoice or the corresponding defaults for the host.

func (*Client) SetArchitectureChoice

func (cl *Client) SetArchitectureChoice(arch string)

func (*Client) SetAuthFilePath

func (cl *Client) SetAuthFilePath(path string)

SetAuthFilePath sets the location of the `containers-auth.json(5)` file.

func (*Client) SetCredentials

func (cl *Client) SetCredentials(username, password string)

SetCredentials will set username and password for Client

func (*Client) SetDockerCertPath

func (cl *Client) SetDockerCertPath(path string)

func (*Client) SetTLSVerify

func (cl *Client) SetTLSVerify(verify *bool)

SetSkipTLSVerify controls if TLS verification happens when making requests. If nil is passed it falls back to the default.

func (*Client) SetVariantChoice

func (cl *Client) SetVariantChoice(variant string)

func (*Client) SkipTLSVerify

func (cl *Client) SkipTLSVerify()

SkipTLSVerify is a convenience helper that internally calls SetTLSVerify with false

func (*Client) UploadImage

func (cl *Client) UploadImage(ctx context.Context, from, tag string) (digest.Digest, error)

UploadImage takes an container image located at from and uploads it to the Target of Client. If tag is set, i.e. not the empty string, it will replace any previously set tag or digest of the target. Returns the digest of the manifest that was written to the server.

type RawManifest

type RawManifest struct {
	Data     []byte
	MimeType string
	Arch     arch.Arch
}

A RawManifest contains the raw manifest Data and its MimeType

func (RawManifest) Digest

func (m RawManifest) Digest() (digest.Digest, error)

Digest computes the digest from the raw manifest data

type Resolver

type Resolver struct {
	Arch         string
	AuthFilePath string
	// contains filtered or unexported fields
}

func NewResolver

func NewResolver(arch string) *Resolver

XXX: use arch.Arch here?

func (*Resolver) Add

func (r *Resolver) Add(spec SourceSpec)

func (*Resolver) Finish

func (r *Resolver) Finish() ([]Spec, error)

type SourceSpec

type SourceSpec struct {
	Source    string
	Name      string
	Digest    *string
	TLSVerify *bool
	Local     bool
}

type Spec

type Spec struct {
	Source       string // does not include the manifest digest
	Digest       string // digest of the manifest at the Source
	TLSVerify    *bool  // controls TLS verification
	ImageID      string // container image identifier
	LocalName    string // name to use inside the image
	ListDigest   string // digest of the list manifest at the Source (optional)
	LocalStorage bool

	Arch arch.Arch // the architecture of the image
}

A Spec is the specification of how to get a specific container from a Source and under what LocalName to store it in an image. The container is identified by at the Source via Digest and ImageID. The latter one should remain the same in the target image as well.

func NewSpec

func NewSpec(source reference.Named, digest, imageID digest.Digest, tlsVerify *bool, listDigest string, localName string, localStorage bool) Spec

NewSpec creates a new Spec from the essential information. It also converts is the transition point from container specific types (digest.Digest) to generic types (string).

Jump to

Keyboard shortcuts

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