Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding a new kind: markdown #40

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
}
Loading