zitadel/cmd/start/flags.go
David Schneider ffdde825ec
fix(backend): respect start flags in all commands (#6621)
* fix(backend): respect start flags in all commands

Currently flags like --externalDomain do only work in the last
registered command which currently is start-from-setup.
This creates the flags globally in the init function in uses them for
all start commands.

* fix(backend): remove viper defaults in start flags

At this point viper is not yet initialized so this defaults would have
not effect either.

* Remove flag name variables and run go mod tidy

---------

Co-authored-by: Tim Möhlmann <tim+github@zitadel.com>
2024-02-21 12:26:51 +00:00

33 lines
693 B
Go

package start
import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"github.com/zitadel/logging"
"github.com/zitadel/zitadel/cmd/key"
"github.com/zitadel/zitadel/cmd/tls"
)
var (
startFlagSet = &pflag.FlagSet{}
)
func init() {
startFlagSet.Uint16("port", 0, "port to run ZITADEL on")
startFlagSet.String("externalDomain", "", "domain ZITADEL will be exposed on")
startFlagSet.String("externalPort", "", "port ZITADEL will be exposed on")
}
func startFlags(cmd *cobra.Command) {
cmd.Flags().AddFlagSet(startFlagSet)
logging.OnError(
viper.BindPFlags(startFlagSet),
).Fatal("start flags")
tls.AddTLSModeFlag(cmd)
key.AddMasterKeyFlag(cmd)
}