Files
.gitea
cli
cmd
pkg
app
autocomplete
catalogue
client
client.go
context.go
registry.go
secret.go
volumes.go
volumes_test.go
config
container
context
dns
envfile
formatter
git
integration
jsontable
limit
lint
log
recipe
secret
server
service
ssh
test
upstream
web
scripts
tests
.dockerignore
.drone.yml
.envrc.sample
.gitignore
.goreleaser.yml
AUTHORS.md
Dockerfile
LICENSE
Makefile
README.md
go.mod
go.sum
renovate.json
abra/pkg/client/registry.go

29 lines
642 B
Go

package client
import (
"context"
"fmt"
"github.com/containers/image/docker"
"github.com/containers/image/types"
"github.com/distribution/reference"
)
// GetRegistryTags retrieves all tags of an image from a container registry.
func GetRegistryTags(img reference.Named) ([]string, error) {
var tags []string
ref, err := docker.ParseReference(fmt.Sprintf("//%s", img))
if err != nil {
return tags, fmt.Errorf("failed to parse image %s, saw: %s", img, err.Error())
}
ctx := context.Background()
tags, err = docker.GetRepositoryTags(ctx, &types.SystemContext{}, ref)
if err != nil {
return tags, err
}
return tags, nil
}