Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Drop setFlags from options parsing #830

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions pkg/operator/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"flag"
"fmt"
"os"
"strings"
"time"

"github.com/samber/lo"
Expand Down Expand Up @@ -59,8 +58,6 @@ type Options struct {
BatchMaxDuration time.Duration
BatchIdleDuration time.Duration
FeatureGates FeatureGates

setFlags map[string]bool
}

type FlagSet struct {
Expand Down Expand Up @@ -114,19 +111,6 @@ func (o *Options) Parse(fs *FlagSet, args ...string) error {
return fmt.Errorf("parsing feature gates, %w", err)
}
o.FeatureGates = gates

o.setFlags = map[string]bool{}
fs.VisitAll(func(f *flag.Flag) {
// NOTE: This assumes all CLI flags can be transformed into their corresponding environment variable. If a cli
// flag / env var pair does not follow this pattern, this will break.
envName := strings.ReplaceAll(strings.ToUpper(f.Name), "-", "_")
_, ok := os.LookupEnv(envName)
o.setFlags[f.Name] = ok
})
fs.Visit(func(f *flag.Flag) {
o.setFlags[f.Name] = true
})

return nil
}

Expand Down