Skip to content
This repository has been archived by the owner on Aug 12, 2021. It is now read-only.

Commit

Permalink
refactor conversion functions into util
Browse files Browse the repository at this point in the history
  • Loading branch information
bluestealth committed Sep 2, 2020
1 parent c44418a commit a4cceb7
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
"path/filepath"
"syscall"

"github.com/docker/go-units"
"github.com/docker/machine/libmachine/drivers"
"github.com/docker/machine/libmachine/mcnflag"
"github.com/docker/machine/libmachine/mcnutils"
"github.com/docker/machine/libmachine/ssh"
"github.com/golang/glog"
"github.com/pkg/errors"
"k8s.io/minikube/pkg/util"
)

// This file is for common code shared among internal machine drivers
Expand All @@ -53,12 +53,6 @@ func (d *CommonDriver) SetConfigFromFlags(flags drivers.DriverOptions) error {
return nil
}

func diskSizeInMiB(diskSizeMB int) int64 {
result := int64(diskSizeMB)
result *= units.MiB
return result
}

func createRawDiskImage(sshKeyPath, diskPath string, diskSizeMb int) error {
tarBuf, err := mcnutils.MakeDiskImage(sshKeyPath)
if err != nil {
Expand All @@ -81,7 +75,7 @@ func createRawDiskImage(sshKeyPath, diskPath string, diskSizeMb int) error {
return errors.Wrapf(err, "closing file %s", diskPath)
}

if err := os.Truncate(diskPath, diskSizeInMiB(diskSizeMb)); err != nil {
if err := os.Truncate(diskPath, util.ConvertMBToBytes(diskSizeMb)); err != nil {
return errors.Wrap(err, "truncate")
}
return nil
Expand Down

0 comments on commit a4cceb7

Please sign in to comment.