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

Function findInputs

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

Source from the content-addressed store, hash-verified

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

Callers 2

collectInputsFunction · 0.85
Test_findInputsFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by 1

Test_findInputsFunction · 0.68