Skip to content

Commit

Permalink
enable the watcher via config - default to false
Browse files Browse the repository at this point in the history
Signed-off-by: ed kim <[email protected]>
  • Loading branch information
edify42 committed Sep 9, 2021
1 parent 3e7d940 commit 97528a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ func main() {

ctrl := controller.NewController(cfg)

go ctrl.Watch(stopChan)
if cfg.EnableWatcher {
go ctrl.Watch(stopChan)
}
ctrl.Run(stopChan)
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Config struct {
MetricsListenAddress string
Provider string
LabelSelector string
EnableWatcher bool
}

func DefaultConfig() *Config {
Expand All @@ -53,6 +54,7 @@ func DefaultConfig() *Config {
MetricsListenAddress: "0.0.0.0:9999",
Provider: "aws",
LabelSelector: "",
EnableWatcher: false,
}
return cfg
}
Expand Down Expand Up @@ -87,6 +89,8 @@ func (cfg *Config) ParseFlags() error {
"Label selector for secrets to fetch from k8s API",
)

enableWatcher := flag.Bool("watch", false, "Turn on watcher which listens for k8s API events as well as polling")

flag.Parse()

i, err := strconv.Atoi(*interval)
Expand All @@ -102,6 +106,7 @@ func (cfg *Config) ParseFlags() error {
cfg.MetricsListenAddress = *metricAddr
cfg.Provider = "aws"
cfg.LabelSelector = *labelSelector
cfg.EnableWatcher = *enableWatcher

logLevel, err := log.ParseLevel(*logLevelStr)
if err != nil {
Expand Down

0 comments on commit 97528a1

Please sign in to comment.