Skip to content

Commit 7b375e9

Browse files
committed
undo changes in internal/store/builder.go
1 parent 294163d commit 7b375e9

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

internal/store/builder.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,18 @@ func (b *Builder) WithMetrics(r prometheus.Registerer) {
107107

108108
// WithEnabledResources sets the enabledResources property of a Builder.
109109
func (b *Builder) WithEnabledResources(r []string) error {
110-
enabledResources := map[string]bool{}
111-
for _, er := range b.enabledResources {
112-
enabledResources[er] = true
113-
}
114-
var newResources []string
115110
for _, resource := range r {
116-
// validate that the resource exists and skip those that are already enabled
117111
if !resourceExists(resource) {
118112
return fmt.Errorf("resource %s does not exist. Available resources: %s", resource, strings.Join(availableResources(), ","))
119113
}
120-
if _, ok := enabledResources[resource]; !ok {
121-
newResources = append(newResources, resource)
122-
}
123-
}
124-
if len(newResources) == 0 {
125-
return nil
126114
}
127115

128-
b.enabledResources = append(b.enabledResources, newResources...)
129-
sort.Strings(b.enabledResources)
116+
var sortedResources []string
117+
sortedResources = append(sortedResources, r...)
118+
119+
sort.Strings(sortedResources)
120+
121+
b.enabledResources = append(b.enabledResources, sortedResources...)
130122
return nil
131123
}
132124

tests/e2e/discovery_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ func TestVariableVKsDiscoveryAndResolution(t *testing.T) {
259259
// Note: we use count to make sure that only one metrics handler is running, and we also want to validate that the
260260
// new metric is available and the old one was removed, otherwise, the response could come from the
261261
// previous handler before its context was cancelled, or maybe because it failed to be cancelled.
262-
if strings.Count(string(out), testUpdateCRDMetric) == 1 && !strings.Contains(string(out), testMetric) {
262+
if strings.Contains(string(out), testUpdateCRDMetric) && !strings.Contains(string(out), testMetric) {
263263
klog.InfoS("metrics available", "metric", string(out))
264264
// Signal the process to exit, since we know the metrics are being generated as expected.
265265
ch <- true

0 commit comments

Comments
 (0)