@@ -2249,6 +2249,9 @@ func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp,
2249
2249
err error
2250
2250
)
2251
2251
2252
+ // IMPORTANT: If you add boolean flags and use a 'true' as the default,
2253
+ // check what needs to be done for FlagSnapshot down below.
2254
+ // See logtimeIsExplicitlySet for reference.
2252
2255
fs .BoolVar (& showHelp , "h" , false , "Show this message." )
2253
2256
fs .BoolVar (& showHelp , "help" , false , "Show this message." )
2254
2257
fs .IntVar (& opts .Port , "port" , 0 , "Port to listen on." )
@@ -2300,6 +2303,7 @@ func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp,
2300
2303
fs .StringVar (& opts .TLSCert , "tlscert" , "" , "Server certificate file." )
2301
2304
fs .StringVar (& opts .TLSKey , "tlskey" , "" , "Private key for server certificate." )
2302
2305
fs .StringVar (& opts .TLSCaCert , "tlscacert" , "" , "Client certificate CA for verification." )
2306
+ // --- See comment on top of flags definition before adding a flag ---
2303
2307
2304
2308
// The flags definition above set "default" values to some of the options.
2305
2309
// Calling Parse() here will override the default options with any value
@@ -2344,6 +2348,20 @@ func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp,
2344
2348
// Snapshot flag options.
2345
2349
FlagSnapshot = opts .Clone ()
2346
2350
2351
+ // Before parsing the config file, we need to know if boolean
2352
+ // flags are explicitly set or not, and for those which default
2353
+ // to `true`, we need to reset them otherwise config reload would
2354
+ // incorrectly override what is in the config file.
2355
+ logtimeIsExplicitlySet := false
2356
+ fs .Visit (func (f * flag.Flag ) {
2357
+ if f .Name == "logtime" {
2358
+ logtimeIsExplicitlySet = true
2359
+ }
2360
+ })
2361
+ if ! logtimeIsExplicitlySet {
2362
+ FlagSnapshot .Logtime = false
2363
+ }
2364
+
2347
2365
// Process signal control.
2348
2366
if signal != "" {
2349
2367
if err := processSignal (signal ); err != nil {
0 commit comments