mirror of
https://github.com/ollama/ollama.git
synced 2025-05-11 18:36:41 +02:00
validate model tags on copy (#1323)
This commit is contained in:
parent
39be7fdb98
commit
96122b7271
2 changed files with 21 additions and 2 deletions
|
@ -67,6 +67,20 @@ func ParseModelPath(name string) ModelPath {
|
|||
return mp
|
||||
}
|
||||
|
||||
var errModelPathInvalid = errors.New("invalid model path")
|
||||
|
||||
func (mp ModelPath) Validate() error {
|
||||
if mp.Repository == "" {
|
||||
return fmt.Errorf("%w: model repository name is required", errModelPathInvalid)
|
||||
}
|
||||
|
||||
if strings.Contains(mp.Tag, ":") {
|
||||
return fmt.Errorf("%w: ':' (colon) is not allowed in tag names", errModelPathInvalid)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mp ModelPath) GetNamespaceRepository() string {
|
||||
return fmt.Sprintf("%s/%s", mp.Namespace, mp.Repository)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue