Include project when looking up target

This commit is contained in:
Chris Roberts 2022-09-23 16:56:21 -07:00
parent 1d991cb253
commit 5445c2195e
2 changed files with 12 additions and 2 deletions

View File

@ -609,6 +609,13 @@ func WithProject(p *Project) TargetOption {
}
}
func WithTargetProjectRef(p *vagrant_plugin_sdk.Ref_Project) TargetOption {
return func(t *Target) (err error) {
t.target.Project = p
return
}
}
// Set a vagrantfile instance on target
func WithTargetVagrantfile(v *Vagrantfile) TargetOption {
return func(t *Target) (err error) {

View File

@ -544,12 +544,15 @@ func (v *Vagrantfile) TargetConfig(
if err != nil {
// If we failed to get the subvm value, then we want to
// just load the target directly so it can generate
v.logger.Warn("failed to get subvm",
v.logger.Warn("failed to get target",
"name", name,
"error", err,
)
t, err := v.factory.NewTarget(WithTargetName(name))
t, err := v.factory.NewTarget(
WithTargetName(name),
WithTargetProjectRef(v.targetSource),
)
if err != nil {
if status.Code(err) != codes.NotFound {
return nil, err