From b7f9ac76e6910ca55c5297e09ccd0fb9e37db4c5 Mon Sep 17 00:00:00 2001 From: devopsbo3 <69951731+devopsbo3@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:27:53 -0600 Subject: [PATCH] Revert "cmd/geth, internal/flags: print envvar config source and bad names (#28119)" This reverts commit c59e4a47dc845f6d3cf435618d5e8f1cba5aa0a7. --- cmd/geth/main.go | 6 +----- internal/flags/helpers.go | 36 ------------------------------------ 2 files changed, 1 insertion(+), 41 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index f6fa47ad2e..a1d148d805 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -249,11 +249,7 @@ func init() { app.Before = func(ctx *cli.Context) error { maxprocs.Set() // Automatically set GOMAXPROCS to match Linux container CPU quota. flags.MigrateGlobalFlags(ctx) - if err := debug.Setup(ctx); err != nil { - return err - } - flags.CheckEnvVars(ctx, app.Flags, "GETH") - return nil + return debug.Setup(ctx) } app.After = func(ctx *cli.Context) error { debug.Exit() diff --git a/internal/flags/helpers.go b/internal/flags/helpers.go index b97f96d59e..bdeb7e38e0 100644 --- a/internal/flags/helpers.go +++ b/internal/flags/helpers.go @@ -20,11 +20,9 @@ import ( "fmt" "os" "regexp" - "sort" "strings" "github.com/ethereum/go-ethereum/internal/version" - "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/mattn/go-isatty" "github.com/urfave/cli/v2" @@ -265,37 +263,3 @@ func AutoEnvVars(flags []cli.Flag, prefix string) { } } } - -// CheckEnvVars iterates over all the environment variables and checks if any of -// them look like a CLI flag but is not consumed. This can be used to detect old -// or mistyped names. -func CheckEnvVars(ctx *cli.Context, flags []cli.Flag, prefix string) { - known := make(map[string]string) - for _, flag := range flags { - docflag, ok := flag.(cli.DocGenerationFlag) - if !ok { - continue - } - for _, envvar := range docflag.GetEnvVars() { - known[envvar] = flag.Names()[0] - } - } - keyvals := os.Environ() - sort.Strings(keyvals) - - for _, keyval := range keyvals { - key := strings.Split(keyval, "=")[0] - if !strings.HasPrefix(key, prefix) { - continue - } - if flag, ok := known[key]; ok { - if ctx.Count(flag) > 0 { - log.Info("Config environment variable found", "envvar", key, "shadowedby", "--"+flag) - } else { - log.Info("Config environment variable found", "envvar", key) - } - } else { - log.Warn("Unknown config environment variable", "envvar", key) - } - } -}