Skip to content

Commit

Permalink
add decude to configmap as well
Browse files Browse the repository at this point in the history
  • Loading branch information
howardjohn committed May 15, 2023
1 parent 1ddee5c commit d9c03e7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/grep.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ func GrepResources(opts Opts, in io.Reader, out io.Writer) error {
if opts.Decode && obj.Kind == "Secret" {
raw = decodeSecret(raw)
}
if opts.Decode && obj.Kind == "ConfigMap" {
raw = decodeConfigMap(raw)
}
o, err := yaml.Marshal(raw)
if err != nil {
return err
Expand Down Expand Up @@ -235,6 +238,21 @@ func decodeSecret(raw genericMap) genericMap {
return raw
}

func decodeConfigMap(raw genericMap) genericMap {
data, ok := raw["binaryData"]
if !ok {
return raw
}
gm, ok := data.(genericMap)
if !ok {
return raw
}
for k, v := range gm {
gm[k] = base64Decode(v)
}
return raw
}

func base64Decode(d interface{}) interface{} {
t, ok := d.(string)
if !ok {
Expand Down

0 comments on commit d9c03e7

Please sign in to comment.