Skip to content

Commit

Permalink
fix(executor/local): do not override env with machine details for loc…
Browse files Browse the repository at this point in the history
…al exec (#522)

* fix(executor/local): do not override env with machine details for local exec

* change log from linux to local - mistake

* init commit

* undo funky commit issue

---------

Co-authored-by: David May <49894298+wass3rw3rk@users.noreply.github.com>
  • Loading branch information
ecrupper and wass3rw3rk authored Oct 9, 2023
1 parent be492bd commit 26628ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
2 changes: 2 additions & 0 deletions executor/local/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/go-vela/types/constants"
"github.com/go-vela/worker/internal/build"
"github.com/go-vela/worker/internal/step"
"github.com/sirupsen/logrus"
)

// CreateBuild configures the build for execution.
Expand Down Expand Up @@ -274,6 +275,7 @@ func (c *client) ExecBuild(ctx context.Context) error {
//
// https://pkg.go.dev/github.com/go-vela/worker/internal/step#Skip
if step.Skip(_step, c.build, c.repo) {
logrus.Infof("Skipping step %s due to ruleset", _step.Name)
continue
}

Expand Down
2 changes: 2 additions & 0 deletions executor/local/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/go-vela/types/pipeline"
"github.com/go-vela/worker/internal/step"
"github.com/sirupsen/logrus"
)

// create a stage logging pattern.
Expand Down Expand Up @@ -90,6 +91,7 @@ func (c *client) ExecStage(ctx context.Context, s *pipeline.Stage, m *sync.Map)
//
// https://pkg.go.dev/github.com/go-vela/worker/internal/step#Skip
if step.Skip(_step, c.build, c.repo) {
logrus.Infof("Skipping step %s due to ruleset", _step.Name)
continue
}

Expand Down
25 changes: 5 additions & 20 deletions executor/local/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@ func (c *client) CreateStep(ctx context.Context, ctn *pipeline.Container) error
return err
}

// create a library step object to facilitate injecting environment as early as possible
// (PlanStep is too late to inject environment vars for the kubernetes runtime).
_step := library.StepFromBuildContainer(c.build, ctn)

// update the step container environment
//
// https://pkg.go.dev/github.com/go-vela/worker/internal/step#Environment
err = step.Environment(ctn, c.build, c.repo, _step, c.Version)
if err != nil {
return err
}

// substitute container configuration
//
// https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.Substitute
Expand All @@ -56,19 +44,16 @@ func (c *client) CreateStep(ctx context.Context, ctn *pipeline.Container) error

// PlanStep prepares the step for execution.
func (c *client) PlanStep(ctx context.Context, ctn *pipeline.Container) error {
// early exit if container is nil
if ctn.Empty() {
return fmt.Errorf("empty container provided")
}

// create the library step object
_step := library.StepFromBuildContainer(c.build, ctn)
_step.SetStatus(constants.StatusRunning)
_step.SetStarted(time.Now().UTC().Unix())

// update the step container environment
//
// https://pkg.go.dev/github.com/go-vela/worker/internal/step#Environment
err := step.Environment(ctn, c.build, c.repo, _step, c.Version)
if err != nil {
return err
}

// add the step to the client map
c.steps.Store(ctn.ID, _step)

Expand Down

0 comments on commit 26628ba

Please sign in to comment.