Skip to content

Commit

Permalink
Rename flag variable
Browse files Browse the repository at this point in the history
  • Loading branch information
neelayu committed Dec 10, 2024
1 parent f1d9d12 commit c885748
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 39 deletions.
38 changes: 19 additions & 19 deletions cmd/telegraf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,23 @@ func runApp(args []string, outputBuffer io.Writer, pprof Server, c TelegrafConfi
filters := processFilterFlags(cCtx)

g := GlobalFlags{
config: cCtx.StringSlice("config"),
configDir: cCtx.StringSlice("config-directory"),
testWait: cCtx.Int("test-wait"),
configURLRetryAttempts: cCtx.Int("config-url-retry-attempts"),
configURLWatchInterval: cCtx.Duration("config-url-watch-interval"),
watchConfig: cCtx.String("watch-config"),
watchInterval: cCtx.Duration("watch-interval"),
pidFile: cCtx.String("pidfile"),
plugindDir: cCtx.String("plugin-directory"),
password: cCtx.String("password"),
oldEnvBehavior: cCtx.Bool("old-env-behavior"),
newPluginPrintBehavior: cCtx.Bool("new-plugin-print-behavior"),
test: cCtx.Bool("test"),
debug: cCtx.Bool("debug"),
once: cCtx.Bool("once"),
quiet: cCtx.Bool("quiet"),
unprotected: cCtx.Bool("unprotected"),
config: cCtx.StringSlice("config"),
configDir: cCtx.StringSlice("config-directory"),
testWait: cCtx.Int("test-wait"),
configURLRetryAttempts: cCtx.Int("config-url-retry-attempts"),
configURLWatchInterval: cCtx.Duration("config-url-watch-interval"),
watchConfig: cCtx.String("watch-config"),
watchInterval: cCtx.Duration("watch-interval"),
pidFile: cCtx.String("pidfile"),
plugindDir: cCtx.String("plugin-directory"),
password: cCtx.String("password"),
oldEnvBehavior: cCtx.Bool("old-env-behavior"),
printPluginConfigSource: cCtx.Bool("print-plugin-config-source"),
test: cCtx.Bool("test"),
debug: cCtx.Bool("debug"),
once: cCtx.Bool("once"),
quiet: cCtx.Bool("quiet"),
unprotected: cCtx.Bool("unprotected"),
}

w := WindowFlags{
Expand Down Expand Up @@ -310,8 +310,8 @@ func runApp(args []string, outputBuffer io.Writer, pprof Server, c TelegrafConfi
Usage: "switch back to pre v1.27 environment replacement behavior",
},
&cli.BoolFlag{
Name: "new-plugin-print-behavior",
Usage: "switch to the new plugin print behavior",
Name: "print-plugin-config-source",
Usage: "print the source for a given plugin",
},
&cli.BoolFlag{
Name: "once",
Expand Down
36 changes: 18 additions & 18 deletions cmd/telegraf/telegraf.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ import (
var stop chan struct{}

type GlobalFlags struct {
config []string
configDir []string
testWait int
configURLRetryAttempts int
configURLWatchInterval time.Duration
watchConfig string
watchInterval time.Duration
pidFile string
plugindDir string
password string
oldEnvBehavior bool
newPluginPrintBehavior bool
test bool
debug bool
once bool
quiet bool
unprotected bool
config []string
configDir []string
testWait int
configURLRetryAttempts int
configURLWatchInterval time.Duration
watchConfig string
watchInterval time.Duration
pidFile string
plugindDir string
password string
oldEnvBehavior bool
printPluginConfigSource bool
test bool
debug bool
once bool
quiet bool
unprotected bool
}

type WindowFlags struct {
Expand Down Expand Up @@ -107,7 +107,7 @@ func (t *Telegraf) Init(pprofErr <-chan error, f Filters, g GlobalFlags, w Windo
// Set environment replacement behavior
config.OldEnvVarReplacement = g.oldEnvBehavior

config.NewPluginPrintBehaviour = g.newPluginPrintBehavior
config.PrintPluginConfigSource = g.printPluginConfigSource
}

func (t *Telegraf) ListSecretStores() ([]string, error) {
Expand Down
5 changes: 3 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ var (
// environment variable replacement behavior
OldEnvVarReplacement = false

NewPluginPrintBehaviour = false
// PrintPluginConfigSource is a switch to enable printing of plugin sources
PrintPluginConfigSource = false

// Password specified via command-line
Password Secret
Expand Down Expand Up @@ -307,7 +308,7 @@ type AgentConfig struct {
// based on the NewPluginPrintBehaviour flag
func getPluginPrintString(plugins pluginNames) string {
output := PluginNameCounts(plugins)
if NewPluginPrintBehaviour {
if PrintPluginConfigSource {
return output + plugins.String()
}

Expand Down

0 comments on commit c885748

Please sign in to comment.