Skip to content

Commit

Permalink
feat: adding a new kind: markdown (#40)
Browse files Browse the repository at this point in the history
Co-authored-by: rick <LinuxSuRen@users.noreply.github.com>
  • Loading branch information
LinuxSuRen and LinuxSuRen authored Jun 21, 2023
1 parent 3267876 commit 8ce37cf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions cmd/argoworkflow/template/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ Please feel free to check the following outputs:
| {{$name}}: {{$output.Value}} |
{{- end}}
{{- end}}
{{- range $name, $output := .}}
{{- if eq "markdown" (toString $output.Kind)}}
{{$output.Value}}
{{- end}}
{{- end}}
`
5 changes: 4 additions & 1 deletion cmd/argoworkflow/workflow_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"strings"

wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/linuxsuren/gogit/argoworkflow/template"
Expand Down Expand Up @@ -56,8 +57,10 @@ func GetOutputsWithTarget(wf *wfv1.Workflow, target string) map[string]template.
for i, output := range outputs {
if output.File != "" {
output.File = target + output.File
outputs[i] = output
} else if strings.HasSuffix(i, ".md") {
output.Kind = "markdown"
}
outputs[i] = output
}
}
return outputs
Expand Down
15 changes: 14 additions & 1 deletion cmd/argoworkflow/workflow_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,25 @@ func TestGetOutputsWithTarget(t *testing.T) {
}},
},
},
"report.md": wfv1.NodeStatus{
Name: "report.md",
Outputs: &wfv1.Outputs{
Parameters: []wfv1.Parameter{{
Name: "report.md",
Value: wfv1.AnyStringPtr("## Report\n"),
}},
},
},
},
},
}

outputs := GetOutputsWithTarget(wf, "https://github.com")
for _, output := range outputs {
assert.Truef(t, strings.HasPrefix(output.File, "https://github.com"), output.File)
if output.Kind == "file" {
assert.Truef(t, strings.HasPrefix(output.File, "https://github.com"), output.File)
} else if output.Kind == "markdown" {
assert.Equal(t, "## Report\n", output.Value)
}
}
}

0 comments on commit 8ce37cf

Please sign in to comment.