Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
c631a9c7
Unverified
Commit
c631a9c7
authored
Apr 27, 2024
by
Blake Mizerany
Committed by
GitHub
Apr 27, 2024
Browse files
types/model: relax name length constraint from 2 to 1 (#3984)
parent
8fd9e568
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
types/model/name.go
types/model/name.go
+4
-4
types/model/name_test.go
types/model/name_test.go
+11
-7
No files found.
types/model/name.go
View file @
c631a9c7
...
@@ -113,16 +113,16 @@ type Name struct {
...
@@ -113,16 +113,16 @@ type Name struct {
// length: [1, 350]
// length: [1, 350]
// namespace:
// namespace:
// pattern: alphanum { alphanum | "-" | "_" }*
// pattern: alphanum { alphanum | "-" | "_" }*
// length: [
2
, 80]
// length: [
1
, 80]
// model:
// model:
// pattern: alphanum { alphanum | "-" | "_" | "." }*
// pattern: alphanum { alphanum | "-" | "_" | "." }*
// length: [
2
, 80]
// length: [
1
, 80]
// tag:
// tag:
// pattern: alphanum { alphanum | "-" | "_" | "." }*
// pattern: alphanum { alphanum | "-" | "_" | "." }*
// length: [1, 80]
// length: [1, 80]
// digest:
// digest:
// pattern: alphanum { alphanum | "-" | ":" }*
// pattern: alphanum { alphanum | "-" | ":" }*
// length: [
2
, 80]
// length: [
1
, 80]
//
//
// Most users should use [ParseName] instead, unless need to support
// Most users should use [ParseName] instead, unless need to support
// different defaults than DefaultName.
// different defaults than DefaultName.
...
@@ -254,7 +254,7 @@ func isValidLen(kind partKind, s string) bool {
...
@@ -254,7 +254,7 @@ func isValidLen(kind partKind, s string) bool {
case
kindTag
:
case
kindTag
:
return
len
(
s
)
>=
1
&&
len
(
s
)
<=
80
return
len
(
s
)
>=
1
&&
len
(
s
)
<=
80
default
:
default
:
return
len
(
s
)
>=
2
&&
len
(
s
)
<=
80
return
len
(
s
)
>=
1
&&
len
(
s
)
<=
80
}
}
}
}
...
...
types/model/name_test.go
View file @
c631a9c7
...
@@ -101,6 +101,11 @@ func TestParseNameParts(t *testing.T) {
...
@@ -101,6 +101,11 @@ func TestParseNameParts(t *testing.T) {
}
}
var
testCases
=
map
[
string
]
bool
{
// name -> valid
var
testCases
=
map
[
string
]
bool
{
// name -> valid
""
:
false
,
// minimal
"h/n/m:t@d"
:
true
,
"host/namespace/model:tag"
:
true
,
"host/namespace/model:tag"
:
true
,
"host/namespace/model"
:
false
,
"host/namespace/model"
:
false
,
"namespace/model"
:
false
,
"namespace/model"
:
false
,
...
@@ -116,11 +121,12 @@ var testCases = map[string]bool{ // name -> valid
...
@@ -116,11 +121,12 @@ var testCases = map[string]bool{ // name -> valid
"h/nn/mm:t@sha256-1000000000000000000000000000000000000000000000000000000000000000"
:
true
,
// bare minimum part sizes
"h/nn/mm:t@sha256-1000000000000000000000000000000000000000000000000000000000000000"
:
true
,
// bare minimum part sizes
"h/nn/mm:t@sha256:1000000000000000000000000000000000000000000000000000000000000000"
:
true
,
// bare minimum part sizes
"h/nn/mm:t@sha256:1000000000000000000000000000000000000000000000000000000000000000"
:
true
,
// bare minimum part sizes
"m"
:
false
,
// model too short
// unqualified
"n/mm:"
:
false
,
// namespace too short
"m"
:
false
,
"h/n/mm:t"
:
false
,
// namespace too short
"n/m:"
:
false
,
"@t"
:
false
,
// digest too short
"h/n/m"
:
false
,
"mm@d"
:
false
,
// digest too short
"@t"
:
false
,
"m@d"
:
false
,
// invalids
// invalids
"^"
:
false
,
"^"
:
false
,
...
@@ -140,8 +146,6 @@ var testCases = map[string]bool{ // name -> valid
...
@@ -140,8 +146,6 @@ var testCases = map[string]bool{ // name -> valid
"hh/nn/mm:-tt@dd"
:
false
,
"hh/nn/mm:-tt@dd"
:
false
,
"hh/nn/mm:tt@-dd"
:
false
,
"hh/nn/mm:tt@-dd"
:
false
,
""
:
false
,
// hosts
// hosts
"host:https/namespace/model:tag"
:
true
,
"host:https/namespace/model:tag"
:
true
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment