forked from toolshed/abra
		
	
		
			
				
	
	
		
			31 lines
		
	
	
		
			692 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			692 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package client
 | 
						|
 | 
						|
import (
 | 
						|
	"context"
 | 
						|
	"errors"
 | 
						|
	"fmt"
 | 
						|
 | 
						|
	"coopcloud.tech/abra/pkg/i18n"
 | 
						|
	"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, errors.New(i18n.G("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
 | 
						|
}
 |