// RegistryListTags returns the list of images instances obtained from all tags existing in the registry func RegistryListTags(image *imagename.ImageName, auth *docker.AuthConfigurations) (images []*imagename.ImageName, err error) { var ( name = image.Name registry = image.Registry ) regAuth, err := GetAuthForRegistry(auth, image) if err != nil { return nil, fmt.Errorf("Failed to get auth token for registry: %s, make sure you are properly logged in using `docker login` or have AWS credentials set in case of using ECR", image) } // XXX: AWS ECR Registry API v2 does not support listing tags // wo we just return a single image tag if it exists and no wildcards used if image.IsECR() { log.Debugf("ECR detected %s", registry) if !image.IsStrict() { return nil, fmt.Errorf("Amazon ECR does not support tags listing, therefore image wildcards are not supported, sorry: %s", image) } if exists, err := ecrImageExists(image, regAuth); err != nil { return nil, err } else if exists { log.Debugf("ECR image %s found in the registry", image) images = append(images, image) } return } if registry == "" { registry = "registry-1.docker.io" if !strings.Contains(name, "/") { name = "library/" + name } } var ( tg = tags{} url = fmt.Sprintf("https://%s/v2/%s/tags/list?page_size=9999&page=1", registry, name) ) log.Debugf("Listing image tags from the remote registry %s", url) if err := registryGet(url, regAuth, &tg); err != nil { return nil, err } log.Debugf("Got %d tags from the remote registry for image %s", len(tg.Tags), image) for _, t := range tg.Tags { candidate := imagename.New(image.NameWithRegistry(), t) if image.Contains(candidate) || image.Tag == candidate.Tag { images = append(images, candidate) } } return }