From eb1cc304cf8d725ed855c90a6fa6927df35c1b38 Mon Sep 17 00:00:00 2001 From: Mahesh Arumugam Date: Fri, 9 Jul 2021 14:52:40 -0700 Subject: [PATCH] FeatureBase Renaming: EnvPrefix --- cmd/root.go | 10 ++++++++-- ctl/server.go | 10 +++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 1048eeb1f..2fd1a333c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -40,7 +40,7 @@ at https://www.pilosa.com/docs/. ` + pilosa.VersionInfo() + "\n", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { v := viper.New() - err := setAllConfig(v, cmd.Flags(), "PILOSA") + err := setAllConfig(v, cmd.Flags()) if err != nil { return err } @@ -90,13 +90,19 @@ at https://www.pilosa.com/docs/. // setAllConfig looks for environment variables which are capitalized versions // of the flag names with dashes replaced by underscores, and prefixed with // envPrefix plus an underscore. -func setAllConfig(v *viper.Viper, flags *pflag.FlagSet, envPrefix string) error { // nolint: unparam +func setAllConfig(v *viper.Viper, flags *pflag.FlagSet) error { // nolint: unparam // add cmd line flag def to viper err := v.BindPFlags(flags) if err != nil { return err } + envPrefix := "PILOSA" + rename := v.GetBool("future.rename") + if rename { + envPrefix = "FEATUREBASE" + } + // add env to viper v.SetEnvPrefix(envPrefix) v.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_")) diff --git a/ctl/server.go b/ctl/server.go index 1f5ec514f..552d5d1c4 100644 --- a/ctl/server.go +++ b/ctl/server.go @@ -27,16 +27,16 @@ import ( func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { flags := cmd.Flags() flags.StringVar(&srv.Config.Name, "name", srv.Config.Name, "Name of the node in the cluster.") - flags.StringVarP(&srv.Config.DataDir, "data-dir", "d", srv.Config.DataDir, "Directory to store pilosa data files.") - flags.StringVarP(&srv.Config.Bind, "bind", "b", srv.Config.Bind, "Default URI on which pilosa should listen.") - flags.StringVar(&srv.Config.BindGRPC, "bind-grpc", srv.Config.BindGRPC, "URI on which pilosa should listen for gRPC requests.") + flags.StringVarP(&srv.Config.DataDir, "data-dir", "d", srv.Config.DataDir, "Directory to store FeatureBase data files.") + flags.StringVarP(&srv.Config.Bind, "bind", "b", srv.Config.Bind, "Default URI on which FeatureBase should listen.") + flags.StringVar(&srv.Config.BindGRPC, "bind-grpc", srv.Config.BindGRPC, "URI on which FeatureBase should listen for gRPC requests.") flags.StringVar(&srv.Config.Advertise, "advertise", srv.Config.Advertise, "Address to advertise externally.") flags.StringVar(&srv.Config.AdvertiseGRPC, "advertise-grpc", srv.Config.AdvertiseGRPC, "Address to advertise externally for gRPC.") flags.IntVar(&srv.Config.MaxWritesPerRequest, "max-writes-per-request", srv.Config.MaxWritesPerRequest, "Number of write commands per request.") flags.StringVar(&srv.Config.LogPath, "log-path", srv.Config.LogPath, "Log path") flags.BoolVar(&srv.Config.Verbose, "verbose", srv.Config.Verbose, "Enable verbose logging") - flags.Uint64Var(&srv.Config.MaxMapCount, "max-map-count", srv.Config.MaxMapCount, "Limits the maximum number of active mmaps. Pilosa will fall back to reading files once this is exhausted. Set below your system's vm.max_map_count.") - flags.Uint64Var(&srv.Config.MaxFileCount, "max-file-count", srv.Config.MaxFileCount, "Soft limit on the maximum number of fragment files Pilosa keeps open simultaneously.") + flags.Uint64Var(&srv.Config.MaxMapCount, "max-map-count", srv.Config.MaxMapCount, "Limits the maximum number of active mmaps. FeatureBase will fall back to reading files once this is exhausted. Set below your system's vm.max_map_count.") + flags.Uint64Var(&srv.Config.MaxFileCount, "max-file-count", srv.Config.MaxFileCount, "Soft limit on the maximum number of fragment files FeatureBase keeps open simultaneously.") flags.DurationVar((*time.Duration)(&srv.Config.LongQueryTime), "long-query-time", time.Duration(srv.Config.LongQueryTime), "Duration that will trigger log and stat messages for slow queries. Zero to disable.") flags.IntVar(&srv.Config.QueryHistoryLength, "query-history-length", srv.Config.QueryHistoryLength, "Number of queries to remember in history.")