-
Notifications
You must be signed in to change notification settings - Fork 814
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
Fix -ruler.alertmanager-url flag #2989
Conversation
This was never space separated, you needed to register the flag multiple times for it to append to the list of strings. On top of that, the previous change implied that when using a config file you would need to provide a a list instead of a string thus breaking exisiting configuration. Signed-off-by: gotjosh <[email protected]>
We had two very similar flag extensions: `Strings` and `StringSlice`. With this, we unify its use by removing `Strings` in favour of `StringSlice` but keeping the string representation favoured in `Strings`. The difference here is that by using `Sprintf` we would get the brackets representation as part of the string. Signed-off-by: gotjosh <[email protected]>
This is no longer only about the API. Signed-off-by: gotjosh <[email protected]>
Signed-off-by: gotjosh <[email protected]>
|
||
// StringSlice is a slice of strings that implements flag.Value | ||
type StringSlice []string | ||
|
||
// String implements flag.Value | ||
func (v StringSlice) String() string { | ||
return strings.Join(v, " ") | ||
return fmt.Sprintf("%s", []string(v)) |
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.
The unification of the flag extensions is basically that I kept the name StringSlice
but "borrowed" the String
casting function.
I like this because for empty values it renders []
instead of ""
which seems to be more accurate.
Signed-off-by: gotjosh <[email protected]>
I'm not sure what to include in the changelog - opinions are welcome. |
Nothing. I don't see any user-impact since the last release that is introduced by this PR. |
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.
Very good job! Clean fix and tested 👏
* fix: `-ruler.alertmanager-url` should be a string This was never space separated, you needed to register the flag multiple times for it to append to the list of strings. On top of that, the previous change implied that when using a config file you would need to provide a a list instead of a string thus breaking exisiting configuration. Signed-off-by: gotjosh <[email protected]> * Unify the use of StringSlice flags We had two very similar flag extensions: `Strings` and `StringSlice`. With this, we unify its use by removing `Strings` in favour of `StringSlice` but keeping the string representation favoured in `Strings`. The difference here is that by using `Sprintf` we would get the brackets representation as part of the string. Signed-off-by: gotjosh <[email protected]> * Rename `api_ruler_test` to `ruler_test` This is no longer only about the API. Signed-off-by: gotjosh <[email protected]> * Create an integration test for Alertmanager discovery Signed-off-by: gotjosh <[email protected]> * Fix existing test Signed-off-by: gotjosh <[email protected]>
* fix: `-ruler.alertmanager-url` should be a string This was never space separated, you needed to register the flag multiple times for it to append to the list of strings. On top of that, the previous change implied that when using a config file you would need to provide a a list instead of a string thus breaking exisiting configuration. Signed-off-by: gotjosh <[email protected]> * Unify the use of StringSlice flags We had two very similar flag extensions: `Strings` and `StringSlice`. With this, we unify its use by removing `Strings` in favour of `StringSlice` but keeping the string representation favoured in `Strings`. The difference here is that by using `Sprintf` we would get the brackets representation as part of the string. Signed-off-by: gotjosh <[email protected]> * Rename `api_ruler_test` to `ruler_test` This is no longer only about the API. Signed-off-by: gotjosh <[email protected]> * Create an integration test for Alertmanager discovery Signed-off-by: gotjosh <[email protected]> * Fix existing test Signed-off-by: gotjosh <[email protected]> Co-authored-by: gotjosh <[email protected]>
What this PR does:
-ruler.alertmanager-url
by reverting it back to using a string (which is meant to be comma-separated) as opposed to a list of strings. As it was this broke compatibility with a file-based configuration where it required a list of strings instead of a single string.StringsSlice
andStrings
flag extensions.Quoting the commits:
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]