diff --git a/step.go b/step.go index e50e7c7..2136533 100644 --- a/step.go +++ b/step.go @@ -22,13 +22,40 @@ import ( // Step defines runtime metadata for a step. type Step struct { + Name string `json:"name,omitempty"` + Type StepType `json:"type,omitempty"` Number int `json:"number,omitempty"` Started time.Time `json:"started,omitempty"` Finished time.Time `json:"finished,omitempty"` } +// StepType identifies the type of step. +type StepType string + +const ( + StepTypeClone StepType = "clone" + StepTypeService StepType = "service" + StepTypePlugin StepType = "plugin" + StepTypeCommands StepType = "commands" + StepTypeCache StepType = "cache" +) + func stepFlags() []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "step.name", + Usage: "step name", + Sources: cli.EnvVars( + "CI_STEP_NAME", + ), + }, + &cli.StringFlag{ + Name: "step.type", + Usage: "step type", + Sources: cli.EnvVars( + "CI_STEP_TYPE", + ), + }, &cli.IntFlag{ Name: "step.number", Usage: "step number", @@ -56,6 +83,8 @@ func stepFlags() []cli.Flag { func stepFromContext(c *cli.Command) Step { return Step{ + Name: c.String("step.name"), + Type: StepType(c.String("step.type")), Number: c.Int("step.number"), Started: time.Unix(c.Int64("step.started"), 0), Finished: time.Unix(c.Int64("step.finished"), 0),