From bd446a72cc25eec227317b81b6192b4894a87ffa Mon Sep 17 00:00:00 2001 From: Blake Mizerany Date: Sat, 6 Apr 2024 22:26:00 -0700 Subject: [PATCH] x/model: introduce Digest --- x/model/name.go | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/x/model/name.go b/x/model/name.go index 1a4fa4d42..6b9e8e9fb 100644 --- a/x/model/name.go +++ b/x/model/name.go @@ -28,19 +28,6 @@ const MaxNamePartLen = 128 type NamePart int -var kindNames = map[NamePart]string{ - Invalid: "Invalid", - Host: "Host", - Namespace: "Namespace", - Model: "Name", - Tag: "Tag", - Build: "Build", -} - -func (k NamePart) String() string { - return cmp.Or(kindNames[k], "Unknown") -} - // Levels of concreteness const ( Host NamePart = iota @@ -48,12 +35,31 @@ const ( Model Tag Build + Digest - NumParts = Build + 1 + // Invalid is a special part that is used to indicate that a part is + // invalid. It is not a valid part of a Name. + // + // It should be kept as the last part in the list. + Invalid - Invalid = NamePart(-1) + NumParts = Invalid - 1 ) +var kindNames = map[NamePart]string{ + Invalid: "Invalid", + Host: "Host", + Namespace: "Namespace", + Model: "Name", + Tag: "Tag", + Build: "Build", + Digest: "Digest", +} + +func (k NamePart) String() string { + return cmp.Or(kindNames[k], "Unknown") +} + // Name is an opaque reference to a model. It holds the parts of a model // with the case preserved, but is not directly comparable with other Names // since model names can be represented with different caseing depending on