Only init targets when running a job scoped at the project or target

This commit is contained in:
sophia 2021-11-17 14:25:32 -06:00 committed by Paul Hinze
parent 59144f74d3
commit d49944a25d
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
4 changed files with 10 additions and 6 deletions

View File

@ -65,7 +65,6 @@ func (c *Client) Task(
ctx context.Context,
op *vagrant_server.Job_RunOp,
mod JobModifier,
) (*vagrant_server.Job_RunResult, error) {
if op == nil {
op = &vagrant_server.Job_RunOp{}

View File

@ -396,11 +396,6 @@ func (b *Basis) LoadProject(popts ...ProjectOption) (p *Project, err error) {
}
}
// Initialize any targets defined within the project
if err = p.InitTargets(); err != nil {
return
}
// If any targets are defined in the project, load them
if len(p.project.Targets) > 0 {
for _, tref := range p.project.Targets {

View File

@ -282,6 +282,11 @@ func (p *Project) Run(ctx context.Context, task *vagrant_server.Task) (err error
"project", p,
"task", task)
// Intialize targets
if err = p.InitTargets(); err != nil {
return err
}
cmd, err := p.basis.component(
ctx, component.CommandType, task.Component.Name)
if err != nil {

View File

@ -213,6 +213,11 @@ func (t *Target) Run(ctx context.Context, task *vagrant_server.Task) (err error)
"target", t,
"task", task)
// Intialize targets
if err = t.project.InitTargets(); err != nil {
return err
}
cmd, err := t.project.basis.component(
ctx, component.CommandType, task.Component.Name)