Support step number
This commit is contained in:
parent
7fb84a54a8
commit
64cae197a4
4 changed files with 9 additions and 5 deletions
|
@ -396,6 +396,7 @@ type ContainerSpec struct {
|
||||||
|
|
||||||
// Step is the structure of one step in a job
|
// Step is the structure of one step in a job
|
||||||
type Step struct {
|
type Step struct {
|
||||||
|
Number int `yaml:"-"`
|
||||||
ID string `yaml:"id"`
|
ID string `yaml:"id"`
|
||||||
If yaml.Node `yaml:"if"`
|
If yaml.Node `yaml:"if"`
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
|
|
|
@ -120,6 +120,7 @@ func (rc *RunContext) compositeExecutor(action *model.Action) *compositeSteps {
|
||||||
if step.ID == "" {
|
if step.ID == "" {
|
||||||
step.ID = fmt.Sprintf("%d", i)
|
step.ID = fmt.Sprintf("%d", i)
|
||||||
}
|
}
|
||||||
|
step.Number = i
|
||||||
|
|
||||||
// create a copy of the step, since this composite action could
|
// create a copy of the step, since this composite action could
|
||||||
// run multiple times and we might modify the instance
|
// run multiple times and we might modify the instance
|
||||||
|
|
|
@ -48,6 +48,7 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
|
||||||
if stepModel.ID == "" {
|
if stepModel.ID == "" {
|
||||||
stepModel.ID = fmt.Sprintf("%d", i)
|
stepModel.ID = fmt.Sprintf("%d", i)
|
||||||
}
|
}
|
||||||
|
stepModel.Number = i
|
||||||
|
|
||||||
step, err := sf.newStep(stepModel, rc)
|
step, err := sf.newStep(stepModel, rc)
|
||||||
|
|
||||||
|
@ -119,7 +120,7 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
|
||||||
|
|
||||||
func useStepLogger(rc *RunContext, stepModel *model.Step, stage stepStage, executor common.Executor) common.Executor {
|
func useStepLogger(rc *RunContext, stepModel *model.Step, stage stepStage, executor common.Executor) common.Executor {
|
||||||
return func(ctx context.Context) error {
|
return func(ctx context.Context) error {
|
||||||
ctx = withStepLogger(ctx, stepModel.ID, stepModel.String(), stage.String())
|
ctx = withStepLogger(ctx, stepModel.Number, stepModel.ID, stepModel.String(), stage.String())
|
||||||
|
|
||||||
rawLogger := common.Logger(ctx).WithField("raw_output", true)
|
rawLogger := common.Logger(ctx).WithField("raw_output", true)
|
||||||
logWriter := common.NewLineWriter(rc.commandHandler(ctx), func(s string) bool {
|
logWriter := common.NewLineWriter(rc.commandHandler(ctx), func(s string) bool {
|
||||||
|
|
|
@ -117,11 +117,12 @@ func WithCompositeStepLogger(ctx context.Context, stepID string) context.Context
|
||||||
}).WithContext(ctx))
|
}).WithContext(ctx))
|
||||||
}
|
}
|
||||||
|
|
||||||
func withStepLogger(ctx context.Context, stepID string, stepName string, stageName string) context.Context {
|
func withStepLogger(ctx context.Context, stepNumber int, stepID, stepName, stageName string) context.Context {
|
||||||
rtn := common.Logger(ctx).WithFields(logrus.Fields{
|
rtn := common.Logger(ctx).WithFields(logrus.Fields{
|
||||||
"step": stepName,
|
"stepNumber": stepNumber,
|
||||||
"stepID": []string{stepID},
|
"step": stepName,
|
||||||
"stage": stageName,
|
"stepID": []string{stepID},
|
||||||
|
"stage": stageName,
|
||||||
})
|
})
|
||||||
return common.WithLogger(ctx, rtn)
|
return common.WithLogger(ctx, rtn)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue