-
Couldn't load subscription status.
- Fork 701
feat: Implement utf8 label name client capability #4442
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
72a3b80
feat: Allow utf-8 characters in label names
jake-kramer cbb8eb2
Address feedback
jake-kramer f651740
Prettier format
jake-kramer 6e8c895
Handle multiple values set for `Accept` header
jake-kramer a2b48a1
Address comments
jake-kramer d28e172
Merge branch 'main' into utf-label-names
jake-kramer 8b0a87e
Filter (instead of sanitize) on read
jake-kramer 12c20e7
Finish v2 read path filtering
jake-kramer 52d3ed3
v1 read path filtering
jake-kramer cb7c9b2
Add tests
jake-kramer 705b47e
fmt/lint
jake-kramer 84bc1b2
Fix comment on legacy label name valid chars
jake-kramer b9d1ec2
Fix race condition in test
jake-kramer b2888fa
Merge branch 'main' into utf-label-names
jake-kramer 9b0d790
Use `LabelNames` instead of backdoor query
jake-kramer f41512f
Update querier label name filtering test
jake-kramer 55810eb
fmt
jake-kramer 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package featureflags | ||
jake-kramer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import ( | ||
| "fmt" | ||
| "mime" | ||
| "net/http" | ||
| ) | ||
|
|
||
| const ( | ||
| // Capability names | ||
| AllowUtf8LabelNamesCapabilityName = "allow-utf8-labelnames" | ||
jake-kramer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| type ClientCapability struct { | ||
| Name string | ||
| Value string | ||
| } | ||
|
|
||
| func ParseClientCapabilities(header http.Header) ([]*ClientCapability, error) { | ||
| acceptHeader := header.Get("Accept") | ||
jake-kramer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if acceptHeader != "" { | ||
| if _, params, err := mime.ParseMediaType(acceptHeader); err != nil { | ||
| return nil, err | ||
| } else { | ||
| capabilities := make([]*ClientCapability, 0, len(params)) | ||
| seenCapabilityNames := make(map[string]struct{}) | ||
| for k, v := range params { | ||
| // Check for duplicates | ||
jake-kramer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if _, ok := seenCapabilityNames[k]; ok { | ||
| return nil, fmt.Errorf("duplicate client capabilities parsed from `Accept:` header: '%s'", | ||
| params) | ||
| } | ||
| seenCapabilityNames[k] = struct{}{} | ||
|
|
||
| capabilities = append(capabilities, &ClientCapability{Name: k, Value: v}) | ||
| } | ||
|
|
||
| return capabilities, nil | ||
| } | ||
| } | ||
|
|
||
| return []*ClientCapability{}, nil | ||
| } | ||
|
|
||
| func GetClientCapability(capabilities []*ClientCapability, capabilityName string) *ClientCapability { | ||
| for _, capability := range capabilities { | ||
| if capability.Name == capabilityName { | ||
| return capability | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.