Skip to content

Commit

Permalink
Support filtering label allowlist by "all"
Browse files Browse the repository at this point in the history
Support filtering label allowlist by "all", which will expand to the
enabled resources, while infering their values based on its value(s).

Signed-off-by: Pranshu Srivastava <[email protected]>
  • Loading branch information
rexagod committed Sep 1, 2022
1 parent 7343894 commit 3e66989
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ _testmain.go

*.iml
.idea/
.run/

# Generated CLI help file
help.txt
Expand Down
11 changes: 10 additions & 1 deletion internal/store/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,16 @@ func (b *Builder) WithAllowAnnotations(annotations map[string][]string) {
// WithAllowLabels configures which labels can be returned for metrics
func (b *Builder) WithAllowLabels(labels map[string][]string) {
if len(labels) > 0 {
b.allowLabelsList = labels
// "all" takes precedence over other specifications
if allowedLabels, ok := labels["all"]; ok {
m := make(map[string][]string)
for _, resource := range b.enabledResources {
m[resource] = allowedLabels
}
b.allowLabelsList = m
} else {
b.allowLabelsList = labels
}
}
}

Expand Down

0 comments on commit 3e66989

Please sign in to comment.