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
  • Loading branch information
ecrupper committed Oct 6, 2023
1 parent b2d343d commit c14e8e4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
2 changes: 2 additions & 0 deletions executor/linux/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/go-vela/types/constants"
"github.com/go-vela/types/pipeline"
"github.com/go-vela/worker/internal/step"
"github.com/sirupsen/logrus"
)

// CreateStage prepares the stage for execution.
Expand Down Expand Up @@ -141,6 +142,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
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
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 c14e8e4

Please sign in to comment.