Skip to content

Commit b7206f1

Browse files
authored
ssbc: Log final env when resolved (#622)
When determining workspaces, we determine the env, too. The values are preliminary though, as they might depend on what's set in the environment of src-cli or use template variables that aren't known at time of workspace determination. This logs the final set of env vars as used for the step.
1 parent b08abb5 commit b7206f1

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

internal/batches/executor/run_steps.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ func executeSingleStep(
265265
if err != nil {
266266
return bytes.Buffer{}, bytes.Buffer{}, errors.Wrap(err, "resolving step environment")
267267
}
268-
269268
// Render the step.Env variables as templates.
270269
env, err := template.RenderStepMap(stepEnv, stepContext)
271270
if err != nil {
@@ -275,7 +274,7 @@ func executeSingleStep(
275274
// ----------
276275
// EXECUTION
277276
// ----------
278-
opts.ui.StepStarted(i+1, runScript)
277+
opts.ui.StepStarted(i+1, runScript, env)
279278

280279
workspaceOpts, err := workspace.DockerRunOpts(ctx, workDir)
281280
if err != nil {

internal/batches/executor/ui.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type StepsExecutionUI interface {
3838
StepSkipped(int)
3939

4040
StepPreparing(int)
41-
StepStarted(int, string)
41+
StepStarted(stepIdx int, runScript string, env map[string]string)
4242

4343
StepOutputWriter(context.Context, *Task, int) StepOutputWriter
4444

@@ -51,14 +51,14 @@ type StepsExecutionUI interface {
5151
// NoopStepsExecUI is an implementation of StepsExecutionUI that does nothing.
5252
type NoopStepsExecUI struct{}
5353

54-
func (noop NoopStepsExecUI) ArchiveDownloadStarted() {}
55-
func (noop NoopStepsExecUI) ArchiveDownloadFinished() {}
56-
func (noop NoopStepsExecUI) WorkspaceInitializationStarted() {}
57-
func (noop NoopStepsExecUI) WorkspaceInitializationFinished() {}
58-
func (noop NoopStepsExecUI) SkippingStepsUpto(startStep int) {}
59-
func (noop NoopStepsExecUI) StepSkipped(step int) {}
60-
func (noop NoopStepsExecUI) StepPreparing(step int) {}
61-
func (noop NoopStepsExecUI) StepStarted(step int, runScript string) {}
54+
func (noop NoopStepsExecUI) ArchiveDownloadStarted() {}
55+
func (noop NoopStepsExecUI) ArchiveDownloadFinished() {}
56+
func (noop NoopStepsExecUI) WorkspaceInitializationStarted() {}
57+
func (noop NoopStepsExecUI) WorkspaceInitializationFinished() {}
58+
func (noop NoopStepsExecUI) SkippingStepsUpto(startStep int) {}
59+
func (noop NoopStepsExecUI) StepSkipped(step int) {}
60+
func (noop NoopStepsExecUI) StepPreparing(step int) {}
61+
func (noop NoopStepsExecUI) StepStarted(step int, runScript string, env map[string]string) {}
6262
func (noop NoopStepsExecUI) StepOutputWriter(ctx context.Context, task *Task, step int) StepOutputWriter {
6363
return NoopStepOutputWriter{}
6464
}

internal/batches/ui/json_lines.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ func (ui *stepsExecutionJSONLines) StepPreparing(step int) {
320320
logOperationProgress(batcheslib.LogEventOperationTaskPreparingStep, map[string]interface{}{"taskID": ui.linesTask.ID, "step": step})
321321
}
322322

323-
func (ui *stepsExecutionJSONLines) StepStarted(step int, runScript string) {
324-
logOperationStart(batcheslib.LogEventOperationTaskStep, map[string]interface{}{"taskID": ui.linesTask.ID, "step": step, "runScript": runScript})
323+
func (ui *stepsExecutionJSONLines) StepStarted(step int, runScript string, env map[string]string) {
324+
logOperationStart(batcheslib.LogEventOperationTaskStep, map[string]interface{}{"taskID": ui.linesTask.ID, "step": step, "runScript": runScript, "env": env})
325325
}
326326

327327
func (ui *stepsExecutionJSONLines) StepOutputWriter(ctx context.Context, task *executor.Task, step int) executor.StepOutputWriter {

internal/batches/ui/task_exec_tui.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"time"
1010

1111
"github.com/sourcegraph/go-diff/diff"
12+
1213
"github.com/sourcegraph/src-cli/internal/batches/executor"
1314

1415
batcheslib "github.com/sourcegraph/sourcegraph/lib/batches"
@@ -453,7 +454,7 @@ func (ui stepsExecTUI) StepSkipped(step int) {
453454
func (ui stepsExecTUI) StepPreparing(step int) {
454455
ui.updateStatusBar(fmt.Sprintf("Preparing %d", step))
455456
}
456-
func (ui stepsExecTUI) StepStarted(step int, runScript string) {
457+
func (ui stepsExecTUI) StepStarted(step int, runScript string, _ map[string]string) {
457458
ui.updateStatusBar(runScript)
458459
}
459460

0 commit comments

Comments
 (0)