Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
[qctl] when node name required make it an arg. (#93)
Browse files Browse the repository at this point in the history
when the node name is required for node commands, make it a required
argument instead of a `--name` flag, as this is more consistent.
> qctl add node [flags] NodeName
> qctl update node [flags] NodeName
> qctl ls node [flags] NodeName
  • Loading branch information
libby authored Oct 16, 2020
1 parent a449051 commit a373597
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion qctl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ at block: 19 (Tue, 06 Oct 2020 00:24:05 UTC)
To add a new node to the network run: add, generate, deploy.
`add` adds the node to the qubernetes config
```
$> qctl add node --name=quorum-node5
$> qctl add node quorum-node5
$> qctl ls nodes
```
cakeshop and monitoring can also be added the same way
Expand Down
49 changes: 26 additions & 23 deletions qctl/nodecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,21 +293,17 @@ var (
//qctl add node --id=node3 --consensus=ibft --quorum
//TODO: get the defaults from the config file.
nodeAddCommand = cli.Command{
Name: "node",
Usage: "add new nodes",
Aliases: []string{"n", "nodes"},
Name: "node",
Usage: "add new node",
Aliases: []string{"n", "nodes"},
ArgsUsage: "UniqueNodeName",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "config, c",
Usage: "Load configuration from `FULL_PATH_FILE`",
EnvVars: []string{"QUBE_CONFIG"},
//Required: true,
},
&cli.StringFlag{
Name: "name",
Usage: "Unique name of node to create",
Required: true,
},
// TODO: set default to Node-name-key-dir
&cli.StringFlag{
Name: "keydir",
Expand Down Expand Up @@ -337,8 +333,14 @@ var (
},
},
Action: func(c *cli.Context) error {
name := c.Args().First()
// node name argument is required to update a node
if name == "" {
c.App.Run([]string{"qctl", "help", "node"})
red.Println(" required argument: Unique NodeName of node you wish to add.")
return cli.Exit(" required argument: Unique NodeName of node you wish to add.", 3)
}
// defaults should be obtained from the config
name := c.String("name")
keyDir := c.String("keydir")
if keyDir == "" {
keyDir = fmt.Sprintf("key-%s", name)
Expand Down Expand Up @@ -443,21 +445,17 @@ var (
}
// TODO: consolidate this and add node
nodeUpdateCommand = cli.Command{
Name: "node",
Usage: "update node",
Aliases: []string{"n", "nodes"},
Name: "node",
Usage: "update node",
Aliases: []string{"n", "nodes"},
ArgsUsage: "NodeName",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "config, c",
Usage: "Load configuration from `FULL_PATH_FILE`",
EnvVars: []string{"QUBE_CONFIG"},
//Required: true,
},
&cli.StringFlag{
Name: "name",
Usage: "Unique name of node to create",
Required: true,
},
// TODO: set default to Node-name-key-dir
&cli.StringFlag{
Name: "keydir",
Expand Down Expand Up @@ -495,8 +493,14 @@ var (
},
},
Action: func(c *cli.Context) error {
name := c.Args().First()
// node name argument is required to update a node
if name == "" {
c.App.Run([]string{"qctl", "help", "node"})
red.Println(" NodeName required to update a node.")
return cli.Exit(" NodeName required to update a node.", 3)
}
// defaults should be obtained from the config
name := c.String("name")
keyDir := c.String("keydir")
if keyDir == "" {
keyDir = fmt.Sprintf("key-%s", name)
Expand Down Expand Up @@ -583,7 +587,6 @@ var (
}
updatedNode = nodeEntry
configFileYaml.Nodes[i] = updatedNode
red.Println(fmt.Sprintf("updated nodes is [%v]", updatedNode))
}
}
// If the node name the user entered to update does not exists, error out and notify the user.
Expand Down Expand Up @@ -617,11 +620,11 @@ var (
// qctl ls node --name --consensus --quorumversion
// qctl ls node --name --consensus --quorumversion --tmversion --tmname
nodeListCommand = cli.Command{
Name: "node",
Usage: "list nodes info",
Aliases: []string{"n", "nodes"},
Name: "node",
Usage: "list nodes info",
Aliases: []string{"n", "nodes"},
ArgsUsage: "NodeName",
Flags: []cli.Flag{

&cli.StringFlag{
Name: "config, c",
Usage: "Load configuration from `FULL_PATH_FILE`",
Expand Down

0 comments on commit a373597

Please sign in to comment.