Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package src
import (
"testing"
"github.com/davecgh/go-spew/spew"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/stretchr/testify/require"
)
func TestList(t *testing.T) {
t.Run("jfrog", func(t *testing.T) {
tags, err := ListDockerImages("jfrog.joom.it/docker-images/backend-api-test-base-runtime")
require.NoError(t, err)
spew.Dump(tags)
})
t.Run("nexus", func(t *testing.T) {
tags, err := ListDockerImages("docker.joom.it/joom-search-elastic")
require.NoError(t, err)
spew.Dump(tags)
})
t.Run("dockerhub", func(t *testing.T) {
tags, err := ListDockerImages("nginx")
require.NoError(t, err)
spew.Dump(tags)
})
}
func ListDockerImages(imageName string) ([]string, error) {
image, err := name.ParseReference(imageName)
if err != nil {
return nil, err
}
return remote.List(image.Context())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.