Documentation ¶
Overview ¶
Package ecr provides implementations of the containerd Resolver, Fetcher, and Pusher interfaces that can use the Amazon ECR API to push and pull images.
References ¶
containerd specifies images with a reference, or a "ref". References are different from Docker image names, as references encode an identifier, but not a retrieval mechanism. refs start with a DNS-style namespace that can be used to select separate Resolvers to use.
The canonical ref format used by this package is ecr.aws/ followed by the ARN of the repository and a label and/or a digest. Valid references are of the form "ecr.aws/arn:aws:ecr:<region>:<account>:repository/<name>:<tag>".
License ¶
This package is licensed under the Apache 2.0 license.
Index ¶
- Variables
- func NewResolver(options ...ResolverOption) (remotes.Resolver, error)
- type ECRSpec
- func (spec ECRSpec) ARN() string
- func (spec ECRSpec) Canonical() string
- func (spec ECRSpec) ImageID() *ecr.ImageIdentifier
- func (spec ECRSpec) Partition() string
- func (spec ECRSpec) Region() string
- func (spec ECRSpec) Registry() string
- func (spec ECRSpec) Spec() reference.Spec
- func (spec ECRSpec) TagDigest() (string, digest.Digest)
- type ResolverOption
- type ResolverOptions
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidManifest = errors.New("invalid manifest")
)
Functions ¶
func NewResolver ¶
func NewResolver(options ...ResolverOption) (remotes.Resolver, error)
NewResolver creates a new remotes.Resolver capable of interacting with Amazon ECR. NewResolver can be called with no arguments for default configuration, or can be customized by specifying ResolverOptions. By default, NewResolver will allocate a new AWS session.Session and an in-memory tracker for layer progress.
Example (Pull) ¶
package main import ( "context" "fmt" "github.com/awslabs/amazon-ecr-containerd-resolver/ecr" "github.com/containerd/containerd" "github.com/containerd/containerd/namespaces" ) func main() { client, _ := containerd.New("/run/containerd/containerd.sock") resolver, _ := ecr.NewResolver() img, _ := client.Pull( namespaces.NamespaceFromEnv(context.TODO()), "ecr.aws/arn:aws:ecr:us-west-2:123456789012:repository/myrepository:mytag", containerd.WithResolver(resolver), containerd.WithPullUnpack, containerd.WithSchema1Conversion) fmt.Println(img.Name()) }
Output:
Example (Push) ¶
package main import ( "context" "github.com/awslabs/amazon-ecr-containerd-resolver/ecr" "github.com/containerd/containerd" "github.com/containerd/containerd/namespaces" ) func main() { client, _ := containerd.New("/run/containerd/containerd.sock") ctx := namespaces.NamespaceFromEnv(context.TODO()) img, _ := client.ImageService().Get( ctx, "docker.io/library/busybox:latest") resolver, _ := ecr.NewResolver() _ = client.Push( ctx, "ecr.aws/arn:aws:ecr:us-west-2:123456789012:repository/myrepository:mytag", img.Target, containerd.WithResolver(resolver)) }
Output:
Types ¶
type ECRSpec ¶
type ECRSpec struct { // Repository name for this reference. Repository string // Object is the image reference's object descriptor. This may be a label or // a digest specifier. Object string // contains filtered or unexported fields }
ECRSpec represents a parsed reference.
Valid references are of the form "ecr.aws/arn:aws:ecr:<region>:<account>:repository/<name>:<tag>".
func ParseImageURI ¶
ParseImageURI takes an ECR image URI and then constructs and returns an ECRSpec struct
func (ECRSpec) ImageID ¶
func (spec ECRSpec) ImageID() *ecr.ImageIdentifier
ImageID returns an ecr.ImageIdentifier suitable for using in calls to ECR
type ResolverOption ¶
type ResolverOption func(*ResolverOptions) error
ResolverOption represents a functional option for configuring the ECR Resolver
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) ResolverOption
WithHTTPClient is a ResolverOption to use a specific http.Client.
func WithLayerDownloadParallelism ¶
func WithLayerDownloadParallelism(parallelism int) ResolverOption
WithLayerDownloadParallelism is a ResolverOption to configure whether layer parts should be downloaded in parallel. Layer parallelism is backed by the htcat library and can increase the speed at which layers are downloaded at the cost of increased memory consumption. It is recommended to test your workload to determine whether the tradeoff is worthwhile.
func WithSession ¶
func WithSession(session *session.Session) ResolverOption
WithSession is a ResolverOption to use a specific AWS session.Session
func WithTracker ¶
func WithTracker(tracker docker.StatusTracker) ResolverOption
WithTracker is a ResolverOption to use a specific docker.Tracker
type ResolverOptions ¶
type ResolverOptions struct { // Session is used for configuring the ECR client. If not specified, a // generic session is used. Session *session.Session // Tracker is used to track uploads to ECR. If not specified, an in-memory // tracker is used instead. Tracker docker.StatusTracker // LayerDownloadParallelism configures whether layer parts should be // downloaded in parallel. If not specified, parallelism is currently // disabled. LayerDownloadParallelism int // HTTPClient configures the HTTP client the resolver internally use for fetching. // If not specified, http.DefaultClient is used. HTTPClient *http.Client }
ResolverOptions represents available options for configuring the ECR Resolver