diff --git a/src/go/pt-k8s-debug-collector/main.go b/src/go/pt-k8s-debug-collector/main.go index c19a5e012..5bf16908a 100644 --- a/src/go/pt-k8s-debug-collector/main.go +++ b/src/go/pt-k8s-debug-collector/main.go @@ -10,7 +10,7 @@ import ( ) const ( - TOOLNAME = "pt-k8s-debug-collector" + toolname = "pt-k8s-debug-collector" ) // We do not set anything here, these variables are defined by the Makefile @@ -38,7 +38,7 @@ func main() { flag.Parse() if version { - fmt.Println(TOOLNAME) + fmt.Println(toolname) fmt.Printf("Version %s\n", Version) fmt.Printf("Build: %s using %s\n", Build, GoVersion) fmt.Printf("Commit: %s\n", Commit) diff --git a/src/go/pt-k8s-debug-collector/main_test.go b/src/go/pt-k8s-debug-collector/main_test.go index 6faa718ce..a1122593d 100644 --- a/src/go/pt-k8s-debug-collector/main_test.go +++ b/src/go/pt-k8s-debug-collector/main_test.go @@ -164,14 +164,14 @@ func TestResourceOption(t *testing.T) { Option --version */ func TestVersionOption(t *testing.T) { - out, err := exec.Command("../../../bin/"+TOOLNAME, "--version").Output() + out, err := exec.Command("../../../bin/"+toolname, "--version").Output() if err != nil { - t.Errorf("error executing %s --version: %s", TOOLNAME, err.Error()) + t.Errorf("error executing %s --version: %s", toolname, err.Error()) } // We are using MustCompile here, because hard-coded RE should not fail - re := regexp.MustCompile(TOOLNAME + `\n.*Version v?\d+\.\d+\.\d+\n`) + re := regexp.MustCompile(toolname + `\n.*Version v?\d+\.\d+\.\d+\n`) if !re.Match(out) { - t.Errorf("%s --version returns wrong result:\n%s", TOOLNAME, out) + t.Errorf("%s --version returns wrong result:\n%s", toolname, out) } } diff --git a/src/go/pt-mongodb-index-check/main.go b/src/go/pt-mongodb-index-check/main.go index 9cd722fb8..06de6bb78 100644 --- a/src/go/pt-mongodb-index-check/main.go +++ b/src/go/pt-mongodb-index-check/main.go @@ -42,7 +42,7 @@ type response struct { } const ( - TOOLNAME = "pt-mongodb-index-check" + toolname = "pt-mongodb-index-check" ) // We do not set anything here, these variables are defined by the Makefile @@ -58,7 +58,7 @@ func main() { kongctx := kong.Parse(&args, kong.UsageOnError()) if kongctx.Command() == "version" { - fmt.Println(TOOLNAME) + fmt.Println(toolname) fmt.Printf("Version %s\n", Version) fmt.Printf("Build: %s using %s\n", Build, GoVersion) fmt.Printf("Commit: %s\n", Commit) diff --git a/src/go/pt-mongodb-query-digest/main.go b/src/go/pt-mongodb-query-digest/main.go index 5e02bdce4..52158703f 100644 --- a/src/go/pt-mongodb-query-digest/main.go +++ b/src/go/pt-mongodb-query-digest/main.go @@ -30,7 +30,7 @@ import ( ) const ( - TOOLNAME = "pt-mongodb-query-digest" + toolname = "pt-mongodb-query-digest" DEFAULT_AUTHDB = "admin" DEFAULT_HOST = "localhost:27017" @@ -90,16 +90,16 @@ func main() { log.SetLevel(logLevel) if opts.Version { - fmt.Println(TOOLNAME) + fmt.Println(toolname) fmt.Printf("Version %s\n", Version) fmt.Printf("Build: %s using %s\n", Build, GoVersion) fmt.Printf("Commit: %s\n", Commit) return } - conf := config.DefaultConfig(TOOLNAME) + conf := config.DefaultConfig(toolname) if !conf.GetBool("no-version-check") && !opts.NoVersionCheck { - advice, err := versioncheck.CheckUpdates(TOOLNAME, Version) + advice, err := versioncheck.CheckUpdates(toolname, Version) if err != nil { log.Infof("cannot check version updates: %s", err.Error()) } else if advice != "" { @@ -361,7 +361,7 @@ func getClientOptions(opts *cliOptions) (*options.ClientOptions, error) { func getHeaders(opts *cliOptions) []string { h := []string{ - fmt.Sprintf("%s - %s\n", TOOLNAME, time.Now().Format(time.RFC1123Z)), + fmt.Sprintf("%s - %s\n", toolname, time.Now().Format(time.RFC1123Z)), fmt.Sprintf("Host: %s\n", opts.Host), fmt.Sprintf("Skipping profiled queries on these collections: %v\n", opts.SkipCollections), } diff --git a/src/go/pt-mongodb-query-digest/main_test.go b/src/go/pt-mongodb-query-digest/main_test.go index acce83926..8b8b973d4 100644 --- a/src/go/pt-mongodb-query-digest/main_test.go +++ b/src/go/pt-mongodb-query-digest/main_test.go @@ -106,7 +106,7 @@ func TestParseArgs(t *testing.T) { want *cliOptions }{ { - args: []string{TOOLNAME}, // arg[0] is the command itself + args: []string{toolname}, // arg[0] is the command itself want: &cliOptions{ Host: "mongodb://" + DEFAULT_HOST, LogLevel: DEFAULT_LOGLEVEL, @@ -117,11 +117,11 @@ func TestParseArgs(t *testing.T) { }, }, { - args: []string{TOOLNAME, "zapp.brannigan.net:27018/samples", "--help"}, + args: []string{toolname, "zapp.brannigan.net:27018/samples", "--help"}, want: nil, }, { - args: []string{TOOLNAME, "zapp.brannigan.net:27018/samples"}, + args: []string{toolname, "zapp.brannigan.net:27018/samples"}, want: &cliOptions{ Host: "mongodb://zapp.brannigan.net:27018/samples", LogLevel: DEFAULT_LOGLEVEL, diff --git a/src/go/pt-mongodb-summary/main.go b/src/go/pt-mongodb-summary/main.go index 2c8349d28..7f23a1962 100644 --- a/src/go/pt-mongodb-summary/main.go +++ b/src/go/pt-mongodb-summary/main.go @@ -35,7 +35,7 @@ import ( ) const ( - TOOLNAME = "pt-mongodb-summary" + toolname = "pt-mongodb-summary" DefaultAuthDB = "admin" DefaultHost = "mongodb://localhost:27017" @@ -194,7 +194,7 @@ func main() { log.SetLevel(logLevel) if opts.Version { - fmt.Println(TOOLNAME) + fmt.Println(toolname) fmt.Printf("Version %s\n", Version) fmt.Printf("Build: %s using %s\n", Build, GoVersion) fmt.Printf("Commit: %s\n", Commit) @@ -202,9 +202,9 @@ func main() { return } - conf := config.DefaultConfig(TOOLNAME) + conf := config.DefaultConfig(toolname) if !conf.GetBool("no-version-check") && !opts.NoVersionCheck { - advice, err := versioncheck.CheckUpdates(TOOLNAME, Version) + advice, err := versioncheck.CheckUpdates(toolname, Version) if err != nil { log.Infof("cannot check version updates: %s", err.Error()) } else if advice != "" { diff --git a/src/go/pt-mongodb-summary/main_test.go b/src/go/pt-mongodb-summary/main_test.go index 9fce19da5..57f7196d4 100644 --- a/src/go/pt-mongodb-summary/main_test.go +++ b/src/go/pt-mongodb-summary/main_test.go @@ -101,7 +101,7 @@ func TestParseArgs(t *testing.T) { want *cliOptions }{ { - args: []string{TOOLNAME}, // arg[0] is the command itself + args: []string{toolname}, // arg[0] is the command itself want: &cliOptions{ Host: DefaultHost, LogLevel: DefaultLogLevel, @@ -112,7 +112,7 @@ func TestParseArgs(t *testing.T) { }, }, { - args: []string{TOOLNAME, "zapp.brannigan.net:27018/samples", "--help"}, + args: []string{toolname, "zapp.brannigan.net:27018/samples", "--help"}, want: nil, }, } diff --git a/src/go/pt-pg-summary/main.go b/src/go/pt-pg-summary/main.go index 0d0589e8b..c77d8ab5f 100644 --- a/src/go/pt-pg-summary/main.go +++ b/src/go/pt-pg-summary/main.go @@ -18,7 +18,7 @@ import ( ) const ( - TOOLNAME = "pt-pg-summary" + toolname = "pt-pg-summary" ) // We do not set anything here, these variables are defined by the Makefile @@ -215,7 +215,7 @@ func safeConnString(opts connOpts, dbName string) string { } func parseCommandLineOpts(args []string) (cliOptions, error) { - app := kingpin.New(TOOLNAME, "Percona Toolkit - PostgreSQL Summary") + app := kingpin.New(toolname, "Percona Toolkit - PostgreSQL Summary") app.UsageWriter(os.Stdout) // version, commit and date will be set at build time by the compiler -ldflags param app.Version(fmt.Sprintf("%s\nVersion %s\nBuild: %s using %s\nCommit: %s", diff --git a/src/go/pt-pg-summary/main_test.go b/src/go/pt-pg-summary/main_test.go index a50bfba3f..5319ecd50 100644 --- a/src/go/pt-pg-summary/main_test.go +++ b/src/go/pt-pg-summary/main_test.go @@ -129,13 +129,13 @@ func TestCollectPerDatabaseInfo(t *testing.T) { Option --version */ func TestVersionOption(t *testing.T) { - out, err := exec.Command("../../../bin/"+TOOLNAME, "--version").Output() + out, err := exec.Command("../../../bin/"+toolname, "--version").Output() if err != nil { - t.Errorf("error executing %s --version: %s", TOOLNAME, err.Error()) + t.Errorf("error executing %s --version: %s", toolname, err.Error()) } // We are using MustCompile here, because hard-coded RE should not fail - re := regexp.MustCompile(TOOLNAME + `\n.*Version v?\d+\.\d+\.\d+\n`) + re := regexp.MustCompile(toolname + `\n.*Version v?\d+\.\d+\.\d+\n`) if !re.Match(out) { - t.Errorf("%s --version returns wrong result:\n%s", TOOLNAME, out) + t.Errorf("%s --version returns wrong result:\n%s", toolname, out) } } diff --git a/src/go/pt-secure-collect/main.go b/src/go/pt-secure-collect/main.go index 62ba4fbab..a9e526182 100644 --- a/src/go/pt-secure-collect/main.go +++ b/src/go/pt-secure-collect/main.go @@ -67,7 +67,7 @@ type myDefaults struct { } const ( - TOOLNAME = "pt-secure-collect" + toolname = "pt-secure-collect" decryptCmd = "decrypt" encryptCmd = "encrypt" @@ -172,7 +172,7 @@ func processCliParams(baseTempPath string, usageWriter io.Writer) (*cliOptions, } msg += "\n " - app := kingpin.New(TOOLNAME, msg) + app := kingpin.New(toolname, msg) if usageWriter != nil { app.UsageWriter(usageWriter) app.Terminate(nil) @@ -181,7 +181,7 @@ func processCliParams(baseTempPath string, usageWriter io.Writer) (*cliOptions, } // Add support for --version flag - app.Version(TOOLNAME + "\nVersion " + Version + "\nBuild: " + Build + " using " + GoVersion + + app.Version(toolname + "\nVersion " + Version + "\nBuild: " + Build + " using " + GoVersion + "\nCommit:" + Commit) opts := &cliOptions{ diff --git a/src/go/pt-secure-collect/main_test.go b/src/go/pt-secure-collect/main_test.go index 53746e314..b9390b2f8 100644 --- a/src/go/pt-secure-collect/main_test.go +++ b/src/go/pt-secure-collect/main_test.go @@ -45,13 +45,13 @@ func TestCollect(t *testing.T) { Option --version */ func TestVersionOption(t *testing.T) { - out, err := exec.Command("../../../bin/"+TOOLNAME, "--version").Output() + out, err := exec.Command("../../../bin/"+toolname, "--version").Output() if err != nil { - t.Errorf("error executing %s --version: %s", TOOLNAME, err.Error()) + t.Errorf("error executing %s --version: %s", toolname, err.Error()) } // We are using MustCompile here, because hard-coded RE should not fail - re := regexp.MustCompile(TOOLNAME + `\n.*Version v?\d+\.\d+\.\d+\n`) + re := regexp.MustCompile(toolname + `\n.*Version v?\d+\.\d+\.\d+\n`) if !re.Match(out) { - t.Errorf("%s --version returns wrong result:\n%s", TOOLNAME, out) + t.Errorf("%s --version returns wrong result:\n%s", toolname, out) } }