-
Notifications
You must be signed in to change notification settings - Fork 70
Add cluster commands get
#4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
sijie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use ClusterData rather than ClusterConfiguration. because configuration is a bit confused especially there are endpoints to fetch configuration.
pkg/ctl/cluster/create.go
Outdated
| "p", | ||
| []string{""}, | ||
| "Cluster to be registered as a peer-cluster of this cluster.") | ||
| cobra.MarkFlagRequired(flagSet, "broker-url") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should set broker-url to required directly. The constraint should be "at least one of the options should be set"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➜ pulsar git:(pulsar_reader) ✗ bin/pulsar-admin clusters create --broker-url localhost:8080 testhello
The following option is required: --url
Provisions a new cluster. This operation requires Pulsar super-user privileges
Usage: create [options] cluster-name
Options:
--broker-url
broker-service-url
--broker-url-secure
broker-service-url for secure connection
* --url
service-url
--url-secure
service-url for secure connection
So the Java admin client is wrong too? Is this need to change in java admin client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes java admin client needs to be improved as well. but let's first do this in pulsarctl first. we can contribute the changes back to pulsar-admin when we complete pulsarctl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
pkg/ctl/cluster/get.go
Outdated
| return doGetClusterConfiguration(vc, clusterName) | ||
| }) | ||
|
|
||
| vc.FlagSetGroup.InFlagSet("ClusterName", func(flagSet *pflag.FlagSet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't introduce a --cluster-name option. use NameArg for cluster-name. keep the behavior as same as other commands in the same command group.
- get <cluster_name>
- create [options] <cluster_name>
pkg/ctl/cluster/get.go
Outdated
| vc.SetDescription( | ||
| "get", | ||
| "Get the configuration data for the specified cluster", | ||
| "This command is used for getting the configuration data of the specified cluster.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should try to improve how we write the long description.
It should contains:
- a few sentences describe what this command is used for.
- a section about the output and example of the output.
- a section of examples how to use this command (if applicable).
- a section of describing what kind of permissions are required for executing this command.
Please work with Yu or Jennifer to come up a standard for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jennifer88huang since you are on call this week, could u pls help review?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
USED FOR:
This command is used for getting the cluster data of the specified cluster.
PERMISSION:
This command only admin can use.
EXAMPLE:
{
serviceUrl : http://localhost:8080,
serviceUrlTls : https://localhost:8080,
brokerServiceUrl: pulsar://localhost:6650,
brokerServiceUrlTls: pulsar+ssl://localhost:6650,
peerClusterNames: ""
}
Usage: pulsarctl clusters get [flags]
Aliases: get, get
Common flags:
-s, --admin-service-url string The admin web service url that pulsarctl connects to. (default "http://localhost:8080")
-C, --color 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)
Use 'pulsarctl clusters get [command] --help' for more information about a command.
Currently, the long description will show like this. Any suggestion? @sijie @jennifer88huang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zymap :
examples should be used for describing the possible combinations of how to run this command. for example, this is the examples of kubectl get.
Examples:
# List all pods in ps output format.
kubectl get pods
# List all pods in ps output format with more information (such as node name).
kubectl get pods -o wide
# List a single replication controller with specified NAME in ps output format.
kubectl get replicationcontroller web
# List deployments in JSON output format, in the "v1" version of the "apps" API group:
kubectl get deployments.v1.apps -o json
# List a single pod in JSON output format.
kubectl get -o json pod web-pod-13je7
# List a pod identified by type and name specified in "pod.yaml" in JSON output format.
kubectl get -f pod.yaml -o json
# List resources from a directory with kustomization.yaml - e.g. dir/kustomization.yaml.
kubectl get -k dir/
# Return only the phase value of the specified pod.
kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}
# List resource information in custom columns.
kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image
# List all replication controllers and services together in ps output format.
kubectl get rc,services
# List one or more resources by their type and names.
kubectl get rc/web service/frontend pods/web-pod-13je7
You need a section to document the output. You should document the output when the command runs successfully and when it fails to run.
USED FOR:
<used-for-description>
REQUIRED PERMISSIONS:
<required-permissions>
EXAMPLES: // if the command is simple, the examples can be ommitted
<list-the-examples-of-commands>
OUTPUT:
<describe the output of the command>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sijie Got it, thanks for the example.
pkg/ctl/cluster/test.go
Outdated
| "github.com/streamnative/pulsarctl/pkg/cmdutils" | ||
| ) | ||
|
|
||
| func TestCommands(newVerb func(cmd *cmdutils.VerbCmd), args []string) (out *bytes.Buffer, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only used for testing cluster commands? If so, let's use a more specific name like TestClusterCommands rather than a general name.
pkg/ctl/cluster/get.go
Outdated
| return err | ||
| } | ||
|
|
||
| func concat(join string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not define a Struct for the long description and have a common method to get the string for long description? So you don't need to write the concat logic every time you introduce a new command.
pkg/ctl/cluster/get.go
Outdated
| } | ||
|
|
||
| func concat(join string) string { | ||
| return "USED FOR:" + join + "\t" + commandUsedFor + join + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use four spaces instead of \t
pkg/ctl/cluster/get.go
Outdated
| " brokerServiceUrlTls: pulsar+ssl://localhost:6650, \n" + | ||
| " peerClusterNames: \"\" \n" + | ||
| "}\n" | ||
| var commandPermission = "This command only admin can use." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var commandPermission = "This command only admin can use." | |
| var commandPermission = "This command requires super-user permissions." |
pkg/ctl/cluster/get.go
Outdated
|
|
||
|
|
||
| var commandUsedFor = "This command is used for getting the cluster data of the specified cluster." | ||
| var commandExample = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not example. It is an example of output. Also you didn't document the error case as I suggested in my previous comment.
|
@sijie I update the long description of the command |
Add cluster commands `get`
Add cluster commands `get`
Master Issue: #2