Skip to content

Commit

Permalink
Merge pull request #118 from stefannica/fix-workflow-list
Browse files Browse the repository at this point in the history
Fix workflow type dereference in workflow CLI commands
  • Loading branch information
stefannica committed Nov 18, 2021
2 parents 2db7525 + 165ea3a commit 89b2d57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pkg/cli/workflow/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const getTemplate = `{{decorate "bold" "Name"}}: {{ .Workflow.Name }}
NAME TYPE DESCRIPTION DEFAULT
{{- range $input := .Workflow.Inputs }}
{{- if not $input.Default }}
{{decorate "bullet" $input.Name }} {{ $input.Type }} {{ formatDesc $input.Description }} {{ "---" }}
{{decorate "bullet" $input.Name }} {{ deref $input.Type }} {{ formatDesc $input.Description }} {{ "---" }}
{{- else }}
{{decorate "bullet" $input.Name }} {{ $input.Type }} {{ formatDesc $input.Description }} {{ $input.Default }}
{{decorate "bullet" $input.Name }} {{ deref $input.Type }} {{ formatDesc $input.Description }} {{ $input.Default }}
{{- end }}
{{- end }}
{{- end }}
Expand All @@ -41,7 +41,7 @@ const getTemplate = `{{decorate "bold" "Name"}}: {{ .Workflow.Name }}
{{- else }}
NAME TYPE DESCRIPTION
{{- range $output := .Workflow.Outputs }}
{{ decorate "bullet" $output.Name }} {{ $output.Type }} {{ formatDesc $output.Description }}
{{ decorate "bullet" $output.Name }} {{ deref $output.Type }} {{ formatDesc $output.Description }}
{{- end }}
{{- end }}
Expand Down
14 changes: 10 additions & 4 deletions pkg/cli/workflow/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ type listOptions struct {
func formatInputs(object interface{}, column string, field interface{}) (formated string) {
if workflow, ok := object.(*workflow.Workflow); ok {
for i, input := range workflow.Inputs {
formated += fmt.Sprintf("- name: %s\n type: %s", input.Name, *input.Type)
formated += fmt.Sprintf("- name: %s", input.Name)
if input.Type != nil {
formated += fmt.Sprintf("\n type: %s", *input.Type)
}
if input.Default != nil {
formated += fmt.Sprintf("\n default: %s", *input.Default)
}
Expand All @@ -36,9 +39,12 @@ func formatInputs(object interface{}, column string, field interface{}) (formate

func formatOutputs(object interface{}, column string, field interface{}) (formated string) {
if workflow, ok := object.(*workflow.Workflow); ok {
for i, input := range workflow.Outputs {
formated += fmt.Sprintf("- name: %s\n type: %s", input.Name, *input.Type)
if i != len(workflow.Inputs)-1 {
for i, output := range workflow.Outputs {
formated += fmt.Sprintf("- name: %s", output.Name)
if output.Type != nil {
formated += fmt.Sprintf("\n type: %s", *output.Type)
}
if i != len(workflow.Outputs)-1 {
formated += "\n"
}
}
Expand Down

0 comments on commit 89b2d57

Please sign in to comment.