Skip to content

Commit

Permalink
Switch from log.Printf(...) to ui.Message(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbast committed Oct 15, 2022
1 parent ed105c8 commit 109e017
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions builder/step_mount_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -99,7 +98,7 @@ func (s *StepMountImage) Cleanup(state multistep.StateBag) {
partitions := sortMountablePartitions(config.ImageConfig.ImagePartitions, true)
for _, partition := range partitions {
mountpoint := filepath.Join(s.MountPath, partition.Mountpoint)
log.Printf("unmounting %s", mountpoint)
ui.Message(fmt.Sprintf("unmounting %s", mountpoint)
_, err := exec.Command("umount", mountpoint).CombinedOutput()
if err != nil {
ui.Error(fmt.Sprintf("failed to unmount %s: %s", mountpoint, err.Error()))
Expand Down
7 changes: 3 additions & 4 deletions builder/step_setup_chroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -123,17 +122,17 @@ func (s *StepSetupChroot) Cleanup(state multistep.StateBag) {
mountpoint := filepath.Join(imageMountpoint, chrootMount.DestinationPath)

if canonical_path, err := filepath.EvalSymlinks(mountpoint); err == nil && canonical_path != mountpoint {
log.Printf("mountpoint %s is symlink to %s", mountpoint, canonical_path)
ui.Message(fmt.Sprintf("mountpoint %s is symlink to %s", mountpoint, canonical_path)
mountpoint = canonical_path
}

if _, ok := mounted[mountpoint]; !ok {
log.Printf("omiting umount of %s, not mounted", mountpoint)
ui.Message(fmt.Sprintf("omiting umount of %s, not mounted", mountpoint))
continue
}

for i := 0; i < 3; i++ {
log.Printf("unmounting %s", mountpoint)
ui.Message(fmt.Sprintf("unmounting %s", mountpoint))
out, err := exec.Command("umount", mountpoint).CombinedOutput()
if err != nil {
if i == 2 {
Expand Down

0 comments on commit 109e017

Please sign in to comment.