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
88775e1f
Commit
88775e1f
authored
May 01, 2024
by
Michael Yang
Browse files
strip scheme from name
parent
8867e744
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
types/model/name.go
types/model/name.go
+7
-1
types/model/name_test.go
types/model/name_test.go
+20
-2
No files found.
types/model/name.go
View file @
88775e1f
...
...
@@ -153,12 +153,18 @@ func ParseNameBare(s string) Name {
n
.
Model
=
s
return
n
}
s
,
n
.
Namespace
,
promised
=
cutPromised
(
s
,
"/"
)
if
!
promised
{
n
.
Namespace
=
s
return
n
}
n
.
Host
=
s
scheme
,
host
,
ok
:=
strings
.
Cut
(
s
,
"://"
)
if
!
ok
{
host
=
scheme
}
n
.
Host
=
host
return
n
}
...
...
types/model/name_test.go
View file @
88775e1f
...
...
@@ -17,6 +17,15 @@ func TestParseNameParts(t *testing.T) {
want
Name
wantValidDigest
bool
}{
{
in
:
"scheme://host:port/namespace/model:tag"
,
want
:
Name
{
Host
:
"host:port"
,
Namespace
:
"namespace"
,
Model
:
"model"
,
Tag
:
"tag"
,
},
},
{
in
:
"host/namespace/model:tag"
,
want
:
Name
{
...
...
@@ -26,6 +35,15 @@ func TestParseNameParts(t *testing.T) {
Tag
:
"tag"
,
},
},
{
in
:
"host:port/namespace/model:tag"
,
want
:
Name
{
Host
:
"host:port"
,
Namespace
:
"namespace"
,
Model
:
"model"
,
Tag
:
"tag"
,
},
},
{
in
:
"host/namespace/model"
,
want
:
Name
{
...
...
@@ -35,9 +53,9 @@ func TestParseNameParts(t *testing.T) {
},
},
{
in
:
"host:
12345
/namespace/model"
,
in
:
"host:
port
/namespace/model"
,
want
:
Name
{
Host
:
"host:
12345
"
,
Host
:
"host:
port
"
,
Namespace
:
"namespace"
,
Model
:
"model"
,
},
...
...
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