Skip to content

Commit

Permalink
parse flags before reading configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
sanposhiho committed Oct 4, 2023
1 parent 70701ce commit 3e9d7a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,19 @@ func main() {
// Tortoise specific flags
var configPath string
flag.StringVar(&configPath, "config", "", "The path to the config file.")
config, err := config.ParseConfig(configPath)
if err != nil {
setupLog.Error(err, "failed to load config")
os.Exit(1)
}

opts := zap.Options{
Development: true,
}
opts.BindFlags(flag.CommandLine)
flag.Parse()

config, err := config.ParseConfig(configPath)
if err != nil {
setupLog.Error(err, "failed to load config")
os.Exit(1)
}

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/testdata/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RangeOfMinMaxReplicasRecommendationHours: 2
MinMaxReplicasRecommendationType: "daily"
MinMaxReplicasRecommendationType: "daily"
TTLHoursOfMinMaxReplicasRecommendation: 720
MaxReplicasFactor: 2.0
MinReplicasFactor: 0.5
Expand Down

0 comments on commit 3e9d7a4

Please sign in to comment.