in schema/v1/step.go [227:277]
func (s *Step) compileToStepProto() (*proto.Step, error) {
protoInputs := map[string]*structpb.Value{}
for k, v := range (map[string]any)(s.Inputs) {
protoValue, err := (&valueCompiler{v}).compile()
if err != nil {
return nil, err
}
protoInputs[k] = protoValue
}
name := ""
if s.Name != nil {
name = *s.Name
}
var (
ref *proto.Step_Reference
err error
)
switch v := s.Step.(type) {
case *proto.Step_Reference:
ref = v
case string:
ref, err = shortReference(v).compile()
case *Reference:
ref, err = v.compile(name, protoInputs, s.Env)
default:
err = fmt.Errorf("unsupported type: %T", v)
}
if err != nil {
return nil, fmt.Errorf("compiling reference: %w", err)
}
if ref.Protocol == proto.StepReferenceProtocol_spec_def {
// Inputs are not returned in the StepReference because there is no guarantee they will match those defined by the SpecDef
// Each step has inputs when executed, so the step is free to inline these inputs into the returned SpecDef
return &proto.Step{
Name: name,
Step: ref,
Env: s.Env,
Inputs: nil,
}, nil
}
return &proto.Step{
Name: name,
Step: ref,
Env: s.Env,
Inputs: protoInputs,
}, nil
}