Documentation ¶
Overview ¶
package container implements a client for a container registry. It can be used to upload container images.
Index ¶
- Constants
- func ApplyDefaultDomainPath(target, defaultDomain, defaultPath string) (string, bool)
- func GetDefaultAuthFile() string
- type Client
- func (cl *Client) GetAuthFilePath() string
- func (cl *Client) GetManifest(ctx context.Context, digest digest.Digest, container *SourceSpec) (r RawManifest, err error)
- func (cl *Client) GetTLSVerify() *bool
- func (cl *Client) Resolve(ctx context.Context, name string, container *SourceSpec) (Spec, error)
- func (cl *Client) SetArchitectureChoice(arch string)
- func (cl *Client) SetAuthFilePath(path string)
- func (cl *Client) SetCredentials(username, password string)
- func (cl *Client) SetDockerCertPath(path string)
- func (cl *Client) SetTLSVerify(verify *bool)
- func (cl *Client) SetVariantChoice(variant string)
- func (cl *Client) SkipTLSVerify()
- func (cl *Client) UploadImage(ctx context.Context, from, tag string) (digest.Digest, error)
- type RawManifest
- type Resolver
- type SourceSpec
- type Spec
Constants ¶
const ( DefaultUserAgent = "osbuild-composer/1.0" DefaultPolicyPath = "/etc/containers/policy.json" )
Variables ¶
This section is empty.
Functions ¶
func ApplyDefaultDomainPath ¶
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.
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 ¶
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 ¶
GetAuthFilePath gets the location of the `containers-auth.json(5)` file.
func (*Client) GetManifest ¶
func (cl *Client) GetManifest(ctx context.Context, digest digest.Digest, container *SourceSpec) (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 ¶
GetSkipTLSVerify returns current TLS verification state.
func (*Client) Resolve ¶
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 (*Client) SetAuthFilePath ¶
SetAuthFilePath sets the location of the `containers-auth.json(5)` file.
func (*Client) SetCredentials ¶
SetCredentials will set username and password for Client
func (*Client) SetDockerCertPath ¶
func (*Client) SetTLSVerify ¶
SetSkipTLSVerify controls if TLS verification happens when making requests. If nil is passed it falls back to the default.
func (*Client) SetVariantChoice ¶
func (*Client) SkipTLSVerify ¶
func (cl *Client) SkipTLSVerify()
SkipTLSVerify is a convenience helper that internally calls SetTLSVerify with false
func (*Client) UploadImage ¶
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 ¶
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 SourceSpec ¶
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) ContainersTransport *string // the type of transport used for the container StoragePath *string // location of the local containers-storage }
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, transport *string, storagePath *string) 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).