Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
fix update cg command to take cg uuid, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranrg committed Jun 29, 2017
1 parent 59bfb01 commit 9b898e1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
6 changes: 3 additions & 3 deletions cmd/tools/admin/main.go
Expand Up @@ -141,8 +141,8 @@ func main() {
},
cli.IntFlag{
Name: "skip_older_messages_in_seconds, k",
Value: 7200,
Usage: "Skip messages older than this duration in seconds.",
Value: 0,
Usage: "Skip messages older than this duration in seconds ('0' to skip none).",
},
cli.IntFlag{
Name: "delay_seonds, d",
Expand Down Expand Up @@ -330,7 +330,7 @@ func main() {
{
Name: "consumergroup",
Aliases: []string{"c", "cg"},
Usage: "update consumergroup <destination_path> <consumer_group_name>",
Usage: "update consumergroup (<consumer_group_uuid> | <destination_path> <consumer_group_name>)",
Flags: []cli.Flag{
cli.StringFlag{
Name: "status, s",
Expand Down
23 changes: 11 additions & 12 deletions cmd/tools/cli/main.go
Expand Up @@ -34,8 +34,8 @@ const (

strMaxDeliveryCount = "Maximum number of times a message is delivered\n\tbefore it is sent to the dead-letter queue (DLQ)"

strSkipOlderMessagesInSeconds = `Skip messages older than this duration in seconds.`
intSkipOlderMessagesInSeconds = 999999999 // More than 30 years
strSkipOlderMessagesInSeconds = `Skip messages older than this duration in seconds ('0' to skip none)`
intSkipOlderMessagesInSeconds = 0 // 0 -> skip none

strDelaySeconds = `Delay to introduce to all messages, in seconds.`
intDelaySeconds = 0 // zero delay, by default
Expand Down Expand Up @@ -93,7 +93,7 @@ func main() {
Subcommands: []cli.Command{
{
Name: "destination",
Aliases: []string{"d", "dst"},
Aliases: []string{"d", "dst", "dest"},
Usage: "create destination <path> [options]",
Flags: []cli.Flag{
cli.StringFlag{
Expand Down Expand Up @@ -191,13 +191,12 @@ func main() {
Subcommands: []cli.Command{
{
Name: "destination",
Aliases: []string{"d", "dst"},
Aliases: []string{"d", "dst", "dest"},
Usage: "show destination <name>",
Flags: []cli.Flag{
cli.StringFlag{
Name: "showcg, sc",
Value: "false",
Usage: "show consumer group(false, true), default to false",
cli.BoolFlag{
Name: "show_cg, cg",
Usage: "show consumer groups for the destination",
},
},
Action: func(c *cli.Context) {
Expand Down Expand Up @@ -245,7 +244,7 @@ func main() {
Subcommands: []cli.Command{
{
Name: "destination",
Aliases: []string{"d", "dst"},
Aliases: []string{"d", "dst", "dest"},
Usage: "update destination <name>",
Flags: []cli.Flag{
cli.StringFlag{
Expand Down Expand Up @@ -285,7 +284,7 @@ func main() {
{
Name: "consumergroup",
Aliases: []string{"c", "cg"},
Usage: "update consumergroup <destination_path> <consumer_group_name>",
Usage: "update consumergroup (<consumer_group_uuid> | <destination_path> <consumer_group_name>)",
Flags: []cli.Flag{
cli.StringFlag{
Name: "status, s",
Expand Down Expand Up @@ -340,7 +339,7 @@ func main() {
Subcommands: []cli.Command{
{
Name: "destination",
Aliases: []string{"d", "dst"},
Aliases: []string{"d", "dst", "dest"},
Usage: "delete destination <name>",
Action: func(c *cli.Context) {
lib.DeleteDestination(c)
Expand All @@ -365,7 +364,7 @@ func main() {
Subcommands: []cli.Command{
{
Name: "destination",
Aliases: []string{"d", "dst"},
Aliases: []string{"d", "dst", "dest"},
Usage: "list destination [options]",
Flags: []cli.Flag{
cli.StringFlag{
Expand Down
24 changes: 21 additions & 3 deletions tools/common/lib.go
Expand Up @@ -518,12 +518,30 @@ func getCgZoneConfigs(c *cli.Context, mClient mcli.Client, cliHelper common.CliH

// UpdateConsumerGroup update the consumer group based on cli.Context
func UpdateConsumerGroup(c *cli.Context, cClient ccli.Client, mClient mcli.Client, cliHelper common.CliHelper) {
if len(c.Args()) < 2 {

var path, name string

switch {
case len(c.Args()) < 1:
ExitIfError(errors.New(strNotEnoughArgs))

case len(c.Args()) == 1: // assume the arg is a uuid

respCG, err := mClient.ReadConsumerGroupByUUID(&shared.ReadConsumerGroupRequest{
ConsumerGroupUUID: &c.Args()[0],
})
ExitIfError(err)

respDest, err := mClient.ReadDestination(&shared.ReadDestinationRequest{
DestinationUUID: respCG.DestinationUUID,
})

path, name = respDest.GetPath(), respCG.GetConsumerGroupUUID()

default:
path, name = c.Args()[0], c.Args()[1]
}

path := c.Args()[0]
name := c.Args()[1]
status := cherami.ConsumerGroupStatus_ENABLED
if c.String("status") == "disabled" {
status = cherami.ConsumerGroupStatus_DISABLED
Expand Down

0 comments on commit 9b898e1

Please sign in to comment.