working commit

This commit is contained in:
2026-02-11 12:53:31 +02:00
parent 517c518df2
commit 6fe7f7c15e
12 changed files with 392 additions and 186 deletions
+10 -4
View File
@@ -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)