apple / foundationdb

FoundationDB - the open source, distributed, transactional key-value store
https://apple.github.io/foundationdb/
Apache License 2.0
14.18k stars 1.29k forks source link

Add a mechanism to allow to specifiy the command line flags over env variables #11462

Closed johscheuer closed 2 weeks ago

johscheuer commented 2 weeks ago

Made some tests locally:

$ ./fdbkubernetesmonitor
{"level":"info","ts":1718374909.7578251,"msg":"should enable pprof","enable-pprof":false}

$ ENABLE_PPROF=true ./fdbkubernetesmonitor
{"level":"info","ts":1718374917.926634,"msg":"should enable pprof","enable-pprof":true}

$ ENABLE_PPROF=falsee ./fdbkubernetesmonitor
panic: strconv.ParseBool: parsing "falsee": invalid syntax

goroutine 1 [running]:
main.main()
        /Users/jscheuermann/workspace/apple/foundationdb/fdbkubernetesmonitor/main.go:130 +0xd08

$ ENABLE_PPROF=false ./fdbkubernetesmonitor
{"level":"info","ts":1718374929.785943,"msg":"should enable pprof","enable-pprof":false}

$ ENABLE_PPROF="false" ./fdbkubernetesmonitor
{"level":"info","ts":1718374937.487411,"msg":"should enable pprof","enable-pprof":false}

$ ENABLE_PPROF="false" ./fdbkubernetesmonitor --enable-pprof
{"level":"info","ts":1718374991.660543,"msg":"should enable pprof","enable-pprof":true}

Those changes allow to specify the value for a command line flag as env variable with the same name.

Code-Reviewer Section

The general pull request guidelines can be found here.

Please check each of the following things and check all boxes before accepting a PR.

For Release-Branches

If this PR is made against a release-branch, please also check the following:

foundationdb-ci commented 2 weeks ago

Result of foundationdb-pr-clang-ide on Linux CentOS 7

foundationdb-ci commented 2 weeks ago

Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x

foundationdb-ci commented 2 weeks ago

Result of foundationdb-pr-macos on macOS Ventura 13.x

foundationdb-ci commented 2 weeks ago

Result of foundationdb-pr-clang on Linux CentOS 7

foundationdb-ci commented 2 weeks ago

Result of foundationdb-pr-clang-arm on Linux CentOS 7

foundationdb-ci commented 2 weeks ago

Result of foundationdb-pr-cluster-tests on Linux CentOS 7

foundationdb-ci commented 2 weeks ago

Result of foundationdb-pr on Linux CentOS 7