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

Function findInputs

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

Source from the content-addressed store, hash-verified

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

Callers 2

collectInputsFunction · 0.85
Test_findInputsFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by 1

Test_findInputsFunction · 0.68