Documentation
¶
Overview ¶
Package ecr lists Amazon ECR registries through the ECR API instead of the distribution API. One DescribeImages page covers up to 1,000 manifests with their tags, push time and last pull time, so a re-crawl costs one call per thousand images rather than one request per tag, and BatchGetImage fetches up to 100 manifests per call, so a first crawl fetches only image configs one by one. It also signs registry requests with the AWS credential chain, so no Docker credential helper is needed.
Index ¶
- func ParseHost(host string) (account, region string, ok bool)
- type API
- type Credentials
- type Registry
- func (r *Registry) Calls() int64
- func (r *Registry) Images(ctx context.Context, repo string) ([]crawl.Listed, error)
- func (r *Registry) Manifests(ctx context.Context, repo string, digests []string) (map[string][]byte, error)
- func (r *Registry) Repos(ctx context.Context) ([]string, error)
- func (r *Registry) Resolve(target authn.Resource) (authn.Authenticator, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type API ¶
type API interface {
ecr.DescribeRepositoriesAPIClient
ecr.DescribeImagesAPIClient
BatchGetImage(ctx context.Context, in *ecr.BatchGetImageInput, opts ...func(*ecr.Options)) (*ecr.BatchGetImageOutput, error)
GetAuthorizationToken(ctx context.Context, in *ecr.GetAuthorizationTokenInput, opts ...func(*ecr.Options)) (*ecr.GetAuthorizationTokenOutput, error)
}
API is the part of the ECR client strata uses.
type Credentials ¶ added in v0.3.1
type Credentials struct {
// Profile is a named profile from the shared AWS config, such as an
// SSO profile for the account that owns the registry.
Profile string
// RoleARN is a role to assume, starting from the profile or the
// default chain, such as a read-only role in the registry's account.
RoleARN string
// ExternalID is passed when assuming RoleARN, if the role requires it.
ExternalID string
}
Credentials pick the AWS identity for one registry, so registries in different accounts can each use their own. Empty fields use the default AWS credential chain.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is one ECR registry. It is a crawl.Lister and an authn.Keychain.
func New ¶
func New(ctx context.Context, host string, creds Credentials, opts ...func(*awsconfig.LoadOptions) error) (*Registry, error)
New returns a client for an ECR registry host. Credentials come from creds, falling back to the default AWS credential chain: environment, shared config and SSO profiles, web identity (EKS) and instance roles. The region comes from the host.
func NewWithAPI ¶
NewWithAPI returns a client that calls api, for tests and custom clients.
func (*Registry) Images ¶
Images lists every active manifest in a repository. Archived images cannot be pulled, so they are left out.
func (*Registry) Manifests ¶ added in v0.3.0
func (r *Registry) Manifests(ctx context.Context, repo string, digests []string) (map[string][]byte, error)
Manifests fetches the manifests of digests in one BatchGetImage call; ECR takes up to 100 per call. A manifest whose bytes do not hash to the digest asked for, or that ECR could not return, is left out, and the crawl fetches it the usual way.