(matchers []*labels.Matcher)
| 51 | } |
| 52 | |
| 53 | func ExtractShardingInfo(matchers []*labels.Matcher) ([]*labels.Matcher, *storepb.ShardInfo, error) { |
| 54 | r := make([]*labels.Matcher, 0, len(matchers)) |
| 55 | |
| 56 | shardInfo := storepb.ShardInfo{} |
| 57 | for _, matcher := range matchers { |
| 58 | if matcher.Name == CortexShardByLabel && matcher.Type == labels.MatchEqual { |
| 59 | decoded, err := base64.StdEncoding.DecodeString(matcher.Value) |
| 60 | if err != nil { |
| 61 | return r, nil, err |
| 62 | } |
| 63 | err = shardInfo.Unmarshal(decoded) |
| 64 | if err != nil { |
| 65 | return r, nil, err |
| 66 | } |
| 67 | } else { |
| 68 | r = append(r, matcher) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | return r, &shardInfo, nil |
| 73 | } |
| 74 | |
| 75 | func ExtractShardingMatchers(matchers []*labels.Matcher) ([]*labels.Matcher, *storepb.ShardMatcher, error) { |
| 76 | r, shardInfo, err := ExtractShardingInfo(matchers) |
no test coverage detected