Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AnuragEkkati
Copy link

regex support for flag --secret-type::

For eg:
--secret-type:kubernetes.io/tls:..tls
--secret-type:Opaque:.
.pem

@npdgm npdgm self-assigned this Feb 6, 2024
@npdgm npdgm added the enhancement New feature or request label Feb 6, 2024
Copy link
Contributor

@paullaffitte paullaffitte left a 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)
Copy link
Contributor

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.

Copy link
Author

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 {

Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants