Commit 5d808449 authored by Matthew Sykes's avatar Matthew Sykes
Browse files

[FAB-11052] begin adding nwo support for discovery



Change-Id: Iac1be44a5a64d37467e83fac968c84796af7d38d
Signed-off-by: default avatarMatthew Sykes <sykesmat@us.ibm.com>
parent edec005f
/*
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
}
......@@ -51,6 +51,10 @@ func (c *Components) Build(args ...string) {
peer, err := gexec.Build("github.com/hyperledger/fabric/peer", args...)
Expect(err).NotTo(HaveOccurred())
c.Paths["peer"] = peer
discover, err := gexec.Build("github.com/hyperledger/fabric/cmd/discover", args...)
Expect(err).NotTo(HaveOccurred())
c.Paths["discover"] = discover
}
func (c *Components) Cleanup() {
......@@ -66,3 +70,4 @@ func (c *Components) Idemixgen() string { return c.Paths["idemixgen"] }
func (c *Components) ConfigTxGen() string { return c.Paths["configtxgen"] }
func (c *Components) Orderer() string { return c.Paths["orderer"] }
func (c *Components) Peer() string { return c.Paths["peer"] }
func (c *Components) Discover() string { return c.Paths["discover"] }
......@@ -50,6 +50,7 @@ type Peer struct {
AdminService *Service `yaml:"adminService,omitempty"`
Handlers *Handlers `yaml:"handlers,omitempty"`
ValidatorPoolSize int `yaml:"validatorPoolSize,omitempty"`
Discovery *Discovery `yaml:"discovery,omitempty"`
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}
......@@ -174,6 +175,14 @@ type Handler struct {
type HandlerMap map[string]Handler
type Discovery struct {
Enabled bool `yaml:"enabled"`
AuthCacheEnabled bool `yaml:"authCacheEnabled"`
AuthCacheMaxSize int `yaml:"authCacheMaxSize,omitempty"`
AuthCachePurgeRetentionRatio float64 `yaml:"authCachePurgeRetentionRatio"`
OrgMembersAllowedAccess bool `yaml:"orgMembersAllowedAccess"`
}
type VM struct {
Endpoint string `yaml:"endpoint,omitempty"`
Docker *Docker `yaml:"docker,omitempty"`
......
......@@ -643,6 +643,12 @@ func (n *Network) ConfigTxGen(command Command) (*gexec.Session, error) {
return n.StartSession(cmd, command.SessionName())
}
// Discover starts a gexec.Session for the provided discover command.
func (n *Network) Discover(command Command) (*gexec.Session, error) {
cmd := NewCommand(n.Components.Discover(), command)
return n.StartSession(cmd, command.SessionName())
}
// ZooKeeperRunner returns a runner for a ZooKeeper instance.
func (n *Network) ZooKeeperRunner(idx int) *runner.ZooKeeper {
colorCode := n.nextColor()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment