in schema/v1/step.go [130:167]
func (s *Step) compileToDefinitionProto() (*proto.Definition, error) {
protoDef := &proto.Definition{}
switch {
case s.Exec != nil:
protoDef.Type = proto.DefinitionType_exec
protoDef.Exec = &proto.Definition_Exec{
Command: s.Exec.Command,
}
if s.Exec.WorkDir != nil {
protoDef.Exec.WorkDir = *s.Exec.WorkDir
}
case s.Run != nil:
protoDef.Type = proto.DefinitionType_steps
protoDef.Steps = make([]*proto.Step, len(s.Run))
for i, ss := range s.Run {
protoStep, err := (&ss).CompileStep()
if err != nil {
return nil, fmt.Errorf("compiling run[%v]: %v: %w", i, s.Name, err)
}
protoDef.Steps[i] = protoStep
}
protoDef.Outputs = map[string]*structpb.Value{}
for k, v := range s.Outputs {
protoV, err := (&valueCompiler{v}).compile()
if err != nil {
return nil, fmt.Errorf("compiling output[%q]: %v: %w", k, v, err)
}
protoDef.Outputs[k] = protoV
}
default:
return nil, fmt.Errorf("could not determine step type")
}
protoDef.Env = s.Env
if s.Delegate != nil {
protoDef.Delegate = *s.Delegate
}
return protoDef, nil
}