Skip to content

Commit

Permalink
chore: Drop setFlags from options parsing (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis authored Nov 29, 2023
1 parent 56012c2 commit 79dc345
Showing 1 changed file with 0 additions and 16 deletions.
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

0 comments on commit 79dc345

Please sign in to comment.