Skip to content

Commit 4144b2c

Browse files
committed
Implement 'osnadmin channel info' subcommand and update tests hyperledger#4892
1 parent fb54947 commit 4144b2c

File tree

7 files changed

+128
-35
lines changed

7 files changed

+128
-35
lines changed

cmd/osnadmin/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ func executeForArgs(args []string) (output string, exit int, err error) {
5454
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.")
5555
listChannelID := list.Flag("channelID", "Channel ID").Short('c').String()
5656

57+
info := channel.Command("info", "Get detailed information about a specific channel.")
58+
infoChannelID := info.Flag("channelID", "Channel ID").Short('c').Required().String()
59+
5760
remove := channel.Command("remove", "Remove a channel from an Ordering Service Node (OSN).")
5861
removeChannelID := remove.Flag("channelID", "Channel ID").Short('c').Required().String()
5962

@@ -114,10 +117,12 @@ func executeForArgs(args []string) (output string, exit int, err error) {
114117
resp, err = osnadmin.Join(osnURL, marshaledConfigBlock, caCertPool, tlsClientCert)
115118
case list.FullCommand():
116119
if *listChannelID != "" {
117-
resp, err = osnadmin.ListSingleChannel(osnURL, *listChannelID, caCertPool, tlsClientCert)
120+
resp, err = osnadmin.Info(osnURL, *listChannelID, caCertPool, tlsClientCert)
118121
break
119122
}
120123
resp, err = osnadmin.ListAllChannels(osnURL, caCertPool, tlsClientCert)
124+
case info.FullCommand():
125+
resp, err = osnadmin.Info(osnURL, *infoChannelID, caCertPool, tlsClientCert)
121126
case remove.FullCommand():
122127
resp, err = osnadmin.Remove(osnURL, *removeChannelID, caCertPool, tlsClientCert)
123128
}

docs/source/commands/osnadminchannel.md

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ each orderer.
1515

1616
The `osnadmin channel` command has the following subcommands:
1717

18-
* join
19-
* list
20-
* remove
18+
- join
19+
- list
20+
- info
21+
- remove
2122

2223
## osnadmin channel
2324
```
@@ -51,6 +52,9 @@ Subcommands:
5152
channelID flag is set, more detailed information will be provided for that
5253
channel.
5354
55+
channel info --channelID=CHANNELID
56+
Get detailed information about a specific channel.
57+
5458
channel remove --channelID=CHANNELID
5559
Remove a channel from an Ordering Service Node (OSN).
5660
```
@@ -111,6 +115,31 @@ Flags:
111115
```
112116

113117

118+
## osnadmin channel info
119+
```
120+
usage: osnadmin channel info --channelID=CHANNELID
121+
122+
Get detailed information about a specific channel.
123+
124+
Flags:
125+
--help Show context-sensitive help (also try
126+
--help-long and --help-man).
127+
-o, --orderer-address=ORDERER-ADDRESS
128+
Admin endpoint of the OSN
129+
--ca-file=CA-FILE Path to file containing PEM-encoded TLS CA
130+
certificate(s) for the OSN
131+
--client-cert=CLIENT-CERT Path to file containing PEM-encoded X509 public
132+
key to use for mutual TLS communication with
133+
the OSN
134+
--client-key=CLIENT-KEY Path to file containing PEM-encoded private key
135+
to use for mutual TLS communication with the
136+
OSN
137+
--no-status Remove the HTTP status message from the command
138+
output
139+
-c, --channelID=CHANNELID Channel ID
140+
```
141+
142+
114143
## osnadmin channel remove
115144
```
116145
usage: osnadmin channel remove --channelID=CHANNELID
@@ -141,7 +170,7 @@ Flags:
141170

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

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

@@ -167,8 +196,8 @@ Here's an example of the `osnadmin channel join` command.
167196

168197
Here are some examples of the `osnadmin channel list` command.
169198

170-
* Listing all the channels that the orderer has joined.
171-
Note that the system channel will always be NULL because it is no longer supported from release v3.0 onwards.
199+
- Listing all the channels that the orderer has joined.
200+
Note that the system channel will always be NULL because it is no longer supported from release v3.0 onwards.
172201

173202
```
174203
osnadmin channel list -o orderer.example.com:9443 --ca-file $CA_FILE --client-cert $CLIENT_CERT --client-key $CLIENT_KEY
@@ -188,18 +217,40 @@ Note that the system channel will always be NULL because it is no longer support
188217

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

191-
* Using the `--channelID` flag to list more details for `mychannel`.
220+
- Using the `--channelID` flag to list more details for `mychannel`.
192221

193222
```
194223
osnadmin channel list -o orderer.example.com:9443 --ca-file $CA_FILE --client-cert $CLIENT_CERT --client-key $CLIENT_KEY --channelID mychannel
195224
196225
Status: 200
197226
{
198-
"name": "mychannel",
199-
"url": "/participation/v1/channels/mychannel",
200-
"consensusRelation": "consenter",
201-
"status": "active",
202-
"height": 3
227+
"name": "mychannel",
228+
"url": "/participation/v1/channels/mychannel",
229+
"consensusRelation": "consenter",
230+
"status": "active",
231+
"height": 3
232+
}
233+
234+
```
235+
236+
Status 200 and the details of the channels are returned.
237+
238+
### osnadmin channel info example
239+
240+
Here are some examples of the `osnadmin channel info` command.
241+
242+
- Using the `--channel-id` flag to get detailed information for mychannel from the orderer at `orderer.example.com:9443`.
243+
244+
```
245+
osnadmin channel info -o orderer.example.com:9443 --ca-file $CA_FILE --client-cert $CLIENT_CERT --client-key $CLIENT_KEY --channel-id mychannel
246+
247+
Status: 200
248+
{
249+
"name": "mychannel",
250+
"url": "/participation/v1/channels/mychannel",
251+
"consensusRelation": "consenter",
252+
"status": "active",
253+
"height": 3
203254
}
204255
205256
```
@@ -210,7 +261,7 @@ Note that the system channel will always be NULL because it is no longer support
210261

211262
Here's an example of the `osnadmin channel remove` command.
212263

213-
* Removing channel `mychannel` from the orderer at `orderer.example.com:9443`.
264+
- Removing channel `mychannel` from the orderer at `orderer.example.com:9443`.
214265

215266
```
216267
osnadmin channel remove -o orderer.example.com:9443 --ca-file $CA_FILE --client-cert $CLIENT_CERT --client-key $CLIENT_KEY --channelID mychannel

docs/wrappers/osnadmin_channel_postscript.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

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

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

@@ -30,8 +30,8 @@ Here's an example of the `osnadmin channel join` command.
3030

3131
Here are some examples of the `osnadmin channel list` command.
3232

33-
* Listing all the channels that the orderer has joined.
34-
Note that the system channel will always be NULL because it is no longer supported from release v3.0 onwards.
33+
- Listing all the channels that the orderer has joined.
34+
Note that the system channel will always be NULL because it is no longer supported from release v3.0 onwards.
3535

3636
```
3737
osnadmin channel list -o orderer.example.com:9443 --ca-file $CA_FILE --client-cert $CLIENT_CERT --client-key $CLIENT_KEY
@@ -51,18 +51,40 @@ Note that the system channel will always be NULL because it is no longer support
5151

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

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

5656
```
5757
osnadmin channel list -o orderer.example.com:9443 --ca-file $CA_FILE --client-cert $CLIENT_CERT --client-key $CLIENT_KEY --channelID mychannel
5858
5959
Status: 200
6060
{
61-
"name": "mychannel",
62-
"url": "/participation/v1/channels/mychannel",
63-
"consensusRelation": "consenter",
64-
"status": "active",
65-
"height": 3
61+
"name": "mychannel",
62+
"url": "/participation/v1/channels/mychannel",
63+
"consensusRelation": "consenter",
64+
"status": "active",
65+
"height": 3
66+
}
67+
68+
```
69+
70+
Status 200 and the details of the channels are returned.
71+
72+
### osnadmin channel info example
73+
74+
Here are some examples of the `osnadmin channel info` command.
75+
76+
- Using the `--channel-id` flag to get detailed information for mychannel from the orderer at `orderer.example.com:9443`.
77+
78+
```
79+
osnadmin channel info -o orderer.example.com:9443 --ca-file $CA_FILE --client-cert $CLIENT_CERT --client-key $CLIENT_KEY --channel-id mychannel
80+
81+
Status: 200
82+
{
83+
"name": "mychannel",
84+
"url": "/participation/v1/channels/mychannel",
85+
"consensusRelation": "consenter",
86+
"status": "active",
87+
"height": 3
6688
}
6789
6890
```
@@ -73,7 +95,7 @@ Note that the system channel will always be NULL because it is no longer support
7395

7496
Here's an example of the `osnadmin channel remove` command.
7597

76-
* Removing channel `mychannel` from the orderer at `orderer.example.com:9443`.
98+
- Removing channel `mychannel` from the orderer at `orderer.example.com:9443`.
7799

78100
```
79101
osnadmin channel remove -o orderer.example.com:9443 --ca-file $CA_FILE --client-cert $CLIENT_CERT --client-key $CLIENT_KEY --channelID mychannel

docs/wrappers/osnadmin_channel_preamble.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ each orderer.
1010

1111
The `osnadmin channel` command has the following subcommands:
1212

13-
* join
14-
* list
15-
* remove
13+
- join
14+
- list
15+
- info
16+
- remove

internal/osnadmin/info.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package osnadmin
8+
9+
import (
10+
"crypto/tls"
11+
"crypto/x509"
12+
"fmt"
13+
"net/http"
14+
)
15+
16+
// Lists a single channel an OSN is a member of.
17+
func Info(osnURL, channelID string, caCertPool *x509.CertPool, tlsClientCert tls.Certificate) (*http.Response, error) {
18+
url := fmt.Sprintf("%s/participation/v1/channels/%s", osnURL, channelID)
19+
20+
return httpGet(url, caCertPool, tlsClientCert)
21+
}

internal/osnadmin/list.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,3 @@ func ListAllChannels(osnURL string, caCertPool *x509.CertPool, tlsClientCert tls
1919

2020
return httpGet(url, caCertPool, tlsClientCert)
2121
}
22-
23-
// Lists a single channel an OSN is a member of.
24-
func ListSingleChannel(osnURL, channelID string, caCertPool *x509.CertPool, tlsClientCert tls.Certificate) (*http.Response, error) {
25-
url := fmt.Sprintf("%s/participation/v1/channels/%s", osnURL, channelID)
26-
27-
return httpGet(url, caCertPool, tlsClientCert)
28-
}

scripts/help_docs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ generateOrCheck \
134134
docs/wrappers/configtxlator_postscript.md \
135135
"${commands[@]}"
136136

137-
commands=("osnadmin channel" "osnadmin channel join" "osnadmin channel list" "osnadmin channel remove")
137+
commands=("osnadmin channel" "osnadmin channel join" "osnadmin channel list" "osnadmin channel info" "osnadmin channel remove")
138138
generateOrCheck \
139139
docs/source/commands/osnadminchannel.md \
140140
docs/wrappers/osnadmin_channel_preamble.md \

0 commit comments

Comments
 (0)