Skip to content

Commit

Permalink
feat: enable original key to be returned for metadata property fields
Browse files Browse the repository at this point in the history
Signed-off-by: Samantha Coyle <[email protected]>
  • Loading branch information
sicoyle committed Mar 6, 2024
1 parent 858719e commit 5d8b40a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions metadata/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@ import (
)

// GetMetadataProperty returns a property from the metadata map, with support for case-insensitive keys and aliases.
func GetMetadataProperty(props map[string]string, keys ...string) (val string, ok bool) {
func GetMetadataProperty(props map[string]string, keys ...string) (key string, val string, ok bool) {
lcProps := make(map[string]string, len(props))
for k, v := range props {
lcProps[strings.ToLower(k)] = v
}
for _, k := range keys {
val, ok = lcProps[strings.ToLower(k)]
if ok {
return val, true
if v, found := lcProps[strings.ToLower(k)]; found {
return k, v, true
}
}
return "", false
return "", "", false
}

// DecodeMetadata decodes a component metadata into a struct.
Expand Down

0 comments on commit 5d8b40a

Please sign in to comment.