Get boxes from project
This commit is contained in:
parent
a841ca8552
commit
2dfb9b933e
@ -3,6 +3,7 @@ package core
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@ -33,15 +34,16 @@ import (
|
||||
// finished with the basis to properly clean
|
||||
// up any open resources.
|
||||
type Basis struct {
|
||||
basis *vagrant_server.Basis
|
||||
logger hclog.Logger
|
||||
config *config.Config
|
||||
plugins *plugin.Manager
|
||||
projects map[string]*Project
|
||||
mappers []*argmapper.Func
|
||||
dir *datadir.Basis
|
||||
ctx context.Context
|
||||
statebag core.StateBag
|
||||
basis *vagrant_server.Basis
|
||||
logger hclog.Logger
|
||||
config *config.Config
|
||||
plugins *plugin.Manager
|
||||
projects map[string]*Project
|
||||
mappers []*argmapper.Func
|
||||
dir *datadir.Basis
|
||||
ctx context.Context
|
||||
statebag core.StateBag
|
||||
boxCollection *BoxCollection
|
||||
|
||||
lookupCache map[string]interface{}
|
||||
|
||||
@ -200,6 +202,16 @@ func (b *Basis) State() *StateBag {
|
||||
return b.statebag.(*StateBag)
|
||||
}
|
||||
|
||||
func (b *Basis) Boxes() (bc *BoxCollection, err error) {
|
||||
if b.boxCollection == nil {
|
||||
b.boxCollection = &BoxCollection{
|
||||
basis: b,
|
||||
directory: filepath.Join(b.dir.DataDir().String(), "boxes"),
|
||||
}
|
||||
}
|
||||
return b.boxCollection, nil
|
||||
}
|
||||
|
||||
func (b *Basis) countParents(host core.Host) (int, error) {
|
||||
numParents := 0
|
||||
p, err := host.Parent()
|
||||
|
||||
@ -62,6 +62,11 @@ func (p *Project) UI() (terminal.UI, error) {
|
||||
return p.ui, nil
|
||||
}
|
||||
|
||||
// Boxes implements core.Project
|
||||
func (p *Project) Boxes() (bc core.BoxCollection, err error) {
|
||||
return p.basis.Boxes()
|
||||
}
|
||||
|
||||
// CWD implements core.Project
|
||||
func (p *Project) CWD() (path string, err error) {
|
||||
cwd, ok := os.LookupEnv("VAGRANT_CWD")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user