1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package approve_former
- import "fmt"
- const signTemplate = `- name: [[ .name ]]
- template: approval
- [[- 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.front_json }} == 通过`, sign.Name)
- }
- func (sign *Sign) Render(upperNode Noder) (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(),
- })
- }
|