Skip to content

Commit

Permalink
Add comments for new functions
Browse files Browse the repository at this point in the history
Signed-off-by: Lance Rushing <lance@lancerushing.com>
  • Loading branch information
lrush committed Dec 26, 2023
1 parent df900c8 commit 962c556
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions stores/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func Flatten(in map[string]interface{}) map[string]interface{} {
return newMap
}

// FlattenMetadata flattens a Metadata struct into a flat map.
func FlattenMetadata(md Metadata) (map[string]interface{}, error) {
var mdMap map[string]interface{}
jsonBytes, err := json.Marshal(md)
Expand Down Expand Up @@ -214,6 +215,8 @@ func UnflattenMetadata(in map[string]interface{}) (Metadata, error) {
return md, err
}

// DecodeNewLines replaces \\n with \n for all string values in the map.
// Used by config stores that do not handle multi-line values (ini, dotenv).
func DecodeNewLines(m map[string]interface{}) {
for k, v := range m {
if s, ok := v.(string); ok {
Expand All @@ -222,6 +225,8 @@ func DecodeNewLines(m map[string]interface{}) {
}
}

// EncodeNewLines replaces \n with \\n for all string values in the map.
// Used by config stores that do not handle multi-line values (ini, dotenv).
func EncodeNewLines(m map[string]interface{}) {
for k, v := range m {
if s, ok := v.(string); ok {
Expand Down

0 comments on commit 962c556

Please sign in to comment.