Skip to content

Commit

Permalink
Minor updates related to documentation for commands and more osnadmin…
Browse files Browse the repository at this point in the history
… updates (release-2.3) (#2322)

* Avoid os.Exit behavior when an osnadmin test fails

This change returns an error from `executeForArgs` when the command line
cannot be parsed. Without this change, tests that use the function
quietly exit without a clear indication as to why.

Signed-off-by: Matthew Sykes <[email protected]>

* generateHelpDocs filters trailing space from text

- Change the generateHelpDocs script to remove trailing spaces from the
  generated help text. This prevents linting failures from
  check_trailingspaces.sh
- Remove trailing space from osnadmin_channel_postscript.md
- Regenerate the help docs with `make help-docs`

Signed-off-by: Matthew Sykes <[email protected]>

* Fix channelID flag reference in osnadmin help

Signed-off-by: Matthew Sykes <[email protected]>
  • Loading branch information
sykesm authored Jan 28, 2021
1 parent c29420c commit 8dc9930
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 29 deletions.
7 changes: 5 additions & 2 deletions cmd/osnadmin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ func executeForArgs(args []string) (output string, exit int, err error) {
joinChannelID := join.Flag("channelID", "Channel ID").Short('c').Required().String()
configBlockPath := join.Flag("config-block", "Path to the file containing an up-to-date config block for the channel").Short('b').Required().String()

list := channel.Command("list", "List channel information for an Ordering Service Node (OSN). If the channel-id flag is set, more detailed information will be provided for that channel.")
list := channel.Command("list", "List channel information for an Ordering Service Node (OSN). If the channelID flag is set, more detailed information will be provided for that channel.")
listChannelID := list.Flag("channelID", "Channel ID").Short('c').String()

remove := channel.Command("remove", "Remove an Ordering Service Node (OSN) from a channel.")
removeChannelID := remove.Flag("channelID", "Channel ID").Short('c').Required().String()

command := kingpin.MustParse(app.Parse(args))
command, err := app.Parse(args)
if err != nil {
return "", 1, err
}

//
// flag validation
Expand Down
12 changes: 12 additions & 0 deletions cmd/osnadmin/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,18 @@ var _ = Describe("osnadmin", func() {
checkOutput(output, exit, err, 201, expectedOutput)
})

Context("when an unknown flag is used", func() {
It("returns an error for long flags", func() {
_, _, err := executeForArgs([]string{"channel", "list", "--bad-flag"})
Expect(err).To(MatchError("unknown long flag '--bad-flag'"))
})

It("returns an error for short flags", func() {
_, _, err := executeForArgs([]string{"channel", "list", "-z"})
Expect(err).To(MatchError("unknown short flag '-z'"))
})
})

Context("when the ca cert cannot be read", func() {
BeforeEach(func() {
ordererCACert = "not-the-ca-cert-youre-looking-for"
Expand Down
38 changes: 19 additions & 19 deletions docs/source/commands/osnadminchannel.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Channel actions
Flags:
--help Show context-sensitive help (also try
--help-long and --help-man).
-o, --orderer-address=ORDERER-ADDRESS
-o, --orderer-address=ORDERER-ADDRESS
Admin endpoint of the OSN
--ca-file=CA-FILE Path to file containing PEM-encoded TLS CA
certificate(s) for the OSN
Expand All @@ -39,31 +39,31 @@ Flags:
OSN
Subcommands:
channel join --channelID=CHANNEL-ID --config-block=CONFIG-BLOCK
channel join --channelID=CHANNELID --config-block=CONFIG-BLOCK
Join an Ordering Service Node (OSN) to a channel. If the channel does not
yet exist, it will be created.
channel list [<flags>]
List channel information for an Ordering Service Node (OSN). If the
channel-id flag is set, more detailed information will be provided for that
channelID flag is set, more detailed information will be provided for that
channel.
channel remove --channelID=CHANNEL-ID
channel remove --channelID=CHANNELID
Remove an Ordering Service Node (OSN) from a channel.
```


## osnadmin channel join
```
usage: osnadmin channel join --channelID=CHANNEL-ID --config-block=CONFIG-BLOCK
usage: osnadmin channel join --channelID=CHANNELID --config-block=CONFIG-BLOCK
Join an Ordering Service Node (OSN) to a channel. If the channel does not yet
exist, it will be created.
Flags:
--help Show context-sensitive help (also try
--help-long and --help-man).
-o, --orderer-address=ORDERER-ADDRESS
-o, --orderer-address=ORDERER-ADDRESS
Admin endpoint of the OSN
--ca-file=CA-FILE Path to file containing PEM-encoded TLS CA
certificate(s) for the OSN
Expand All @@ -73,8 +73,8 @@ Flags:
--client-key=CLIENT-KEY Path to file containing PEM-encoded private key
to use for mutual TLS communication with the
OSN
-c, --channelID=CHANNEL-ID Channel ID
-b, --config-block=CONFIG-BLOCK
-c, --channelID=CHANNELID Channel ID
-b, --config-block=CONFIG-BLOCK
Path to the file containing an up-to-date
config block for the channel
```
Expand All @@ -84,13 +84,13 @@ Flags:
```
usage: osnadmin channel list [<flags>]
List channel information for an Ordering Service Node (OSN). If the channel-id
List channel information for an Ordering Service Node (OSN). If the channelID
flag is set, more detailed information will be provided for that channel.
Flags:
--help Show context-sensitive help (also try
--help-long and --help-man).
-o, --orderer-address=ORDERER-ADDRESS
-o, --orderer-address=ORDERER-ADDRESS
Admin endpoint of the OSN
--ca-file=CA-FILE Path to file containing PEM-encoded TLS CA
certificate(s) for the OSN
Expand All @@ -100,20 +100,20 @@ Flags:
--client-key=CLIENT-KEY Path to file containing PEM-encoded private key
to use for mutual TLS communication with the
OSN
-c, --channelID=CHANNEL-ID Channel ID
-c, --channelID=CHANNELID Channel ID
```


## osnadmin channel remove
```
usage: osnadmin channel remove --channelID=CHANNEL-ID
usage: osnadmin channel remove --channelID=CHANNELID
Remove an Ordering Service Node (OSN) from a channel.
Flags:
--help Show context-sensitive help (also try
--help-long and --help-man).
-o, --orderer-address=ORDERER-ADDRESS
-o, --orderer-address=ORDERER-ADDRESS
Admin endpoint of the OSN
--ca-file=CA-FILE Path to file containing PEM-encoded TLS CA
certificate(s) for the OSN
Expand All @@ -123,7 +123,7 @@ Flags:
--client-key=CLIENT-KEY Path to file containing PEM-encoded private key
to use for mutual TLS communication with the
OSN
-c, --channelID=CHANNEL-ID Channel ID
-c, --channelID=CHANNELID Channel ID
```

## Example Usage
Expand All @@ -132,7 +132,7 @@ Flags:

Here's an example of the `osnadmin channel join` command.

* Create and join a sample channel `mychannel` defined by the application channel genesis
* Create and join a sample channel `mychannel` defined by the application channel genesis
block contained in file `mychannel-genesis-block.pb`. Use the orderer admin endpoint
at `orderer.example.com:9443`.

Expand Down Expand Up @@ -162,7 +162,7 @@ Here are some examples of the `osnadmin channel list` command.
system channel (if one exists) and all of the application channels.

```
osnadmin channel list -o orderer.example.com:9443 --ca-file $CA_FILE --client-cert $CLIENT_CERT --client-key $CLIENT_KEY
osnadmin channel list -o orderer.example.com:9443 --ca-file $CA_FILE --client-cert $CLIENT_CERT --client-key $CLIENT_KEY
Status: 200
{
Expand All @@ -177,7 +177,7 @@ Here are some examples of the `osnadmin channel list` command.
```

Status 200 and the list of channels are returned.
Status 200 and the list of channels are returned.

* Using the `--channelID` flag to list more details for `mychannel`.

Expand All @@ -195,7 +195,7 @@ Here are some examples of the `osnadmin channel list` command.
```

Status 200 and the details of the channels are returned.
Status 200 and the details of the channels are returned.

### osnadmin channel remove example

Expand All @@ -209,6 +209,6 @@ Here's an example of the `osnadmin channel remove` command.
Status: 204
```

Status 204 is returned upon successful removal of a channel.
Status 204 is returned upon successful removal of a channel.

<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
2 changes: 1 addition & 1 deletion docs/source/commands/peerlifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ also outputs which organizations have approved the chaincode definition. If an
organization has approved the chaincode definition specified in the command, the
command will return a value of true. You can use this command to learn whether enough
channel members have approved a chaincode definition to meet the
`Application/Channel/Endorsement` policy (a majority by default) before the
`/Channel/Application/Endorsement` policy (a majority by default) before the
definition can be committed to a channel.
* Here is an example of the `peer lifecycle chaincode checkcommitreadiness` command,
Expand Down
10 changes: 5 additions & 5 deletions docs/wrappers/osnadmin_channel_postscript.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Here's an example of the `osnadmin channel join` command.

* Create and join a sample channel `mychannel` defined by the application channel genesis
* Create and join a sample channel `mychannel` defined by the application channel genesis
block contained in file `mychannel-genesis-block.pb`. Use the orderer admin endpoint
at `orderer.example.com:9443`.

Expand Down Expand Up @@ -34,7 +34,7 @@ Here are some examples of the `osnadmin channel list` command.
system channel (if one exists) and all of the application channels.

```
osnadmin channel list -o orderer.example.com:9443 --ca-file $CA_FILE --client-cert $CLIENT_CERT --client-key $CLIENT_KEY
osnadmin channel list -o orderer.example.com:9443 --ca-file $CA_FILE --client-cert $CLIENT_CERT --client-key $CLIENT_KEY
Status: 200
{
Expand All @@ -49,7 +49,7 @@ Here are some examples of the `osnadmin channel list` command.
```

Status 200 and the list of channels are returned.
Status 200 and the list of channels are returned.

* Using the `--channelID` flag to list more details for `mychannel`.

Expand All @@ -67,7 +67,7 @@ Here are some examples of the `osnadmin channel list` command.
```

Status 200 and the details of the channels are returned.
Status 200 and the details of the channels are returned.

### osnadmin channel remove example

Expand All @@ -81,6 +81,6 @@ Here's an example of the `osnadmin channel remove` command.
Status: 204
```

Status 204 is returned upon successful removal of a channel.
Status 204 is returned upon successful removal of a channel.

<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
2 changes: 1 addition & 1 deletion docs/wrappers/peer_lifecycle_chaincode_postscript.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ also outputs which organizations have approved the chaincode definition. If an
organization has approved the chaincode definition specified in the command, the
command will return a value of true. You can use this command to learn whether enough
channel members have approved a chaincode definition to meet the
`Application/Channel/Endorsement` policy (a majority by default) before the
`/Channel/Application/Endorsement` policy (a majority by default) before the
definition can be committed to a channel.
* Here is an example of the `peer lifecycle chaincode checkcommitreadiness` command,
Expand Down
2 changes: 1 addition & 1 deletion scripts/generateHelpDocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ generateHelpText(){
## $x
\`\`\`
$($x --help 2>&1)
$($x --help 2>&1 | sed -E 's/[[:space:]]+$//g')
\`\`\`
EOF
Expand Down

0 comments on commit 8dc9930

Please sign in to comment.