streamnative / pulsarctl

a CLI for Apache Pulsar written in Go
Apache License 2.0
154 stars 68 forks source link

--tls-allow-insecure breaks argument parsing #711

Open addisonj opened 2 years ago

addisonj commented 2 years ago

When passing --tls-allow-insecure in a command like:

pulsarctl --tls-allow-insecure true --admin-service-url https://xxx --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationToken --auth-params="token:xxx" namespaces list public
[✖]  the tenant name is not specified or the tenant name is specified more than one

We get an error.

In the help, it doesn't seem like you need -tls-allow-insecure true but if you don't include the true, and do the following:

pulsarctl --tls-allow-insecure --admin-service-url https://xxx --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationToken --auth-params="token:xxx" namespaces list public 
Error: unknown command "https://xxx" for "pulsarctl"
Run 'pulsarctl --help' for usage.
unknown command "https://xxx" for "pulsarctl"

The --tls-allow-insecure is chomping the next argument

The following does work:

pulsarctl --admin-service-url https:/xxx --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationToken --auth-params="token:xxx namespaces list public --tls-allow-insecure     
+----------------+
| NAMESPACE NAME |
+----------------+
| public/default |
+----------------+

But it is pretty awkward.

nodece commented 2 years ago

Thanks for your feedback, the right way:

pulsarctl namespaces list public --tls-allow-insecure --admin-service-url https:/xxx --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationToken --auth-params="token:xxx"

pulsarctl namespaces list public --tls-allow-insecure=true --admin-service-url https:/xxx --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationToken --auth-params="token:xxx"

Don't use any flags before subcommand, because these flags are registered in subcommand, you can see the common flags from root command.

➜  pulsarctl git:(master) pulsarctl -h
a CLI for Apache Pulsar

Usage: pulsarctl [command] [flags]

Commands:
  bookkeeper            Operations about bookKeeper
  broker-stats          Operations to collect broker statistics
  brokers               Operations about broker(s)
  clusters              Operations about cluster(s)
  completion            Generates shell completion scripts
  context               Interface for setting Pulsar Context 
  functions             Interface for managing Pulsar Functions (lightweight, Lambda-style compute processes that work with Pulsar)
  functions-worker      Operations to collect function-worker statistics
  help                  Help about any command
  namespaces            Operations about namespaces
  ns-isolation-policy   Operations about namespace isolation policy
  oauth2                Operations about oauth2
  packages              Operations about packages
  plugin                Operations about plugins
  resource-quotas       Operations about resource quotas
  schemas               Operations related to Schemas associated with Pulsar topics
  sinks                 Interface for managing Pulsar IO sinks (egress data from Pulsar)
  sources               Interface for managing Pulsar IO Sources (ingress data into Pulsar)
  subscriptions         Operations about subscription(s)
  tenants               Operations about tenant(s)
  token                 Operations of token
  topics                Operations about topic(s)

Common flags:
  -C, --fabulous string   toggle colorized logs (true,false,fabulous) (default "true")
  -h, --help              help for this command
  -v, --verbose int       set log level, use 0 to silence, 4 for debugging (default 3)
  -V, --version           show the pulsarctl version informantion

Use 'pulsarctl [command] --help' for more information about a command