From 8867e744ff3c5a59467f316f0f23c272fe66700a Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Wed, 1 May 2024 12:14:53 -0700 Subject: [PATCH] types/model: fix name for hostport --- types/model/name.go | 6 +++++- types/model/name_test.go | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/types/model/name.go b/types/model/name.go index a0a44703..fd4fbfc4 100644 --- a/types/model/name.go +++ b/types/model/name.go @@ -143,7 +143,11 @@ func ParseNameBare(s string) Name { n.RawDigest = MissingPart } - s, n.Tag, _ = cutPromised(s, ":") + // "/" is an illegal tag character, so we can use it to split the host + if strings.LastIndex(s, ":") > strings.LastIndex(s, "/") { + s, n.Tag, _ = cutPromised(s, ":") + } + s, n.Model, promised = cutPromised(s, "/") if !promised { n.Model = s diff --git a/types/model/name_test.go b/types/model/name_test.go index 75659f0d..2f99c5b1 100644 --- a/types/model/name_test.go +++ b/types/model/name_test.go @@ -34,6 +34,14 @@ func TestParseNameParts(t *testing.T) { Model: "model", }, }, + { + in: "host:12345/namespace/model", + want: Name{ + Host: "host:12345", + Namespace: "namespace", + Model: "model", + }, + }, { in: "namespace/model", want: Name{