From 889b31ab785c559e56a790b90583917ee742adbc Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Wed, 17 Apr 2024 15:13:05 -0700 Subject: [PATCH] types/model: support : in PartHost for host:port --- types/model/name.go | 5 +++++ types/model/name_test.go | 1 + 2 files changed, 6 insertions(+) diff --git a/types/model/name.go b/types/model/name.go index 7f037b61..9c56c49a 100644 --- a/types/model/name.go +++ b/types/model/name.go @@ -521,6 +521,8 @@ func parts(s string) iter_Seq2[PartKind, string] { return } state, j, partLen = PartModel, i, 0 + case PartHost: + // noop: support for host:port default: yield(PartExtraneous, s[i+1:j]) return @@ -678,6 +680,9 @@ func isValidByteFor(kind PartKind, c byte) bool { if kind == PartNamespace && c == '.' { return false } + if kind == PartHost && c == ':' { + return true + } if c == '.' || c == '-' { return true } diff --git a/types/model/name_test.go b/types/model/name_test.go index b45dadaf..8749477a 100644 --- a/types/model/name_test.go +++ b/types/model/name_test.go @@ -40,6 +40,7 @@ var testNames = map[string]fields{ "user/model": {namespace: "user", model: "model"}, "example.com/ns/mistral:7b+Q4_0": {host: "example.com", namespace: "ns", model: "mistral", tag: "7b", build: "Q4_0"}, "example.com/ns/mistral:7b+X": {host: "example.com", namespace: "ns", model: "mistral", tag: "7b", build: "X"}, + "localhost:5000/ns/mistral": {host: "localhost:5000", namespace: "ns", model: "mistral"}, // invalid digest "mistral:latest@invalid256-": {},