Skip to content

Commit 81fd32a

Browse files
committed
Reject pod:// with an error
1 parent cf513d0 commit 81fd32a

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

internal/snapshot/destination.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ func ParseDestination(dest string, now time.Time) (Destination, error) {
6161
} else {
6262
lower := strings.ToLower(dest)
6363
switch {
64+
case strings.HasPrefix(lower, "pod://"):
65+
podName := dest[len("pod://"):]
66+
return Destination{}, fmt.Errorf("'%s' is not a valid reference. Aliases use a single colon. Did you mean:\npod:%s", dest, podName)
6467
case strings.HasPrefix(lower, "pod:"):
65-
podName := strings.TrimPrefix(dest[len("pod:"):], "//")
68+
podName := dest[len("pod:"):]
6669
if !validPodName.MatchString(podName) {
6770
return Destination{}, fmt.Errorf("invalid pod name %q: use letters, digits, and hyphens only, starting with a letter or digit", podName)
6871
}

internal/snapshot/destination_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,9 @@ func TestParseDestination(t *testing.T) {
200200
wantPodName: "my-baseline",
201201
},
202202
{
203-
// pod:// is also accepted
204-
input: "pod://my-baseline",
205-
wantKind: snapshot.KindPod,
206-
wantPodName: "my-baseline",
203+
name: "pod:// rejected with did-you-mean hint",
204+
input: "pod://my-baseline",
205+
wantErr: "not a valid reference. Aliases use a single colon. Did you mean:\npod:my-baseline",
207206
},
208207
{
209208
input: "pod:abc123",

0 commit comments

Comments
 (0)