server: allow mixed-case model names on push, pull, cp, and create (#7676)

This change allows for mixed-case model names to be pushed, pulled,
copied, and created, which was previously disallowed because the Ollama
registry was backed by a Docker registry that enforced a naming
convention that disallowed mixed-case names, which is no longer the
case.

This does not break existing, intended, behaviors.

Also, make TestCase test a story of creating, updating, pulling, and
copying a model with case variations, ensuring the model's manifest is
updated correctly, and not duplicated across different files with
different case variations.
This commit is contained in:
Blake Mizerany
2024-11-19 15:05:57 -08:00
committed by GitHub
parent e66c29261a
commit 4b8a2e341a
4 changed files with 169 additions and 84 deletions

View File

@@ -298,6 +298,13 @@ func (n Name) LogValue() slog.Value {
return slog.StringValue(n.String())
}
func (n Name) EqualFold(o Name) bool {
return strings.EqualFold(n.Host, o.Host) &&
strings.EqualFold(n.Namespace, o.Namespace) &&
strings.EqualFold(n.Model, o.Model) &&
strings.EqualFold(n.Tag, o.Tag)
}
func isValidLen(kind partKind, s string) bool {
switch kind {
case kindHost: