Some checks failed
continuous-integration/drone/push Build is failing
See #483
31 lines
701 B
Go
31 lines
701 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/containers/image/docker"
|
|
"github.com/containers/image/types"
|
|
"github.com/distribution/reference"
|
|
"github.com/leonelquinteros/gotext"
|
|
)
|
|
|
|
// 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, errors.New(gotext.Get("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
|
|
}
|