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

Check for nil strings and include wrappers around each. #1335

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

mattdurham
Copy link
Contributor

When trying to remove the fork grafana agent uses ran into an issue with some strings being nil via the config. Kingpin never allows this so it hasnt been an issue yet.

Created two wrapper methods to make it easier, I could have went with one new func and ! the call but I think its cleaner to have two. I checked for any *string and *bool.

Tested the windows_exporter and the Grafana Agent using this without problem.

@mattdurham mattdurham marked this pull request as ready for review November 14, 2023 15:43
@mattdurham mattdurham requested a review from a team as a code owner November 14, 2023 15:43
@jkroepke
Copy link
Member

PR LGTM, but

How are you able to pass nil values to collectors? Because the config structs of each collector are not having string points. Do I miss something?

@mattdurham
Copy link
Contributor Author

For example oldSiteExclude is only set from NewFromFlag so it will be always nil when dealing with using a config. Its very likely a few of these are never nil, but it was easier to wrap them all instead of figuring out the usage of each.

@mattdurham
Copy link
Contributor Author

The where clause fields and a few others look fine without the check but then I have to think on whether its safe or not.

@mattdurham
Copy link
Contributor Author

If you would prefer I not touch those strings, I can go back and check them.

Copy link
Member

@jkroepke jkroepke left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@jkroepke
Copy link
Member

If you would prefer I not touch those strings, I can go back and check them.

I just want to know, where are the nil values come from. But almost all "old" settings are affected here.

@jkroepke jkroepke merged commit 1836cd1 into prometheus-community:master Nov 15, 2023
5 checks passed
@mattdurham mattdurham deleted the nil_string_check branch November 15, 2023 18:29
anubhavg-icpl pushed a commit to anubhavg-icpl/windows_exporter that referenced this pull request Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants