Skip to content

Commit

Permalink
bugfix: use instance name as saved name (#2260)
Browse files Browse the repository at this point in the history
Signed-off-by: kakazhou <[email protected]>
  • Loading branch information
kakaZhou719 committed Jul 12, 2023
1 parent 9d48ae3 commit dabf8ce
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/imageengine/buildah/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,25 @@ func (engine *Engine) Save(opts *options.SaveOptions) error {
if err != nil {
return err
}

if len(images) == 0 {
return fmt.Errorf("no image matched with digest %s", instanceDigest)
}

instanceTar := filepath.Join(tempDir, images[0].ID+".tar")
err = engine.saveOneImage(images[0].ID, opts.Format, instanceTar, opts.Compress)
instance := images[0]
instanceTar := filepath.Join(tempDir, instance.ID+".tar")

// if instance has "Names", use the first one as saved name
instanceName := instance.ID
if len(instance.Names) > 0 {
instanceName = instance.Names[0]
}

err = engine.saveOneImage(instanceName, opts.Format, instanceTar, opts.Compress)
if err != nil {
return err
}

pathsToCompress = append(pathsToCompress, instanceTar)
}

Expand Down

0 comments on commit dabf8ce

Please sign in to comment.