Skip to content

Commit

Permalink
Support walking slices and arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtechVitek committed Oct 4, 2024
1 parent 0d8fa2d commit 93ba276
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ func (g *collector) collectSecretFields(v reflect.Value, path string) {
g.collectSecretFields(field, fmt.Sprintf("%v.%v", path, v.Type().Field(i).Name))
}

case reflect.Slice, reflect.Array:
for i := 0; i < v.Len(); i++ {
item := v.Index(i)
g.collectSecretFields(item, fmt.Sprintf("%v[%v]", path, i))
}

case reflect.String:
secretName, found := strings.CutPrefix(v.String(), "$SECRET:")
if !found {
Expand All @@ -51,7 +57,8 @@ func (g *collector) collectSecretFields(v reflect.Value, path string) {
fieldPath: path,
secretName: secretName,
})
}

return
default:
return
}
}

0 comments on commit 93ba276

Please sign in to comment.