package approve_former import "fmt" const signTemplate = `- name: [[ .name ]] template: approval [[- if .depends ]] depends: "[[ .depends ]]" [[- end ]] [[- if .when ]] when: "[[ .when ]]" [[- end -]]` type Sign struct { Name string } func NewSign(name string) *Sign { return &Sign{ Name: name, } } func (sign *Sign) GetDepends() string { return fmt.Sprintf("%s.Succeeded", sign.Name) } func (sign *Sign) GetWhen() string { return fmt.Sprintf(`{{ tasks.%s.outputs.parameters.approve }} == 通过`, sign.Name) } func (sign *Sign) Render(upperNode Node) (string, error) { if upperNode == nil { return render("sign", signTemplate, map[string]any{ "name": sign.Name, }) } return render("sign", signTemplate, map[string]any{ "name": sign.Name, "depends": upperNode.GetDepends(), "when": upperNode.GetWhen(), }) }