Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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