-
Notifications
You must be signed in to change notification settings - Fork 0
/
discover.go
93 lines (82 loc) · 1.61 KB
/
discover.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package commands
type Peers struct {
UserCert string
UserKey string
MSPID string
Server string
Channel string
}
func (p Peers) SessionName() string {
return "discover-peers"
}
func (p Peers) Args() []string {
return []string{
"--userCert", p.UserCert,
"--userKey", p.UserKey,
"--MSP", p.MSPID,
"peers",
"--server", p.Server,
"--channel", p.Channel,
}
}
type Config struct {
UserCert string
UserKey string
MSPID string
Server string
Channel string
}
func (c Config) SessionName() string {
return "discover-config"
}
func (c Config) Args() []string {
return []string{
"--userCert", c.UserCert,
"--userKey", c.UserKey,
"--MSP", c.MSPID,
"config",
"--server", c.Server,
"--channel", c.Channel,
}
}
type Endorsers struct {
UserCert string
UserKey string
MSPID string
Server string
Channel string
Chaincode string
Chaincodes []string
Collection string
Collections []string
}
func (e Endorsers) SessionName() string {
return "discover-endorsers"
}
func (e Endorsers) Args() []string {
args := []string{
"--userCert", e.UserCert,
"--userKey", e.UserKey,
"--MSP", e.MSPID,
"endorsers",
"--server", e.Server,
"--channel", e.Channel,
}
if e.Chaincode != "" {
args = append(args, "--chaincode", e.Chaincode)
}
for _, cc := range e.Chaincodes {
args = append(args, "--chaincode", cc)
}
if e.Collection != "" {
args = append(args, "--collection", e.Collection)
}
for _, c := range e.Collections {
args = append(args, "--collection", c)
}
return args
}