-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
regex support for flag --secret-type:<type>:<regex> #243
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! There are however some little changes that could be made before merging.
|
||
func getMatchingKeys(secretKeyValues map[string][]byte, pattern string) ([]string, error) { | ||
keys := make([]string, 0, len(secretKeyValues)) | ||
regex, err := regexp.Compile(pattern) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than compiling the regex on the fly, you should compile it just after flag and argument parsing, and store them as regexes in Exporter.KubeSecretTypes
in order to produce the error as soon as possible and treat it as argument parsing error. The exporter should not succeed to start if arguments are malformed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Let me make the change
continue | ||
} | ||
for _, kubeSecretKey := range kubeSecretKeys { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a cosmetic standpoint, this empty line could be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
regex support for flag --secret-type::
For eg:
--secret-type:kubernetes.io/tls:..tls
--secret-type:Opaque:..pem