|
|
@ -153,11 +153,7 @@ func GetManifest(mp ModelPath) (*ManifestV2, error) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func GetModel(name string) (*Model, error) { |
|
|
func GetModel(name string) (*Model, error) { |
|
|
mp, err := ParseModelPath(name, false) |
|
|
mp := ParseModelPath(name) |
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
manifest, err := GetManifest(mp) |
|
|
manifest, err := GetManifest(mp) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
@ -276,11 +272,7 @@ func CreateModel(ctx context.Context, name string, path string, fn func(resp api |
|
|
fn(api.ProgressResponse{Status: "looking for model"}) |
|
|
fn(api.ProgressResponse{Status: "looking for model"}) |
|
|
embed.model = c.Args |
|
|
embed.model = c.Args |
|
|
|
|
|
|
|
|
mp, err := ParseModelPath(c.Args, false) |
|
|
mp := ParseModelPath(c.Args) |
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mf, err := GetManifest(mp) |
|
|
mf, err := GetManifest(mp) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
modelFile, err := filenameWithPath(path, c.Args) |
|
|
modelFile, err := filenameWithPath(path, c.Args) |
|
|
@ -682,11 +674,7 @@ func SaveLayers(layers []*LayerReader, fn func(resp api.ProgressResponse), force |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func CreateManifest(name string, cfg *LayerReader, layers []*Layer) error { |
|
|
func CreateManifest(name string, cfg *LayerReader, layers []*Layer) error { |
|
|
mp, err := ParseModelPath(name, false) |
|
|
mp := ParseModelPath(name) |
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
manifest := ManifestV2{ |
|
|
manifest := ManifestV2{ |
|
|
SchemaVersion: 2, |
|
|
SchemaVersion: 2, |
|
|
MediaType: "application/vnd.docker.distribution.manifest.v2+json", |
|
|
MediaType: "application/vnd.docker.distribution.manifest.v2+json", |
|
|
@ -817,21 +805,13 @@ func CreateLayer(f io.ReadSeeker) (*LayerReader, error) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func CopyModel(src, dest string) error { |
|
|
func CopyModel(src, dest string) error { |
|
|
srcModelPath, err := ParseModelPath(src, false) |
|
|
srcModelPath := ParseModelPath(src) |
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
srcPath, err := srcModelPath.GetManifestPath(false) |
|
|
srcPath, err := srcModelPath.GetManifestPath(false) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
destModelPath, err := ParseModelPath(dest, false) |
|
|
destModelPath := ParseModelPath(dest) |
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
destPath, err := destModelPath.GetManifestPath(true) |
|
|
destPath, err := destModelPath.GetManifestPath(true) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
@ -854,11 +834,7 @@ func CopyModel(src, dest string) error { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func DeleteModel(name string) error { |
|
|
func DeleteModel(name string) error { |
|
|
mp, err := ParseModelPath(name, false) |
|
|
mp := ParseModelPath(name) |
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
manifest, err := GetManifest(mp) |
|
|
manifest, err := GetManifest(mp) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
@ -884,10 +860,7 @@ func DeleteModel(name string) error { |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
tag := path[:slashIndex] + ":" + path[slashIndex+1:] |
|
|
tag := path[:slashIndex] + ":" + path[slashIndex+1:] |
|
|
fmp, err := ParseModelPath(tag, false) |
|
|
fmp := ParseModelPath(tag) |
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// skip the manifest we're trying to delete
|
|
|
// skip the manifest we're trying to delete
|
|
|
if mp.GetFullTagname() == fmp.GetFullTagname() { |
|
|
if mp.GetFullTagname() == fmp.GetFullTagname() { |
|
|
@ -940,13 +913,13 @@ func DeleteModel(name string) error { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func PushModel(ctx context.Context, name string, regOpts *RegistryOptions, fn func(api.ProgressResponse)) error { |
|
|
func PushModel(ctx context.Context, name string, regOpts *RegistryOptions, fn func(api.ProgressResponse)) error { |
|
|
mp, err := ParseModelPath(name, regOpts.Insecure) |
|
|
mp := ParseModelPath(name) |
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn(api.ProgressResponse{Status: "retrieving manifest"}) |
|
|
fn(api.ProgressResponse{Status: "retrieving manifest"}) |
|
|
|
|
|
|
|
|
|
|
|
if mp.ProtocolScheme == "http" && !regOpts.Insecure { |
|
|
|
|
|
return fmt.Errorf("insecure protocol http") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
manifest, err := GetManifest(mp) |
|
|
manifest, err := GetManifest(mp) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fn(api.ProgressResponse{Status: "couldn't retrieve manifest"}) |
|
|
fn(api.ProgressResponse{Status: "couldn't retrieve manifest"}) |
|
|
@ -1026,9 +999,10 @@ func PushModel(ctx context.Context, name string, regOpts *RegistryOptions, fn fu |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func PullModel(ctx context.Context, name string, regOpts *RegistryOptions, fn func(api.ProgressResponse)) error { |
|
|
func PullModel(ctx context.Context, name string, regOpts *RegistryOptions, fn func(api.ProgressResponse)) error { |
|
|
mp, err := ParseModelPath(name, regOpts.Insecure) |
|
|
mp := ParseModelPath(name) |
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
if mp.ProtocolScheme == "http" && !regOpts.Insecure { |
|
|
|
|
|
return fmt.Errorf("insecure protocol http") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
fn(api.ProgressResponse{Status: "pulling manifest"}) |
|
|
fn(api.ProgressResponse{Status: "pulling manifest"}) |
|
|
|