summaryrefslogtreecommitdiffstats
path: root/pkg/model/workflow.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/model/workflow.go')
-rw-r--r--pkg/model/workflow.go44
1 files changed, 31 insertions, 13 deletions
diff --git a/pkg/model/workflow.go b/pkg/model/workflow.go
index 9860aad..1186454 100644
--- a/pkg/model/workflow.go
+++ b/pkg/model/workflow.go
@@ -79,22 +79,40 @@ type WorkflowDispatch struct {
}
func (w *Workflow) WorkflowDispatchConfig() *WorkflowDispatch {
- if w.RawOn.Kind != yaml.MappingNode {
- return nil
- }
-
- var val map[string]yaml.Node
- if !decodeNode(w.RawOn, &val) {
- return nil
- }
+ switch w.RawOn.Kind {
+ case yaml.ScalarNode:
+ var val string
+ if !decodeNode(w.RawOn, &val) {
+ return nil
+ }
+ if val == "workflow_dispatch" {
+ return &WorkflowDispatch{}
+ }
+ case yaml.SequenceNode:
+ var val []string
+ if !decodeNode(w.RawOn, &val) {
+ return nil
+ }
+ for _, v := range val {
+ if v == "workflow_dispatch" {
+ return &WorkflowDispatch{}
+ }
+ }
+ case yaml.MappingNode:
+ var val map[string]yaml.Node
+ if !decodeNode(w.RawOn, &val) {
+ return nil
+ }
- var config WorkflowDispatch
- node := val["workflow_dispatch"]
- if !decodeNode(node, &config) {
+ n, found := val["workflow_dispatch"]
+ var workflowDispatch WorkflowDispatch
+ if found && decodeNode(n, &workflowDispatch) {
+ return &workflowDispatch
+ }
+ default:
return nil
}
-
- return &config
+ return nil
}
type WorkflowCallInput struct {