Updated model builder to use lowercase checks only. **breaking change**

The case checking seems kinda dumb now looking back at this code. I am not sure why I felt the need to do that, however after being aware of it for some time and not being happy with the extra cycles it puts the code through.

This change removes ConvertCase from the utils package, as it's no longer used or needed right now. If it needs co come back, we can re-add the code, but deleting code always makes me happy.
It also removed a dependency from the project, which reduces the footprint, great!
This commit is contained in:
Dave Shanley
2022-11-05 09:54:34 -04:00
parent 9e0c5cd2e9
commit 77ecbd418f
5 changed files with 3 additions and 56 deletions

View File

@@ -3,7 +3,6 @@ package utils
import (
"encoding/json"
"fmt"
"github.com/iancoleman/strcase"
"github.com/vmware-labs/yaml-jsonpath/pkg/yamlpath"
"gopkg.in/yaml.v3"
"regexp"
@@ -206,7 +205,7 @@ type KeyNodeSearch struct {
func FindKeyNodeTop(key string, nodes []*yaml.Node) (keyNode *yaml.Node, valueNode *yaml.Node) {
for i, v := range nodes {
if key == v.Value {
if strings.ToLower(key) == strings.ToLower(v.Value) {
return v, nodes[i+1] // next node is what we need.
}
}
@@ -538,26 +537,6 @@ func RenderCodeSnippet(startNode *yaml.Node, specData []string, before, after in
return buf.String()
}
func ConvertCase(input string, convert Case) string {
if input == "" {
return ""
}
switch convert {
case PascalCase:
return strcase.ToCamel(input)
case CamelCase:
return strcase.ToLowerCamel(input)
case ScreamingKebabCase:
return strcase.ToScreamingKebab(input)
case ScreamingSnakeCase:
return strcase.ToScreamingSnake(input)
case SnakeCase:
return strcase.ToSnake(input)
default:
return input
}
}
func DetectCase(input string) Case {
trim := strings.TrimSpace(input)
if trim == "" {