Skip to content

Commit

Permalink
Merge pull request #1994 from clamoriniere/fix-builder-interface
Browse files Browse the repository at this point in the history
fix: public Builder compatibility with the BuilderInterface
  • Loading branch information
k8s-ci-robot authored Feb 16, 2023
2 parents 1acb4df + bcfef5a commit da10923
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import (
"k8s.io/kube-state-metrics/v2/pkg/options"
)

// Make sure the public Builder implements the public BuilderInterface.
// New internal Builder methods should be added to the public BuilderInterface.
var _ ksmtypes.BuilderInterface = &Builder{}

// Builder helps to build store. It follows the builder pattern
// (https://en.wikipedia.org/wiki/Builder_pattern).
type Builder struct {
Expand Down Expand Up @@ -61,6 +65,11 @@ func (b *Builder) WithNamespaces(n options.NamespaceList) {
b.internal.WithNamespaces(n)
}

// WithFieldSelectorFilter sets the fieldSelector property of a Builder.
func (b *Builder) WithFieldSelectorFilter(fieldSelectorFilter string) {
b.internal.WithFieldSelectorFilter(fieldSelectorFilter)
}

// WithSharding sets the shard and totalShards property of a Builder.
func (b *Builder) WithSharding(shard int32, totalShards int) {
b.internal.WithSharding(shard, totalShards)
Expand Down Expand Up @@ -103,8 +112,8 @@ func (b *Builder) WithAllowAnnotations(annotations map[string][]string) {
}

// WithAllowLabels configures which labels can be returned for metrics
func (b *Builder) WithAllowLabels(l map[string][]string) {
b.internal.WithAllowLabels(l)
func (b *Builder) WithAllowLabels(l map[string][]string) error {
return b.internal.WithAllowLabels(l)
}

// WithGenerateStoresFunc configures a custom generate store function
Expand Down

0 comments on commit da10923

Please sign in to comment.