Fix boolean pointer handling

- Refactor field reflection for clarity
- Update tests for clarity

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-10-29 23:07:39 -06:00
parent e54ecfad95
commit fcc15eb8ef
3 changed files with 182 additions and 142 deletions

View File

@@ -231,7 +231,7 @@ func UnmarshalConf(obj interface{}, excludeList []string) (lines []string) {
lines = append(lines, ymlStr...)
}
}
if field.Type.Kind() == reflect.Ptr && field.Tag.Get("yaml") != "" {
if field.Type.Kind() == reflect.Ptr && field.Type.Elem().Kind() == reflect.Struct && field.Tag.Get("yaml") != "" {
typeLine := field.Tag.Get("yaml")
if len(strings.Split(typeLine, ",")) > 1 {
typeLine = strings.Split(typeLine, ",")[0] + ":"