diff --git a/internal/core/project.go b/internal/core/project.go index 83ea06420..721f8c6cd 100644 --- a/internal/core/project.go +++ b/internal/core/project.go @@ -120,7 +120,7 @@ func (p *Project) JobInfo() *component.JobInfo { return p.jobInfo } -func (p *Project) Target(nameOrId string) (*Target, error) { +func (p *Project) Target(nameOrId string) (core.Target, error) { if t, ok := p.targets[nameOrId]; ok { return t, nil } diff --git a/internal/core/target.go b/internal/core/target.go index 007c5d691..59cc6580c 100644 --- a/internal/core/target.go +++ b/internal/core/target.go @@ -232,8 +232,10 @@ type TargetOption func(*Target) error func WithTargetName(name string) TargetOption { return func(t *Target) (err error) { - if ex := t.project.Target(name); ex != nil { - t.target = ex.target + if ex, _ := t.project.Target(name); ex != nil { + if et, ok := ex.(*Target); ok { + t.target = et.target + } return } for _, target := range t.project.targets { @@ -262,8 +264,10 @@ func WithTargetRef(r *vagrant_plugin_sdk.Ref_Target) TargetOption { } var target *vagrant_server.Target - if ex := t.project.Target(r.Name); ex != nil { - t.target = ex.target + if ex, _ := t.project.Target(r.Name); ex != nil { + if et, ok := ex.(*Target); ok { + t.target = et.target + } return } result, err := t.Client().FindTarget(t.ctx,