diff --git a/Vagrantfile b/Vagrantfile index b0316389d..2c0cf8b81 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -44,7 +44,7 @@ Vagrant.configure("2") do |config| config.vm.define "one" do |c| c.vm.hostname = "one" c.vm.usable_port_range = 8070..8090 - c.vm.box = "bento/ubuntu" + c.vm.box = "bento/ubuntu-16.04" c.vm.provision "shell", inline: "echo hello world" c.vm.provision "shell" do |s| s.inline = "echo goodbye" diff --git a/internal/core/basis.go b/internal/core/basis.go index 23107d78d..b74ec816c 100644 --- a/internal/core/basis.go +++ b/internal/core/basis.go @@ -207,6 +207,7 @@ func (b *Basis) Boxes() (bc *BoxCollection, err error) { b.boxCollection = &BoxCollection{ basis: b, directory: filepath.Join(b.dir.DataDir().String(), "boxes"), + logger: b.logger, } } return b.boxCollection, nil diff --git a/internal/core/project.go b/internal/core/project.go index 73ca2c525..2ae88933e 100644 --- a/internal/core/project.go +++ b/internal/core/project.go @@ -4,7 +4,6 @@ import ( "context" "errors" "os" - "path/filepath" "strings" "sync" @@ -440,21 +439,19 @@ func (p *Project) InitTargets() (err error) { // TODO: get provider info here too/generate full machine config? // We know that these are machines so, save the Machine record machineRecord := &vagrant_server.Target_Machine{} - // TODO: create a new box for now. This should be querying the box collection - // for a box that matches the provided provider and name - doxDir := filepath.Join(p.basis.dir.DataDir().String(), "boxes/hashicorp-VAGRANTSLASH-bionic64/1.0.282/virtualbox/") - b, erro := NewBox( - BoxWithBasis(p.basis), - BoxWithName(t.ConfigVm.Box), - // TODO: need to get this box info from the vagrantfile/provider - BoxWithProvider("virtualbox"), - BoxWithVersion("1.0.282"), - BoxWithDirectory(doxDir), - ) + boxes, _ := p.Boxes() + b, erro := boxes.Find(t.ConfigVm.Box, "") if erro != nil { return erro } - machineRecord.Box = b.ToProto() + if b == nil { + // Add the box + b, erro = addBox(t.ConfigVm.Box, "virtualbox", p.basis) + if erro != nil { + return nil + } + } + machineRecord.Box = b.(*Box).ToProto() machineRecordAny, erro := anypb.New(machineRecord) if err != nil { p.logger.Debug("Error generating machine record for target",