-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add more option for release creation
- Loading branch information
Showing
5 changed files
with
81 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package cliutil | ||
|
||
import ( | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// ConvertConfigArrayToNestedMap converts a flat key-value map with dot notation | ||
// paths into a nested map[string]interface{} structure. It handles conversion | ||
// of string values to numbers and booleans where appropriate. | ||
func ConvertConfigArrayToNestedMap(configArray map[string]string) map[string]interface{} { | ||
config := make(map[string]interface{}) | ||
for path, value := range configArray { | ||
segments := strings.Split(path, ".") | ||
current := config | ||
for i, segment := range segments { | ||
if i == len(segments)-1 { | ||
if num, err := strconv.ParseFloat(value, 64); err == nil { | ||
current[segment] = num | ||
} else if value == "true" { | ||
current[segment] = true | ||
} else if value == "false" { | ||
current[segment] = false | ||
} else { | ||
current[segment] = value | ||
} | ||
} else { | ||
// Create nested map if it doesn't exist | ||
if _, exists := current[segment]; !exists { | ||
current[segment] = make(map[string]interface{}) | ||
} | ||
// Move to next level | ||
current = current[segment].(map[string]interface{}) | ||
} | ||
} | ||
} | ||
return config | ||
} |