Skip to content

Commit da10923

Browse files
authored
Merge pull request #1994 from clamoriniere/fix-builder-interface
fix: public Builder compatibility with the BuilderInterface
2 parents 1acb4df + bcfef5a commit da10923

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pkg/builder/builder.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ import (
3232
"k8s.io/kube-state-metrics/v2/pkg/options"
3333
)
3434

35+
// Make sure the public Builder implements the public BuilderInterface.
36+
// New internal Builder methods should be added to the public BuilderInterface.
37+
var _ ksmtypes.BuilderInterface = &Builder{}
38+
3539
// Builder helps to build store. It follows the builder pattern
3640
// (https://en.wikipedia.org/wiki/Builder_pattern).
3741
type Builder struct {
@@ -61,6 +65,11 @@ func (b *Builder) WithNamespaces(n options.NamespaceList) {
6165
b.internal.WithNamespaces(n)
6266
}
6367

68+
// WithFieldSelectorFilter sets the fieldSelector property of a Builder.
69+
func (b *Builder) WithFieldSelectorFilter(fieldSelectorFilter string) {
70+
b.internal.WithFieldSelectorFilter(fieldSelectorFilter)
71+
}
72+
6473
// WithSharding sets the shard and totalShards property of a Builder.
6574
func (b *Builder) WithSharding(shard int32, totalShards int) {
6675
b.internal.WithSharding(shard, totalShards)
@@ -103,8 +112,8 @@ func (b *Builder) WithAllowAnnotations(annotations map[string][]string) {
103112
}
104113

105114
// WithAllowLabels configures which labels can be returned for metrics
106-
func (b *Builder) WithAllowLabels(l map[string][]string) {
107-
b.internal.WithAllowLabels(l)
115+
func (b *Builder) WithAllowLabels(l map[string][]string) error {
116+
return b.internal.WithAllowLabels(l)
108117
}
109118

110119
// WithGenerateStoresFunc configures a custom generate store function

0 commit comments

Comments
 (0)