diff --git a/go/mysql/auth_server_clientcert.go b/go/mysql/auth_server_clientcert.go index 4b574e96ef3..f9dcd22ee88 100644 --- a/go/mysql/auth_server_clientcert.go +++ b/go/mysql/auth_server_clientcert.go @@ -24,7 +24,7 @@ import ( "github.com/dolthub/vitess/go/vt/log" ) -var clientcertAuthMethod = flag.String("mysql_clientcert_auth_method", MysqlClearPassword, "client-side authentication method to use. Supported values: mysql_clear_password, dialog.") +var clientcertAuthMethod = MysqlClearPassword type AuthServerClientCert struct { Method string @@ -36,11 +36,11 @@ func InitAuthServerClientCert() { log.Info("Not configuring AuthServerClientCert because mysql_server_ssl_ca is empty") return } - if *clientcertAuthMethod != MysqlClearPassword && *clientcertAuthMethod != MysqlDialog { + if clientcertAuthMethod != MysqlClearPassword && clientcertAuthMethod != MysqlDialog { log.Fatalf("Invalid mysql_clientcert_auth_method value: only support mysql_clear_password or dialog") } ascc := &AuthServerClientCert{ - Method: *clientcertAuthMethod, + Method: clientcertAuthMethod, } RegisterAuthServerImpl("clientcert", ascc) } diff --git a/go/mysql/auth_server_static.go b/go/mysql/auth_server_static.go index 2b43bc1a1ad..760a75c5d69 100644 --- a/go/mysql/auth_server_static.go +++ b/go/mysql/auth_server_static.go @@ -19,7 +19,6 @@ package mysql import ( "bytes" "encoding/json" - "flag" "net" "os" "os/signal" @@ -34,9 +33,9 @@ import ( ) var ( - mysqlAuthServerStaticFile = flag.String("mysql_auth_server_static_file", "", "JSON File to read the users/passwords from.") - mysqlAuthServerStaticString = flag.String("mysql_auth_server_static_string", "", "JSON representation of the users/passwords config.") - mysqlAuthServerStaticReloadInterval = flag.Duration("mysql_auth_static_reload_interval", 0, "Ticker to reload credentials") + mysqlAuthServerStaticFile string = "" + mysqlAuthServerStaticString string = "" + mysqlAuthServerStaticReloadInterval time.Duration = 0 ) const ( @@ -89,18 +88,18 @@ type AuthServerStaticEntry struct { // InitAuthServerStatic Handles initializing the AuthServerStatic if necessary. func InitAuthServerStatic() { // Check parameters. - if *mysqlAuthServerStaticFile == "" && *mysqlAuthServerStaticString == "" { + if mysqlAuthServerStaticFile == "" && mysqlAuthServerStaticString == "" { // Not configured, nothing to do. log.Infof("Not configuring AuthServerStatic, as mysql_auth_server_static_file and mysql_auth_server_static_string are empty") return } - if *mysqlAuthServerStaticFile != "" && *mysqlAuthServerStaticString != "" { + if mysqlAuthServerStaticFile != "" && mysqlAuthServerStaticString != "" { // Both parameters specified, can only use one. log.Fatalf("Both mysql_auth_server_static_file and mysql_auth_server_static_string specified, can only use one.") } // Create and register auth server. - RegisterAuthServerStaticFromParams(*mysqlAuthServerStaticFile, *mysqlAuthServerStaticString, *mysqlAuthServerStaticReloadInterval) + RegisterAuthServerStaticFromParams(mysqlAuthServerStaticFile, mysqlAuthServerStaticString, mysqlAuthServerStaticReloadInterval) } // NewAuthServerStatic returns a new AuthServerStatic, reading from |file| or diff --git a/go/mysql/auth_server_static_test.go b/go/mysql/auth_server_static_test.go index cadcc5686eb..16b263b1e73 100644 --- a/go/mysql/auth_server_static_test.go +++ b/go/mysql/auth_server_static_test.go @@ -155,11 +155,11 @@ func TestStaticConfigHUPWithRotation(t *testing.T) { t.Fatalf("couldn't create temp file: %v", err) } defer os.Remove(tmpFile.Name()) - *mysqlAuthServerStaticFile = tmpFile.Name() + mysqlAuthServerStaticFile = tmpFile.Name() - savedReloadInterval := *mysqlAuthServerStaticReloadInterval - defer func() { *mysqlAuthServerStaticReloadInterval = savedReloadInterval }() - *mysqlAuthServerStaticReloadInterval = 10 * time.Millisecond + savedReloadInterval := mysqlAuthServerStaticReloadInterval + defer func() { mysqlAuthServerStaticReloadInterval = savedReloadInterval }() + mysqlAuthServerStaticReloadInterval = 10 * time.Millisecond oldStr := "str1" jsonConfig := fmt.Sprintf("{\"%s\":[{\"Password\":\"%s\"}]}", oldStr, oldStr) diff --git a/go/mysql/query_benchmark_test.go b/go/mysql/query_benchmark_test.go index e2ea8ac9a38..556b368fab6 100644 --- a/go/mysql/query_benchmark_test.go +++ b/go/mysql/query_benchmark_test.go @@ -18,7 +18,6 @@ package mysql import ( "context" - "flag" "math/rand" "net" "strings" @@ -27,10 +26,6 @@ import ( var testReadConnBufferSize = DefaultConnBufferSize -func init() { - flag.IntVar(&testReadConnBufferSize, "test.read_conn_buffer_size", DefaultConnBufferSize, "buffer size for reads from connections in tests") -} - const benchmarkQueryPrefix = "benchmark " func benchmarkQuery(b *testing.B, threads int, query string) { diff --git a/go/stats/export.go b/go/stats/export.go index 508663207ed..a8c8a1c987e 100644 --- a/go/stats/export.go +++ b/go/stats/export.go @@ -30,7 +30,6 @@ package stats import ( "bytes" "expvar" - "flag" "fmt" "strconv" "sync" @@ -39,9 +38,9 @@ import ( "github.com/dolthub/vitess/go/vt/log" ) -var emitStats = flag.Bool("emit_stats", false, "true iff we should emit stats to push-based monitoring/stats backends") -var statsEmitPeriod = flag.Duration("stats_emit_period", time.Duration(60*time.Second), "Interval between emitting stats to all registered backends") -var statsBackend = flag.String("stats_backend", "", "The name of the registered push-based monitoring/stats backend to use") +var emitStats = false +var statsEmitPeriod = time.Duration(60 * time.Second) +var statsBackend = "" // NewVarHook is the type of a hook to export variables in a different way type NewVarHook func(name string, v expvar.Var) @@ -122,7 +121,7 @@ func RegisterPushBackend(name string, backend PushBackend) { log.Fatalf("PushBackend %s already exists; can't register the same name multiple times", name) } pushBackends[name] = backend - if *emitStats { + if emitStats { // Start a single goroutine to emit stats periodically once.Do(func() { go emitToBackend(statsEmitPeriod) @@ -132,19 +131,19 @@ func RegisterPushBackend(name string, backend PushBackend) { // emitToBackend does a periodic emit to the selected PushBackend. If a push fails, // it will be logged as a warning (but things will otherwise proceed as normal). -func emitToBackend(emitPeriod *time.Duration) { - ticker := time.NewTicker(*emitPeriod) +func emitToBackend(emitPeriod time.Duration) { + ticker := time.NewTicker(emitPeriod) defer ticker.Stop() for range ticker.C { - backend, ok := pushBackends[*statsBackend] + backend, ok := pushBackends[statsBackend] if !ok { - log.Errorf("No PushBackend registered with name %s", *statsBackend) + log.Errorf("No PushBackend registered with name %s", statsBackend) return } err := backend.PushAll() if err != nil { // TODO(aaijazi): This might cause log spam... - log.Warningf("Pushing stats to backend %v failed: %v", *statsBackend, err) + log.Warningf("Pushing stats to backend %v failed: %v", statsBackend, err) } } } diff --git a/go/vt/sqlparser/truncate_query.go b/go/vt/sqlparser/truncate_query.go index a441c812aed..8b86ccb0dd4 100644 --- a/go/vt/sqlparser/truncate_query.go +++ b/go/vt/sqlparser/truncate_query.go @@ -16,16 +16,12 @@ limitations under the License. package sqlparser -import ( - "flag" -) - var ( // TruncateUILen truncate queries in debug UIs to the given length. 0 means unlimited. - TruncateUILen = flag.Int("sql-max-length-ui", 512, "truncate queries in debug UIs to the given length (default 512)") + TruncateUILen = 512 // TruncateErrLen truncate queries in error logs to the given length. 0 means unlimited. - TruncateErrLen = flag.Int("sql-max-length-errors", 0, "truncate queries in error logs to the given length (default unlimited)") + TruncateErrLen = 0 ) func truncateQuery(query string, max int) string { @@ -41,12 +37,12 @@ func truncateQuery(query string, max int) string { // TruncateForUI is used when displaying queries on various Vitess status pages // to keep the pages small enough to load and render properly func TruncateForUI(query string) string { - return truncateQuery(query, *TruncateUILen) + return truncateQuery(query, TruncateUILen) } // TruncateForLog is used when displaying queries as part of error logs // to avoid overwhelming logging systems with potentially long queries and // bind value data. func TruncateForLog(query string) string { - return truncateQuery(query, *TruncateErrLen) + return truncateQuery(query, TruncateErrLen) } diff --git a/go/vt/vterrors/vterrors.go b/go/vt/vterrors/vterrors.go index 59d82183534..4977b551208 100644 --- a/go/vt/vterrors/vterrors.go +++ b/go/vt/vterrors/vterrors.go @@ -87,7 +87,6 @@ package vterrors import ( "context" - "flag" "fmt" "io" @@ -98,10 +97,6 @@ import ( // embedded stack trace in the output. var LogErrStacks bool -func init() { - flag.BoolVar(&LogErrStacks, "log_err_stacks", false, "log stack traces for errors") -} - // New returns an error with the supplied message. // New also records the stack trace at the point it was called. func New(code vtrpcpb.Code, message string) error {