-
Notifications
You must be signed in to change notification settings - Fork 537
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
Ruler: Add support for arbitrary extra URL parameters to Alertmanager client's OAuth config #10030
Open
alexweav
wants to merge
10
commits into
main
Choose a base branch
from
alexweav/ruler-endpointParams
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+504
−146
Open
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
79f3f6c
Extend LimitsMap to support strings
alexweav 9d93f4c
Drive-by fix update bug i noticed
alexweav de427c2
Add exported way to fetch the map contents
alexweav d248790
Add exported way to initialize with data
alexweav 2815a31
Endpoint params support
alexweav c7048cd
make docs, make reference-help
alexweav 3e449c9
linter
alexweav e25750c
fix doc generator
alexweav d827a08
regen docs
alexweav 2729df9
Extend changelog
alexweav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,15 +9,19 @@ import ( | |
"gopkg.in/yaml.v3" | ||
) | ||
|
||
// LimitsMap is a generic map that can hold either float64 or int as values. | ||
type LimitsMap[T float64 | int] struct { | ||
// LimitsMap is a flag.Value implementation that looks like a generic map, holding float64s, ints, or strings as values. | ||
type LimitsMap[T float64 | int | string] struct { | ||
data map[string]T | ||
validator func(k string, v T) error | ||
} | ||
|
||
func NewLimitsMap[T float64 | int](validator func(k string, v T) error) LimitsMap[T] { | ||
func NewLimitsMap[T float64 | int | string](validator func(k string, v T) error) LimitsMap[T] { | ||
return NewLimitsMapWithData(make(map[string]T), validator) | ||
} | ||
|
||
func NewLimitsMapWithData[T float64 | int | string](data map[string]T, validator func(k string, v T) error) LimitsMap[T] { | ||
return LimitsMap[T]{ | ||
data: make(map[string]T), | ||
data: data, | ||
validator: validator, | ||
} | ||
} | ||
|
@@ -45,6 +49,10 @@ func (m LimitsMap[T]) Set(s string) error { | |
return m.updateMap(newMap) | ||
} | ||
|
||
func (m LimitsMap[T]) Read() map[string]T { | ||
return m.data | ||
} | ||
|
||
// Clone returns a copy of the LimitsMap. | ||
func (m LimitsMap[T]) Clone() LimitsMap[T] { | ||
newMap := make(map[string]T, len(m.data)) | ||
|
@@ -73,6 +81,7 @@ func (m LimitsMap[T]) updateMap(newMap map[string]T) error { | |
} | ||
} | ||
|
||
clear(m.data) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. drive-by bugfix i happened to notice. added corresponding test. |
||
for k, v := range newMap { | ||
m.data[k] = v | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
So far, the only place where we really use map flags is in Limits, that's why this was called LimitsMap. But, nothing in this file is really specific to limits.
This new use case isn't really a limit, but I felt it gives a better configuration experience to be consistent with existing flags here, rather than invent a second map format that behaves differently.
I've kept the name
LimitsMap
and package as i feel it's close enough to being descriptive and would muddy the diff to include renames/moves. I also think there's a valid case for moving this todskit
'sflagext
package in the future anyway, so it didn't make sense to do a big rename yet.I'm happy to change the name, or explore moving this to dskit, if reviewers would prefer. Or, this can be left to a subsequent PR.