diff --git a/pkg/cli/cert.go b/pkg/cli/cert.go index 24471aa94f2e..e41f9657685f 100644 --- a/pkg/cli/cert.go +++ b/pkg/cli/cert.go @@ -51,6 +51,7 @@ The certs directory is created if it does not exist. If the CA key exists and --allow-ca-key-reuse is true, the key is used. If the CA certificate exists and --overwrite is true, the new CA certificate is prepended to it. `, + Args: cobra.NoArgs, RunE: MaybeDecorateGRPCError(runCreateCACert), } @@ -84,6 +85,12 @@ Requires a CA cert in "/ca.crt" and matching key in "--ca-key". If "ca.crt" contains more than one certificate, the first is used. Creation fails if the CA expiration time is before the desired certificate expiration. `, + Args: func(cmd *cobra.Command, args []string) error { + if len(args) == 0 { + return errors.Errorf("create-node requires at least one host name or address, none was specified") + } + return nil + }, RunE: MaybeDecorateGRPCError(runCreateNodeCert), } @@ -119,6 +126,7 @@ Requires a CA cert in "/ca.crt" and matching key in "--ca-key". If "ca.crt" contains more than one certificate, the first is used. Creation fails if the CA expiration time is before the desired certificate expiration. `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runCreateClientCert), } @@ -127,10 +135,6 @@ Creation fails if the CA expiration time is before the desired certificate expir // TODO(marc): there is currently no way to specify which CA cert to use if more // than one if present. func runCreateClientCert(cmd *cobra.Command, args []string) error { - if len(args) != 1 { - return usageAndError(cmd) - } - var err error var username string if username, err = sql.NormalizeAndValidateUsername(args[0]); err != nil { @@ -156,15 +160,12 @@ var listCertsCmd = &cobra.Command{ Long: ` List certificates and keys found in the certificate directory. `, + Args: cobra.NoArgs, RunE: MaybeDecorateGRPCError(runListCerts), } // runListCerts loads and lists all certs. func runListCerts(cmd *cobra.Command, args []string) error { - if len(args) != 0 { - return usageAndError(cmd) - } - cm, err := baseCfg.GetCertificateManager() if err != nil { return errors.Wrap(err, "could not get certificate manager") diff --git a/pkg/cli/cli.go b/pkg/cli/cli.go index 9fb576ed54dd..33c311c005e5 100644 --- a/pkg/cli/cli.go +++ b/pkg/cli/cli.go @@ -81,6 +81,7 @@ var versionCmd = &cobra.Command{ Long: ` Output build version information. `, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { info := build.GetInfo() tw := tabwriter.NewWriter(os.Stdout, 2, 1, 2, ' ', 0) diff --git a/pkg/cli/cli_test.go b/pkg/cli/cli_test.go index 64c60c34df16..3b82116bb488 100644 --- a/pkg/cli/cli_test.go +++ b/pkg/cli/cli_test.go @@ -2061,17 +2061,19 @@ func TestJunkPositionalArguments(t *testing.T) { defer c.cleanup() for i, test := range []string{ - "start junk", - "sql junk", - "gen man junk", - "gen autocomplete junk", - "gen example-data intro junk", + "start", + "sql", + "gen man", + "gen autocomplete", + "gen example-data intro", } { - out, err := c.RunWithCapture(test) + const junk = "junk" + line := test + " " + junk + out, err := c.RunWithCapture(line) if err != nil { t.Fatal(errors.Wrap(err, strconv.Itoa(i))) } - exp := test + "\ninvalid arguments\n" + exp := fmt.Sprintf("%s\nunknown command %q for \"cockroach %s\"\n", line, junk, test) if exp != out { t.Errorf("expected:\n%s\ngot:\n%s", exp, out) } diff --git a/pkg/cli/debug.go b/pkg/cli/debug.go index 039049a4dab7..bfc62462c64c 100644 --- a/pkg/cli/debug.go +++ b/pkg/cli/debug.go @@ -60,6 +60,7 @@ var debugKeysCmd = &cobra.Command{ Long: ` Pretty-prints all keys in a store. `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runDebugKeys), } @@ -138,10 +139,6 @@ func runDebugKeys(cmd *cobra.Command, args []string) error { stopper := stop.NewStopper() defer stopper.Stop(context.Background()) - if len(args) != 1 { - return errors.New("one argument required: dir") - } - db, err := openExistingStore(args[0], stopper, true /* readOnly */) if err != nil { return err @@ -156,13 +153,14 @@ func runDebugKeys(cmd *cobra.Command, args []string) error { } var debugRangeDataCmd = &cobra.Command{ - Use: "range-data [directory] range-id", + Use: "range-data [directory] [range id]", Short: "dump all the data in a range", Long: ` Pretty-prints all keys and values in a range. By default, includes unreplicated state like the raft HardState. With --replicated, only includes data covered by the consistency checker. `, + Args: cobra.ExactArgs(2), RunE: MaybeDecorateGRPCError(runDebugRangeData), } @@ -170,10 +168,6 @@ func runDebugRangeData(cmd *cobra.Command, args []string) error { stopper := stop.NewStopper() defer stopper.Stop(context.Background()) - if len(args) != 2 { - return errors.New("two arguments required: dir range_id") - } - db, err := openExistingStore(args[0], stopper, true /* readOnly */) if err != nil { return err @@ -213,6 +207,7 @@ var debugRangeDescriptorsCmd = &cobra.Command{ Long: ` Prints all range descriptors in a store with a history of changes. `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runDebugRangeDescriptors), } @@ -424,10 +419,6 @@ func runDebugRangeDescriptors(cmd *cobra.Command, args []string) error { stopper := stop.NewStopper() defer stopper.Stop(context.Background()) - if len(args) != 1 { - return errors.New("one argument required: dir") - } - db, err := openExistingStore(args[0], stopper, true /* readOnly */) if err != nil { return err @@ -448,6 +439,7 @@ Decode a hexadecimal-encoded key and pretty-print it. For example: $ decode-key BB89F902ADB43000151C2D1ED07DE6C009 /Table/51/1/44938288/1521140384.514565824,0 `, + Args: cobra.ArbitraryArgs, RunE: func(cmd *cobra.Command, args []string) error { for _, arg := range args { b, err := hex.DecodeString(arg) @@ -470,6 +462,7 @@ var debugRaftLogCmd = &cobra.Command{ Long: ` Prints all log entries in a store for the given range. `, + Args: cobra.ExactArgs(2), RunE: MaybeDecorateGRPCError(runDebugRaftLog), } @@ -528,10 +521,6 @@ func runDebugRaftLog(cmd *cobra.Command, args []string) error { stopper := stop.NewStopper() defer stopper.Stop(context.Background()) - if len(args) != 2 { - return errors.New("two arguments required: dir range_id") - } - db, err := openExistingStore(args[0], stopper, true /* readOnly */) if err != nil { return err @@ -560,6 +549,7 @@ ranges individually. Uses a hard-coded GC policy with a 24 hour TTL for old versions. `, + Args: cobra.RangeArgs(1, 2), RunE: MaybeDecorateGRPCError(runDebugGCCmd), } @@ -568,18 +558,11 @@ func runDebugGCCmd(cmd *cobra.Command, args []string) error { defer stopper.Stop(context.Background()) var rangeID roachpb.RangeID - switch len(args) { - - } - switch len(args) { - case 2: + if len(args) == 2 { var err error if rangeID, err = parseRangeID(args[1]); err != nil { return err } - case 1: - default: - return errors.New("arguments: dir [range_id]") } db, err := openExistingStore(args[0], stopper, true /* readOnly */) @@ -650,6 +633,7 @@ Capable of detecting the following errors: * Raft logs that are inconsistent with their metadata * MVCC stats that are inconsistent with the data within the range `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runDebugCheckStoreCmd), } @@ -666,10 +650,6 @@ func runDebugCheckStoreCmd(cmd *cobra.Command, args []string) error { ctx := context.Background() - if len(args) != 1 { - return errors.New("one required argument: dir") - } - db, err := openExistingStore(args[0], stopper, true /* readOnly */) if err != nil { return err @@ -812,6 +792,7 @@ var debugEnvCmd = &cobra.Command{ Long: ` Output environment variables that influence configuration. `, + Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { env := envutil.GetEnvReport() fmt.Print(env) @@ -824,6 +805,7 @@ var debugCompactCmd = &cobra.Command{ Long: ` Compact the sstables in a store. `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runDebugCompact), } @@ -831,10 +813,6 @@ func runDebugCompact(cmd *cobra.Command, args []string) error { stopper := stop.NewStopper() defer stopper.Stop(context.Background()) - if len(args) != 1 { - return errors.New("one argument is required") - } - db, err := openExistingStore(args[0], stopper, false /* readOnly */) if err != nil { return err @@ -886,6 +864,7 @@ total files and 14 files that are 129 MiB in size. The suffixes K, M, G and T are used for terseness to represent KiB, MiB, GiB and TiB. `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runDebugSSTables), } @@ -893,10 +872,6 @@ func runDebugSSTables(cmd *cobra.Command, args []string) error { stopper := stop.NewStopper() defer stopper.Stop(context.Background()) - if len(args) != 1 { - return errors.New("one argument is required") - } - db, err := openExistingStore(args[0], stopper, true /* readOnly */) if err != nil { return err @@ -915,6 +890,7 @@ Pretty-prints the values in a node's gossip instance. Can connect to a running server to get the values or can be provided with a JSON file captured from a node's /_status/gossip/ debug endpoint. `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runDebugGossipValues), } @@ -1020,6 +996,7 @@ var debugSyncTestCmd = &cobra.Command{ Short: "Run a performance test for WAL sync speed", Long: ` `, + Args: cobra.MaximumNArgs(1), Hidden: true, RunE: MaybeDecorateGRPCError(runDebugSyncTest), } @@ -1032,9 +1009,6 @@ var syncTestOpts = synctest.Options{ func runDebugSyncTest(cmd *cobra.Command, args []string) error { syncTestOpts.Dir = "./testdb" - if len(args) > 1 { - return fmt.Errorf("too many arguments") - } if len(args) == 1 { syncTestOpts.Dir = args[0] } diff --git a/pkg/cli/demo.go b/pkg/cli/demo.go index 111609e07fa4..79227b36b94a 100644 --- a/pkg/cli/demo.go +++ b/pkg/cli/demo.go @@ -34,6 +34,7 @@ Start an in-memory, standalone, single-node CockroachDB instance, and open an interactive SQL prompt to it. `, Example: ` cockroach demo`, + Args: cobra.NoArgs, RunE: MaybeShoutError(MaybeDecorateGRPCError(runDemo)), } diff --git a/pkg/cli/dump.go b/pkg/cli/dump.go index 4fc3e9f6e752..8305c83f9ca6 100644 --- a/pkg/cli/dump.go +++ b/pkg/cli/dump.go @@ -41,14 +41,11 @@ var dumpCmd = &cobra.Command{ Dump SQL tables of a cockroach database. If the table name is omitted, dump all tables in the database. `, + Args: cobra.MinimumNArgs(1), RunE: MaybeDecorateGRPCError(runDump), } func runDump(cmd *cobra.Command, args []string) error { - if len(args) < 1 { - return usageAndError(cmd) - } - conn, err := getPasswordAndMakeSQLClient("cockroach dump") if err != nil { return err diff --git a/pkg/cli/error.go b/pkg/cli/error.go index b39aef2518bf..417504462de6 100644 --- a/pkg/cli/error.go +++ b/pkg/cli/error.go @@ -111,10 +111,3 @@ func MaybeShoutError( return err } } - -func usageAndError(cmd *cobra.Command) error { - if err := cmd.Usage(); err != nil { - return err - } - return errors.New("invalid arguments") -} diff --git a/pkg/cli/examples.go b/pkg/cli/examples.go index d4496fa0aa71..5af57aed4eba 100644 --- a/pkg/cli/examples.go +++ b/pkg/cli/examples.go @@ -41,10 +41,8 @@ func init() { genExampleCmd := &cobra.Command{ Use: meta.Name, Short: meta.Description, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - if len(args) > 0 { - return usageAndError(cmd) - } runGenExamplesCmd(gen) return nil }, diff --git a/pkg/cli/gen.go b/pkg/cli/gen.go index 09909065549a..97aaca2099ae 100644 --- a/pkg/cli/gen.go +++ b/pkg/cli/gen.go @@ -35,14 +35,11 @@ By default, this places man pages into the "man/man1" directory under the curren Use "--path=PATH" to override the output directory. For example, to install man pages globally on many Unix-like systems, use "--path=/usr/local/share/man/man1". `, + Args: cobra.NoArgs, RunE: MaybeDecorateGRPCError(runGenManCmd), } func runGenManCmd(cmd *cobra.Command, args []string) error { - if len(args) > 0 { - return usageAndError(cmd) - } - info := build.GetInfo() header := &doc.GenManHeader{ Section: "1", @@ -90,13 +87,11 @@ override the file location. Note that for the generated file to work on OS X, you'll need to install Homebrew's bash-completion package (or an equivalent) and follow the post-install instructions. `, + Args: cobra.NoArgs, RunE: MaybeDecorateGRPCError(runGenAutocompleteCmd), } func runGenAutocompleteCmd(cmd *cobra.Command, args []string) error { - if len(args) > 0 { - return usageAndError(cmd) - } if err := cmd.Root().GenBashCompletionFile(autoCompletePath); err != nil { return err } diff --git a/pkg/cli/haproxy.go b/pkg/cli/haproxy.go index 5f4a8c217cf7..76fd9c5f1564 100644 --- a/pkg/cli/haproxy.go +++ b/pkg/cli/haproxy.go @@ -45,6 +45,7 @@ The addresses used are those advertized by the nodes themselves. Make sure hapro can resolve the hostnames in the configuration file, either by using full-qualified names, or running haproxy in the same network. `, + Args: cobra.NoArgs, RunE: MaybeDecorateGRPCError(runGenHAProxyCmd), } @@ -84,10 +85,6 @@ func nodeStatusesToNodeInfos(statuses []status.NodeStatus) []haProxyNodeInfo { } func runGenHAProxyCmd(cmd *cobra.Command, args []string) error { - if len(args) > 0 { - return usageAndError(cmd) - } - ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/pkg/cli/init.go b/pkg/cli/init.go index d1d83087077e..568e9461eaf7 100644 --- a/pkg/cli/init.go +++ b/pkg/cli/init.go @@ -38,6 +38,7 @@ must appear in the --join flags of other nodes. A node started without the --join flag initializes itself as a single-node cluster, so the init command is not used in that case. `, + Args: cobra.NoArgs, RunE: MaybeShoutError(MaybeDecorateGRPCError(runInit)), } diff --git a/pkg/cli/node.go b/pkg/cli/node.go index 27ff41652cbd..f6f418351417 100644 --- a/pkg/cli/node.go +++ b/pkg/cli/node.go @@ -49,14 +49,11 @@ var lsNodesCmd = &cobra.Command{ Display the node IDs for all active (that is, running and not decommissioned) members of the cluster. To retrieve the IDs for inactive members, see 'node status --decommission'. `, + Args: cobra.NoArgs, RunE: MaybeDecorateGRPCError(runLsNodes), } func runLsNodes(cmd *cobra.Command, args []string) error { - if len(args) != 0 { - return usageAndError(cmd) - } - const showDecommissioned = false nodeStatuses, _, err := runStatusNodeInner(showDecommissioned, nil) if err != nil { @@ -111,6 +108,7 @@ var statusNodeCmd = &cobra.Command{ If a node ID is specified, this will show the status for the corresponding node. If no node ID is specified, this will display the status for all nodes in the cluster. `, + Args: cobra.MaximumNArgs(1), RunE: MaybeDecorateGRPCError(runStatusNode), } @@ -314,6 +312,7 @@ var decommissionNodeCmd = &cobra.Command{ Long: ` Marks the nodes with the supplied IDs as decommissioning. This will cause leases and replicas to be removed from these nodes.`, + Args: cobra.MinimumNArgs(1), RunE: MaybeDecorateGRPCError(runDecommissionNode), } @@ -330,10 +329,6 @@ func parseNodeIDs(strNodeIDs []string) ([]roachpb.NodeID, error) { } func runDecommissionNode(cmd *cobra.Command, args []string) error { - if len(args) == 0 { - return usageAndError(cmd) - } - ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -434,13 +429,14 @@ func decommissionResponseValueToRows( } var recommissionNodeCmd = &cobra.Command{ - Use: "recommission []+", + Use: "recommission [ ...]", Short: "recommissions the node(s)", Long: ` For the nodes with the supplied IDs, resets the decommissioning states. The target nodes must be restarted, at which point the change will take effect and the nodes will participate in the cluster as regular nodes. `, + Args: cobra.MinimumNArgs(1), RunE: MaybeDecorateGRPCError(runRecommissionNode), } @@ -450,10 +446,6 @@ func printDecommissionStatus(resp serverpb.DecommissionStatusResponse) error { } func runRecommissionNode(cmd *cobra.Command, args []string) error { - if len(args) == 0 { - return usageAndError(cmd) - } - ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/pkg/cli/sql.go b/pkg/cli/sql.go index 37288f80e1b9..e613ab196beb 100644 --- a/pkg/cli/sql.go +++ b/pkg/cli/sql.go @@ -59,6 +59,7 @@ var sqlShellCmd = &cobra.Command{ Long: ` Open a sql shell running against a cockroach database. `, + Args: cobra.NoArgs, RunE: MaybeDecorateGRPCError(runTerm), } @@ -1140,10 +1141,6 @@ func runStatements(conn *sqlConn, stmts []string) error { } func runTerm(cmd *cobra.Command, args []string) error { - if len(args) > 0 { - return usageAndError(cmd) - } - // We don't consider sessions interactives unless we have a // serious hunch they are. For now, only `cockroach sql` *without* // `-e` has the ability to input from a (presumably) human user, diff --git a/pkg/cli/start.go b/pkg/cli/start.go index b571af8c6cc7..0c1bac50251c 100644 --- a/pkg/cli/start.go +++ b/pkg/cli/start.go @@ -78,6 +78,7 @@ uninitialized, specify the --join flag to point to any healthy node (or list of nodes) already part of the cluster. `, Example: ` cockroach start --insecure --store=attrs=ssd,path=/mnt/ssd1 [--join=host:port,[host:port]]`, + Args: cobra.NoArgs, RunE: MaybeShoutError(MaybeDecorateGRPCError(runStart)), } @@ -371,10 +372,6 @@ func initTempStorageConfig( // of other active nodes used to join this node to the cockroach // cluster, if this is its first time connecting. func runStart(cmd *cobra.Command, args []string) error { - if len(args) > 0 { - return usageAndError(cmd) - } - tBegin := timeutil.Now() // First things first: if the user wants background processing, @@ -999,6 +996,7 @@ Shutdown the server. The first stage is drain, where any new requests will be ignored by the server. When all extant requests have been completed, the server exits. `, + Args: cobra.NoArgs, RunE: MaybeDecorateGRPCError(runQuit), } @@ -1071,10 +1069,6 @@ type errTryHardShutdown struct{ error } // runQuit accesses the quit shutdown path. func runQuit(cmd *cobra.Command, args []string) (err error) { - if len(args) != 0 { - return usageAndError(cmd) - } - ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/pkg/cli/user.go b/pkg/cli/user.go index ed5487760081..fa2a49adfc33 100644 --- a/pkg/cli/user.go +++ b/pkg/cli/user.go @@ -31,13 +31,11 @@ var getUserCmd = &cobra.Command{ Long: ` Fetches and displays the user for . `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runGetUser), } func runGetUser(cmd *cobra.Command, args []string) error { - if len(args) != 1 { - return usageAndError(cmd) - } conn, err := getPasswordAndMakeSQLClient("cockroach user") if err != nil { return err @@ -60,13 +58,11 @@ var lsUsersCmd = &cobra.Command{ Long: ` List all users. `, + Args: cobra.NoArgs, RunE: MaybeDecorateGRPCError(runLsUsers), } func runLsUsers(cmd *cobra.Command, args []string) error { - if len(args) > 0 { - return usageAndError(cmd) - } conn, err := getPasswordAndMakeSQLClient("cockroach user") if err != nil { return err @@ -83,13 +79,11 @@ var rmUserCmd = &cobra.Command{ Long: ` Remove an existing user by username. `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runRmUser), } func runRmUser(cmd *cobra.Command, args []string) error { - if len(args) != 1 { - return usageAndError(cmd) - } conn, err := getPasswordAndMakeSQLClient("cockroach user") if err != nil { return err @@ -117,6 +111,7 @@ Valid usernames contain 1 to 63 alphanumeric characters. They must begin with either a letter or an underscore. Subsequent characters may be letters, numbers, or underscores. `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runSetUser), } @@ -125,9 +120,6 @@ may be letters, numbers, or underscores. // TODO(marc): once we have more fields in the user, we will need // to allow changing just some of them (eg: change email, but leave password). func runSetUser(cmd *cobra.Command, args []string) error { - if len(args) != 1 { - return usageAndError(cmd) - } pwdString := "" if password { var err error diff --git a/pkg/cli/zip.go b/pkg/cli/zip.go index 2c9ce91f00e3..2534a2b58964 100644 --- a/pkg/cli/zip.go +++ b/pkg/cli/zip.go @@ -42,6 +42,7 @@ Retrieval of per-node details (status, stack traces, range status) requires the node to be live and operating properly. Retrieval of SQL data requires the cluster to be live. `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runDebugZip), } @@ -104,10 +105,6 @@ func runDebugZip(cmd *cobra.Command, args []string) error { settingsName = base + "/settings" ) - if len(args) != 1 { - return usageAndError(cmd) - } - ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/pkg/cli/zone.go b/pkg/cli/zone.go index 848349d9ccdf..a453b54eb1b1 100644 --- a/pkg/cli/zone.go +++ b/pkg/cli/zone.go @@ -72,16 +72,13 @@ var getZoneCmd = &cobra.Command{ Fetches and displays the zone configuration for the specified database or table. `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runGetZone), } // runGetZone retrieves the zone config for a given object id, // and if present, outputs its YAML representation. func runGetZone(cmd *cobra.Command, args []string) error { - if len(args) != 1 { - return usageAndError(cmd) - } - zs, err := config.ParseCLIZoneSpecifier(args[0]) if err != nil { return err @@ -128,13 +125,11 @@ var lsZonesCmd = &cobra.Command{ Long: ` List zone configs. `, + Args: cobra.NoArgs, RunE: MaybeDecorateGRPCError(runLsZones), } func runLsZones(cmd *cobra.Command, args []string) error { - if len(args) > 0 { - return usageAndError(cmd) - } conn, err := getPasswordAndMakeSQLClient("cockroach zone") if err != nil { return err @@ -169,14 +164,11 @@ var rmZoneCmd = &cobra.Command{ Long: ` Remove an existing zone config for the specified database or table. `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runRmZone), } func runRmZone(cmd *cobra.Command, args []string) error { - if len(args) != 1 { - return usageAndError(cmd) - } - conn, err := getPasswordAndMakeSQLClient("cockroach zone") if err != nil { return err @@ -225,6 +217,7 @@ EOF Note that the specified zone config is merged with the existing zone config for the database or table. `, + Args: cobra.ExactArgs(1), RunE: MaybeDecorateGRPCError(runSetZone), } @@ -250,10 +243,6 @@ func readZoneConfig() (conf []byte, err error) { // runSetZone parses the yaml input file, converts it to proto, and inserts it // in the system.zones table. func runSetZone(cmd *cobra.Command, args []string) error { - if len(args) != 1 { - return usageAndError(cmd) - } - conn, err := getPasswordAndMakeSQLClient("cockroach zone") if err != nil { return err diff --git a/pkg/security/certs.go b/pkg/security/certs.go index 0bb0dec7d4bd..6bcd853ccac7 100644 --- a/pkg/security/certs.go +++ b/pkg/security/certs.go @@ -185,10 +185,6 @@ func CreateNodePair( return errors.New("the path to the certs directory is required") } - if len(hosts) == 0 { - return errors.Errorf("no hosts specified. Need at least one") - } - // The certificate manager expands the env for the certs directory. // For consistency, we need to do this for the key as well. caKeyPath = os.ExpandEnv(caKeyPath)