-
Notifications
You must be signed in to change notification settings - Fork 70
Add partitioned topic command CURD #35
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
|
please avoid coupling refactoring with other changes. so revert the refactor please. also as discussed, lets unify partitioned topic and topic into one set of commands. |
383dac2 to
f70a8ec
Compare
|
@sijie PTAL |
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.
Please add the help output for the added commands in the description.
d4986f6 to
b213f04
Compare
| return err | ||
| } | ||
|
|
||
| partitions, err := strconv.Atoi(vc.NameArgs[1]) |
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.
It is only checking two args. Please be more specific. SetRunFuncWithTwoNameArgs
|
@sijie PTAL |
Master issue: streamnative/pulsarctl#2 *Modifications* Add commands topic `create`, `delete`, `update`, `get-metadata`, `list`. *TODO* need add test for these commands. ## OUTPUT * create * ``` ➜ pulsarctl-yong git:(topic-partitioned-commands) ./pulsarctl topic create -h USED FOR: This command is used for creating topic. REQUIRED PERMISSION: This command requires admin permissions. EXAMPLES: #Create non-partitioned topic <topic-name> pulsarctl topics create <topic-name> 0 #Create topic <topic-name> with <partitions-num> partitions pulsarctl topics create <topic-name> <partition-num> OUTPUT: #normal output Create topic <topic-name> with <partition-num> partitions successfully #the topic name and(or) the partitions is not specified [✖] need to specified the topic name and the partitions #the topic has been created [✖] code: 409 reason: Partitioned topic already exists #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic> [✖] Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic> #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic> [✖] Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic> #the topic name is not in the format of <tenant>/<namespace>/<topic> [✖] Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic> #the namespace name is not in the format of <tenant>/<namespace> [✖] The complete name of namespace is invalid. complete name : <namespace-complete-name> #the tenant name and(or) namespace name is empty [✖] Invalid tenant or namespace. [<tenant>/<namespace>] #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Tenant name include unsupported special chars. tenant : [<namespace>] #the namespace name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Namespace name include unsupported special chars. namespace : [<namespace>] Usage: pulsarctl topics create [flags] Aliases: create, c ``` * delete * ``` ➜ pulsarctl-yong git:(topic-partitioned-commands) ./pulsarctl topic delete -h USED FOR: This command is used for deleting an exist topic. REQUIRED PERMISSION: This command requires admin permissions. EXAMPLES: #Delete a partitioned topic <topic-name> pulsarctl topics delete <topic-name> #Delete a non-partitioned topic <topic-name> pulsarctl topics delete --non-partitioned <topic-name> OUTPUT: #normal output Delete topic <topic-name> successfully #the topic name is not specified [✖] only one argument is allowed to be used as a name #the partitioned topic does not exist [✖] code: 404 reason: Partitioned topic does not exist #the non-partitioned topic does not exist [✖] code: 404 reason: Topic not found #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic> [✖] Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic> #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic> [✖] Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic> #the topic name is not in the format of <tenant>/<namespace>/<topic> [✖] Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic> #the namespace name is not in the format of <tenant>/<namespace> [✖] The complete name of namespace is invalid. complete name : <namespace-complete-name> #the tenant name and(or) namespace name is empty [✖] Invalid tenant or namespace. [<tenant>/<namespace>] #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Tenant name include unsupported special chars. tenant : [<namespace>] #the namespace name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Namespace name include unsupported special chars. namespace : [<namespace>] Usage: pulsarctl topics delete [flags] Aliases: delete, d ``` * get-metadata * ``` ➜ pulsarctl-yong git:(topic-partitioned-commands) ./pulsarctl topic get-metadata -h USED FOR: This command is used for getting an exist topic. REQUIRED PERMISSION: This command requires admin permissions. EXAMPLES: #Get an exist topic <topic-name> metadata pulsarctl topics get-metadata <topic-name> OUTPUT: #normal output { "partitions": "<partitions>" } #the topic name is not specified [✖] only one argument is allowed to be used as a name #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic> [✖] Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic> #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic> [✖] Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic> #the topic name is not in the format of <tenant>/<namespace>/<topic> [✖] Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic> #the namespace name is not in the format of <tenant>/<namespace> [✖] The complete name of namespace is invalid. complete name : <namespace-complete-name> #the tenant name and(or) namespace name is empty [✖] Invalid tenant or namespace. [<tenant>/<namespace>] #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Tenant name include unsupported special chars. tenant : [<namespace>] #the namespace name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Namespace name include unsupported special chars. namespace : [<namespace>] Usage: pulsarctl topics get-metadata [flags] Aliases: get-metadata, gm ``` * list * ``` ➜ pulsarctl-yong git:(topic-partitioned-commands) ./pulsarctl topic list -h USED FOR: This command is used for listing all exist topics under the specified namespace. REQUIRED PERMISSION: This command requires admin permissions. EXAMPLES: #List all exist topics under the namespace <tenant/namespace> pulsarctl topics list <tenant/namespace> OUTPUT: #normal output +--------------------------------+--------------------------------+ | PUBLIC/DEFAULT PARTITIONED | PUBLIC/DEFAULT NON-PARTITIONED | | TOPICS | TOPICS | +--------------------------------+--------------------------------+ | | | +--------------------------------+--------------------------------+ #the namespace is not specified [✖] only one argument is allowed to be used as a name #the tenant of the namespace is not exist [✖] code: 404 reason: Tenant does not exist #the namespace is not exist [✖] code: 404 reason: Namespace does not exist #the namespace name is not in the format of <tenant>/<namespace> [✖] The complete name of namespace is invalid. complete name : <namespace-complete-name> #the tenant name and(or) namespace name is empty [✖] Invalid tenant or namespace. [<tenant>/<namespace>] #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Tenant name include unsupported special chars. tenant : [<namespace>] #the namespace name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Namespace name include unsupported special chars. namespace : [<namespace>] Usage: pulsarctl topics list [flags] Aliases: list, lp ``` * update * ``` ➜ pulsarctl-yong git:(topic-partitioned-commands) ./pulsarctl topic update -h USED FOR: This command is used for updating an exist topic with new partition number. REQUIRED PERMISSION: This command requires admin permissions. EXAMPLES: # pulsarctl topics update <topic-name> <partition-num> OUTPUT: #normal output Update topic <topic-name> with <partition-num> partitions successfully #the topic name and(or) the partitions is not specified [✖] need to specified the topic name and the partitions #the partitions number is invalid [✖] invalid partition number '<number>' #the topic is not exist [✖] code: 409 reason: Topic is not partitioned topic #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic> [✖] Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic> #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic> [✖] Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic> #the topic name is not in the format of <tenant>/<namespace>/<topic> [✖] Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic> #the namespace name is not in the format of <tenant>/<namespace> [✖] The complete name of namespace is invalid. complete name : <namespace-complete-name> #the tenant name and(or) namespace name is empty [✖] Invalid tenant or namespace. [<tenant>/<namespace>] #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Tenant name include unsupported special chars. tenant : [<namespace>] #the namespace name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Namespace name include unsupported special chars. namespace : [<namespace>] Usage: pulsarctl topics update [flags] Aliases: update, up ```
Master issue: streamnative/pulsarctl#2 *Modifications* Add commands topic `create`, `delete`, `update`, `get-metadata`, `list`. *TODO* need add test for these commands. ## OUTPUT * create * ``` ➜ pulsarctl-yong git:(topic-partitioned-commands) ./pulsarctl topic create -h USED FOR: This command is used for creating topic. REQUIRED PERMISSION: This command requires admin permissions. EXAMPLES: #Create non-partitioned topic <topic-name> pulsarctl topics create <topic-name> 0 #Create topic <topic-name> with <partitions-num> partitions pulsarctl topics create <topic-name> <partition-num> OUTPUT: #normal output Create topic <topic-name> with <partition-num> partitions successfully #the topic name and(or) the partitions is not specified [✖] need to specified the topic name and the partitions #the topic has been created [✖] code: 409 reason: Partitioned topic already exists #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic> [✖] Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic> #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic> [✖] Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic> #the topic name is not in the format of <tenant>/<namespace>/<topic> [✖] Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic> #the namespace name is not in the format of <tenant>/<namespace> [✖] The complete name of namespace is invalid. complete name : <namespace-complete-name> #the tenant name and(or) namespace name is empty [✖] Invalid tenant or namespace. [<tenant>/<namespace>] #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Tenant name include unsupported special chars. tenant : [<namespace>] #the namespace name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Namespace name include unsupported special chars. namespace : [<namespace>] Usage: pulsarctl topics create [flags] Aliases: create, c ``` * delete * ``` ➜ pulsarctl-yong git:(topic-partitioned-commands) ./pulsarctl topic delete -h USED FOR: This command is used for deleting an exist topic. REQUIRED PERMISSION: This command requires admin permissions. EXAMPLES: #Delete a partitioned topic <topic-name> pulsarctl topics delete <topic-name> #Delete a non-partitioned topic <topic-name> pulsarctl topics delete --non-partitioned <topic-name> OUTPUT: #normal output Delete topic <topic-name> successfully #the topic name is not specified [✖] only one argument is allowed to be used as a name #the partitioned topic does not exist [✖] code: 404 reason: Partitioned topic does not exist #the non-partitioned topic does not exist [✖] code: 404 reason: Topic not found #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic> [✖] Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic> #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic> [✖] Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic> #the topic name is not in the format of <tenant>/<namespace>/<topic> [✖] Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic> #the namespace name is not in the format of <tenant>/<namespace> [✖] The complete name of namespace is invalid. complete name : <namespace-complete-name> #the tenant name and(or) namespace name is empty [✖] Invalid tenant or namespace. [<tenant>/<namespace>] #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Tenant name include unsupported special chars. tenant : [<namespace>] #the namespace name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Namespace name include unsupported special chars. namespace : [<namespace>] Usage: pulsarctl topics delete [flags] Aliases: delete, d ``` * get-metadata * ``` ➜ pulsarctl-yong git:(topic-partitioned-commands) ./pulsarctl topic get-metadata -h USED FOR: This command is used for getting an exist topic. REQUIRED PERMISSION: This command requires admin permissions. EXAMPLES: #Get an exist topic <topic-name> metadata pulsarctl topics get-metadata <topic-name> OUTPUT: #normal output { "partitions": "<partitions>" } #the topic name is not specified [✖] only one argument is allowed to be used as a name #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic> [✖] Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic> #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic> [✖] Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic> #the topic name is not in the format of <tenant>/<namespace>/<topic> [✖] Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic> #the namespace name is not in the format of <tenant>/<namespace> [✖] The complete name of namespace is invalid. complete name : <namespace-complete-name> #the tenant name and(or) namespace name is empty [✖] Invalid tenant or namespace. [<tenant>/<namespace>] #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Tenant name include unsupported special chars. tenant : [<namespace>] #the namespace name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Namespace name include unsupported special chars. namespace : [<namespace>] Usage: pulsarctl topics get-metadata [flags] Aliases: get-metadata, gm ``` * list * ``` ➜ pulsarctl-yong git:(topic-partitioned-commands) ./pulsarctl topic list -h USED FOR: This command is used for listing all exist topics under the specified namespace. REQUIRED PERMISSION: This command requires admin permissions. EXAMPLES: #List all exist topics under the namespace <tenant/namespace> pulsarctl topics list <tenant/namespace> OUTPUT: #normal output +--------------------------------+--------------------------------+ | PUBLIC/DEFAULT PARTITIONED | PUBLIC/DEFAULT NON-PARTITIONED | | TOPICS | TOPICS | +--------------------------------+--------------------------------+ | | | +--------------------------------+--------------------------------+ #the namespace is not specified [✖] only one argument is allowed to be used as a name #the tenant of the namespace is not exist [✖] code: 404 reason: Tenant does not exist #the namespace is not exist [✖] code: 404 reason: Namespace does not exist #the namespace name is not in the format of <tenant>/<namespace> [✖] The complete name of namespace is invalid. complete name : <namespace-complete-name> #the tenant name and(or) namespace name is empty [✖] Invalid tenant or namespace. [<tenant>/<namespace>] #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Tenant name include unsupported special chars. tenant : [<namespace>] #the namespace name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Namespace name include unsupported special chars. namespace : [<namespace>] Usage: pulsarctl topics list [flags] Aliases: list, lp ``` * update * ``` ➜ pulsarctl-yong git:(topic-partitioned-commands) ./pulsarctl topic update -h USED FOR: This command is used for updating an exist topic with new partition number. REQUIRED PERMISSION: This command requires admin permissions. EXAMPLES: # pulsarctl topics update <topic-name> <partition-num> OUTPUT: #normal output Update topic <topic-name> with <partition-num> partitions successfully #the topic name and(or) the partitions is not specified [✖] need to specified the topic name and the partitions #the partitions number is invalid [✖] invalid partition number '<number>' #the topic is not exist [✖] code: 409 reason: Topic is not partitioned topic #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic> [✖] Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic> #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic> [✖] Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic> #the topic name is not in the format of <tenant>/<namespace>/<topic> [✖] Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic> #the namespace name is not in the format of <tenant>/<namespace> [✖] The complete name of namespace is invalid. complete name : <namespace-complete-name> #the tenant name and(or) namespace name is empty [✖] Invalid tenant or namespace. [<tenant>/<namespace>] #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Tenant name include unsupported special chars. tenant : [<namespace>] #the namespace name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed [✖] Namespace name include unsupported special chars. namespace : [<namespace>] Usage: pulsarctl topics update [flags] Aliases: update, up ```
Master issue: #2
Modifications
Add commands topic
create,delete,update,get-metadata,list.TODO
need add test for these commands.
OUTPUT