[feat] add pull argument
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
func SaveImageTar(ctx context.Context, image, path, name string) error {
|
||||
func SaveImageTar(ctx context.Context, image, path, name string, doPull bool) error {
|
||||
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
|
||||
if err != nil {
|
||||
@@ -20,8 +20,10 @@ func SaveImageTar(ctx context.Context, image, path, name string) error {
|
||||
}
|
||||
defer cli.Close()
|
||||
|
||||
if err := pullImage(ctx, cli, image); err != nil {
|
||||
return fmt.Errorf("pull image %s failed: %v", image, err)
|
||||
if doPull {
|
||||
if err := pullImage(ctx, cli, image); err != nil {
|
||||
return fmt.Errorf("pull image %s failed: %v", image, err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := saveToTar(ctx, cli, image, path, name); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user