Skip to content

Commit

Permalink
#35 consider vagrant images is the default
Browse files Browse the repository at this point in the history
return list of images in case of empty image cache
  • Loading branch information
mhewedy committed Dec 9, 2020
1 parent 21aa9c0 commit 0bdc10d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions command/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ var imagesCmd = &cobra.Command{
Long: `List remote and cached images
Images are cached after the first time it is downloaded.
You can find images from Vagrant at: https://app.vagrantup.com/search
example images:
* ubuntu/trusty64
* hashicorp/precise64
* generic/centos8
* generic/alpine38
`,
Example: `
Use the image in creating a VM:
Expand Down
8 changes: 7 additions & 1 deletion hypervisor/virtualbox/box.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@ func getBoxInfo(vm string) (*base.Box, error) {
if len(cpuCount) == 0 {
cpuCount = "1"
}

diskLocation := ""
if len(vb.Machine.MediaRegistry.HardDisks.HardDisk) > 0 {
diskLocation = vb.Machine.MediaRegistry.HardDisks.HardDisk[0].Location
}

return &base.Box{
CPU: cpuCount,
Mem: vb.Machine.Hardware.Memory.RAMSize,
DiskSize: getDiskSizeInGB(vm, vb.Machine.MediaRegistry.HardDisks.HardDisk[0].Location),
DiskSize: getDiskSizeInGB(vm, diskLocation),
MACAddr: vb.Machine.Hardware.Network.Adapter.MACAddress,
}, nil
}
Expand Down
10 changes: 10 additions & 0 deletions images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ func Display() (string, error) {
return "", err
}

if len(list) == 0 {
return `You can find images from Vagrant at: https://app.vagrantup.com/search
example images:
* ubuntu/trusty64
* hashicorp/precise64
* generic/centos8
* generic/alpine38
`, nil
}

result := header

for i := range list {
Expand Down

0 comments on commit 0bdc10d

Please sign in to comment.