working commit
This commit is contained in:
+10
-4
@@ -14,6 +14,7 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/auxutar"
|
||||
|
||||
"github.com/google/go-containerregistry/pkg/authn"
|
||||
@@ -26,10 +27,15 @@ func (cli *Client) PullImage(ctx context.Context, filepath, imagepath string, ti
|
||||
var err error
|
||||
ctx, _ = context.WithTimeout(ctx, timeout)
|
||||
|
||||
imagepath, username, password, err := repackReference(imagepath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
options := make([]crane.Option, 0)
|
||||
options = append(options, crane.WithContext(ctx))
|
||||
|
||||
if cli.username != "" && cli.password != "" {
|
||||
if username != "" && password != "" {
|
||||
ref, err := name.ParseReference(imagepath)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -48,8 +54,8 @@ func (cli *Client) PullImage(ctx context.Context, filepath, imagepath string, ti
|
||||
return err
|
||||
}
|
||||
basicAuth := &authn.Basic{
|
||||
Username: cli.username,
|
||||
Password: cli.password,
|
||||
Username: username,
|
||||
Password: password,
|
||||
}
|
||||
authTransport, err := transport.NewWithContext(ctx, reg, basicAuth, defaultTransport, scopes)
|
||||
if err != nil {
|
||||
@@ -65,7 +71,7 @@ func (cli *Client) PullImage(ctx context.Context, filepath, imagepath string, ti
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dstdir := makeTmpFileName(filepath)
|
||||
dstdir := auxtool.MakeTmpFilename(filepath)
|
||||
err = os.MkdirAll(dstdir, 0750)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user