MCPcopy Index your code
hub / github.com/cli/cli / findInputs

Function findInputs

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

Source from the content-addressed store, hash-verified

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

Callers 2

collectInputsFunction · 0.85
Test_findInputsFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by 1

Test_findInputsFunction · 0.68