working commit
This commit is contained in:
+10
-4
@@ -15,6 +15,7 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/auxutar"
|
||||
|
||||
"github.com/google/go-containerregistry/pkg/authn"
|
||||
@@ -29,9 +30,14 @@ func (cli *Client) PushImage(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
|
||||
@@ -53,8 +59,8 @@ func (cli *Client) PushImage(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)
|
||||
@@ -67,7 +73,7 @@ func (cli *Client) PushImage(ctx context.Context, filepath, imagepath string, ti
|
||||
options = append(options, crane.WithTransport(defaultTransport))
|
||||
}
|
||||
|
||||
dstdir := makeTmpFileName(filepath)
|
||||
dstdir := auxtool.MakeTmpFilename(filepath)
|
||||
err = auxutar.Unarchive(filepath, dstdir)
|
||||
if err != nil {
|
||||
os.RemoveAll(dstdir)
|
||||
|
||||
Reference in New Issue
Block a user