Skip to content

Commit

Permalink
Merge pull request #1506 from jonjohnsonjr/uses-names-slog
Browse files Browse the repository at this point in the history
Add uses and name to slog values
  • Loading branch information
k4leung4 authored Sep 19, 2024
2 parents 4835c49 + a6a3370 commit 1a5bdfe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/build/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (c *Compiled) CompilePipelines(ctx context.Context, sm *SubstitutionMap, pi

func (c *Compiled) compilePipeline(ctx context.Context, sm *SubstitutionMap, pipeline *config.Pipeline, parent map[string]string) error {
log := clog.FromContext(ctx)
uses, with := pipeline.Uses, maps.Clone(pipeline.With)
name, uses, with := pipeline.Name, pipeline.Uses, maps.Clone(pipeline.With)

if uses != "" {
var data []byte
Expand Down Expand Up @@ -239,6 +239,9 @@ func (c *Compiled) compilePipeline(ctx context.Context, sm *SubstitutionMap, pip
return fmt.Errorf("undefined input %q to pipeline %q", k, pipeline.Uses)
}
}

// We want to keep the original name here because loading the pipeline will overwrite it.
pipeline.Name = name
}

if parent != nil {
Expand Down
11 changes: 11 additions & 0 deletions pkg/build/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,17 @@ func (r *pipelineRunner) runPipeline(ctx context.Context, pipeline *config.Pipel
log.Infof("running step %q", id)
}

slogs := []any{}
if pipeline.Name != "" {
slogs = append(slogs, "name", pipeline.Name)
}
if pipeline.Uses != "" {
slogs = append(slogs, "uses", pipeline.Uses)
}
if len(slogs) != 0 {
ctx = clog.WithLogger(ctx, log.With(slogs...))
}

command := buildEvalRunCommand(pipeline, debugOption, workdir, pipeline.Runs)
if err := r.runner.Run(ctx, r.config, envOverride, command...); err != nil {
if err := r.maybeDebug(ctx, pipeline.Runs, envOverride, command, workdir, err); err != nil {
Expand Down

0 comments on commit 1a5bdfe

Please sign in to comment.