(input string)
| 442 | } |
| 443 | |
| 444 | func getConfigOptions(input string) ([]templates.NameDescription, bool) { |
| 445 | |
| 446 | input = strings.ToLower(input) |
| 447 | |
| 448 | configOptions := []templates.NameDescription{} |
| 449 | |
| 450 | allConfigData := configs.GetConfig().AllConfigData() |
| 451 | pathLookup := map[string]string{} |
| 452 | for name, _ := range allConfigData { |
| 453 | |
| 454 | lowerName := strings.ToLower(name) |
| 455 | pathLookup[lowerName] = name |
| 456 | |
| 457 | builtPath := "" |
| 458 | for _, namePart := range strings.Split(name, ".") { |
| 459 | builtPath += namePart |
| 460 | if _, ok := pathLookup[builtPath]; !ok { |
| 461 | pathLookup[strings.ToLower(builtPath)] = builtPath |
| 462 | } |
| 463 | builtPath += "." |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | inputProperCase := input |
| 468 | if caseCheck, ok := pathLookup[input]; ok { |
| 469 | |
| 470 | inputProperCase = caseCheck |
| 471 | |
| 472 | // Is this a full config path? |
| 473 | if configVal, ok := allConfigData[inputProperCase]; ok { |
| 474 | |
| 475 | configOptions = append(configOptions, templates.NameDescription{ |
| 476 | Id: inputProperCase, |
| 477 | Name: inputProperCase, |
| 478 | Description: fmt.Sprintf("%v", configVal), |
| 479 | }) |
| 480 | |
| 481 | return configOptions, true |
| 482 | |
| 483 | } |
| 484 | |
| 485 | } else if input != "" { |
| 486 | return configOptions, false |
| 487 | } |
| 488 | |
| 489 | // Find which partial path we are on and populate options |
| 490 | usedNames := map[string]struct{}{} |
| 491 | for fullConfigPath, configVal := range allConfigData { |
| 492 | |
| 493 | if input != "" { |
| 494 | if len(fullConfigPath) <= len(input) || fullConfigPath[0:len(inputProperCase)] != inputProperCase { |
| 495 | continue |
| 496 | } |
| 497 | } |
| 498 | |
| 499 | nextConfigPathSection := fullConfigPath |
| 500 | if len(inputProperCase) > 0 { |
| 501 | nextConfigPathSection = nextConfigPathSection[len(inputProperCase)+1:] |
no test coverage detected