MCPcopy Create free account
hub / github.com/cli/cli / findInputs

Function findInputs

pkg/cmd/workflow/run/run.go:404–501  ·  view source on GitHub ↗
(yamlContent []byte)

Source from the content-addressed store, hash-verified

402}
403
404func findInputs(yamlContent []byte) ([]WorkflowInput, error) {
405 var rootNode yaml.Node
406 err := yaml.Unmarshal(yamlContent, &rootNode)
407 if err != nil {
408 return nil, fmt.Errorf("unable to parse workflow YAML: %w", err)
409 }
410
411 if len(rootNode.Content) != 1 {
412 return nil, errors.New("invalid YAML file")
413 }
414
415 var onKeyNode *yaml.Node
416 var dispatchKeyNode *yaml.Node
417 var inputsKeyNode *yaml.Node
418 var inputsMapNode *yaml.Node
419
420 // TODO this is pretty hideous
421 for _, node := range rootNode.Content[0].Content {
422 if onKeyNode != nil {
423 if node.Kind == yaml.MappingNode {
424 for _, node := range node.Content {
425 if dispatchKeyNode != nil {
426 for _, node := range node.Content {
427 if inputsKeyNode != nil {
428 inputsMapNode = node
429 break
430 }
431 if node.Value == "inputs" {
432 inputsKeyNode = node
433 }
434 }
435 break
436 }
437 if node.Value == "workflow_dispatch" {
438 dispatchKeyNode = node
439 }
440 }
441 } else if node.Kind == yaml.SequenceNode {
442 for _, node := range node.Content {
443 if node.Value == "workflow_dispatch" {
444 dispatchKeyNode = node
445 break
446 }
447 }
448 } else if node.Kind == yaml.ScalarNode {
449 if node.Value == "workflow_dispatch" {
450 dispatchKeyNode = node
451 break
452 }
453 }
454 break
455 }
456 if strings.EqualFold(node.Value, "on") {
457 onKeyNode = node
458 }
459 }
460
461 if onKeyNode == nil {

Callers 2

collectInputsFunction · 0.85
Test_findInputsFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by 1

Test_findInputsFunction · 0.68