Skip to content

Commit 5d80844

Browse files
committed
[FAB-11052] begin adding nwo support for discovery
Change-Id: Iac1be44a5a64d37467e83fac968c84796af7d38d Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent edec005 commit 5d80844

File tree

4 files changed

+113
-0
lines changed

4 files changed

+113
-0
lines changed

integration/nwo/commands/discover.go

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

integration/nwo/components.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ func (c *Components) Build(args ...string) {
5151
peer, err := gexec.Build("github.com/hyperledger/fabric/peer", args...)
5252
Expect(err).NotTo(HaveOccurred())
5353
c.Paths["peer"] = peer
54+
55+
discover, err := gexec.Build("github.com/hyperledger/fabric/cmd/discover", args...)
56+
Expect(err).NotTo(HaveOccurred())
57+
c.Paths["discover"] = discover
5458
}
5559

5660
func (c *Components) Cleanup() {
@@ -66,3 +70,4 @@ func (c *Components) Idemixgen() string { return c.Paths["idemixgen"] }
6670
func (c *Components) ConfigTxGen() string { return c.Paths["configtxgen"] }
6771
func (c *Components) Orderer() string { return c.Paths["orderer"] }
6872
func (c *Components) Peer() string { return c.Paths["peer"] }
73+
func (c *Components) Discover() string { return c.Paths["discover"] }

integration/nwo/fabricconfig/core.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type Peer struct {
5050
AdminService *Service `yaml:"adminService,omitempty"`
5151
Handlers *Handlers `yaml:"handlers,omitempty"`
5252
ValidatorPoolSize int `yaml:"validatorPoolSize,omitempty"`
53+
Discovery *Discovery `yaml:"discovery,omitempty"`
5354

5455
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
5556
}
@@ -174,6 +175,14 @@ type Handler struct {
174175

175176
type HandlerMap map[string]Handler
176177

178+
type Discovery struct {
179+
Enabled bool `yaml:"enabled"`
180+
AuthCacheEnabled bool `yaml:"authCacheEnabled"`
181+
AuthCacheMaxSize int `yaml:"authCacheMaxSize,omitempty"`
182+
AuthCachePurgeRetentionRatio float64 `yaml:"authCachePurgeRetentionRatio"`
183+
OrgMembersAllowedAccess bool `yaml:"orgMembersAllowedAccess"`
184+
}
185+
177186
type VM struct {
178187
Endpoint string `yaml:"endpoint,omitempty"`
179188
Docker *Docker `yaml:"docker,omitempty"`

integration/nwo/network.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,12 @@ func (n *Network) ConfigTxGen(command Command) (*gexec.Session, error) {
643643
return n.StartSession(cmd, command.SessionName())
644644
}
645645

646+
// Discover starts a gexec.Session for the provided discover command.
647+
func (n *Network) Discover(command Command) (*gexec.Session, error) {
648+
cmd := NewCommand(n.Components.Discover(), command)
649+
return n.StartSession(cmd, command.SessionName())
650+
}
651+
646652
// ZooKeeperRunner returns a runner for a ZooKeeper instance.
647653
func (n *Network) ZooKeeperRunner(idx int) *runner.ZooKeeper {
648654
colorCode := n.nextColor()

0 commit comments

Comments
 (0)