|
|
|
@ -23,6 +23,8 @@ import (
|
|
|
|
|
|
|
|
|
|
"github.com/google/go-containerregistry/pkg/crane"
|
|
|
|
|
"github.com/google/go-containerregistry/pkg/name"
|
|
|
|
|
gcrv1 "github.com/google/go-containerregistry/pkg/v1"
|
|
|
|
|
"github.com/google/go-containerregistry/pkg/v1/mutate"
|
|
|
|
|
"github.com/google/go-containerregistry/pkg/v1/random"
|
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
|
)
|
|
|
|
@ -32,11 +34,18 @@ func Test_List(t *testing.T) {
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
repo := "test-list" + randStringRunes(5)
|
|
|
|
|
tags := []string{"v0.0.1", "v0.0.2", "v0.0.3"}
|
|
|
|
|
source := "github.com/fluxcd/fluxv2"
|
|
|
|
|
rev := "rev"
|
|
|
|
|
m := Metadata{
|
|
|
|
|
Source: source,
|
|
|
|
|
Revision: rev,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tag := range tags {
|
|
|
|
|
dst := fmt.Sprintf("%s/%s:%s", dockerReg, repo, tag)
|
|
|
|
|
img, err := random.Image(1024, 1)
|
|
|
|
|
g.Expect(err).ToNot(HaveOccurred())
|
|
|
|
|
img = mutate.Annotations(img, m.ToAnnotations()).(gcrv1.Image)
|
|
|
|
|
err = crane.Push(img, dst, craneOptions(ctx)...)
|
|
|
|
|
g.Expect(err).ToNot(HaveOccurred())
|
|
|
|
|
}
|
|
|
|
@ -49,5 +58,11 @@ func Test_List(t *testing.T) {
|
|
|
|
|
tag, err := name.NewTag(meta.URL)
|
|
|
|
|
g.Expect(err).ToNot(HaveOccurred())
|
|
|
|
|
g.Expect(tag.TagStr()).Should(BeElementOf(tags))
|
|
|
|
|
|
|
|
|
|
g.Expect(meta.ToAnnotations()).To(Equal(m.ToAnnotations()))
|
|
|
|
|
|
|
|
|
|
digest, err := crane.Digest(meta.URL, craneOptions(ctx)...)
|
|
|
|
|
g.Expect(err).ToNot(HaveOccurred())
|
|
|
|
|
g.Expect(meta.Digest).To(Equal(digest))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|