image:tag@digest format support

This commit is contained in:
CrazyMax
2023-09-16 12:04:20 +02:00
parent 78879b3fae
commit 061c976fe9
14 changed files with 399 additions and 28 deletions

View File

@@ -12,7 +12,7 @@ const (
sha256digest = "@sha256:" + sha256digestHex
)
func TestParseReference(t *testing.T) {
func TestImageReference(t *testing.T) {
testCases := []struct {
input string
expected string
@@ -23,28 +23,27 @@ func TestParseReference(t *testing.T) {
expected: "docker.io/library/busybox:latest",
},
{
input: "//busybox:notlatest",
input: "docker.io/library/busybox",
expected: "docker.io/library/busybox:latest",
},
{
input: "docker.io/library/busybox:latest",
expected: "docker.io/library/busybox:latest",
},
{
input: "busybox:notlatest",
expected: "docker.io/library/busybox:notlatest",
},
{
input: "//busybox" + sha256digest,
input: "busybox" + sha256digest,
expected: "docker.io/library/busybox" + sha256digest,
},
{
input: "//busybox",
expected: "docker.io/library/busybox:latest",
input: "busybox:latest" + sha256digest,
expected: "docker.io/library/busybox" + sha256digest,
},
{
input: "//busybox:latest" + sha256digest,
expected: "",
wantErr: true,
},
{
input: "//docker.io/library/busybox:latest",
expected: "docker.io/library/busybox:latest",
},
{
input: "//UPPERCASEISINVALID",
input: "UPPERCASEISINVALID",
expected: "",
wantErr: true,
},
@@ -53,7 +52,7 @@ func TestParseReference(t *testing.T) {
for _, tt := range testCases {
tt := tt
t.Run(tt.input, func(t *testing.T) {
ref, err := ParseReference(tt.input)
ref, err := ImageReference(tt.input)
if tt.wantErr {
require.Error(t, err)
return