forked from Hyperledger-TWGC/fabric
-
Notifications
You must be signed in to change notification settings - Fork 0
/
components.go
71 lines (52 loc) · 1.58 KB
/
components.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
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package nwo
import (
"fmt"
"io/ioutil"
"net/http"
"github.com/hyperledger/fabric/integration/runner"
. "github.com/onsi/gomega"
)
type Components struct {
ServerAddress string `json:"server_address"`
}
func (c *Components) ConfigTxGen() string {
return c.Build("github.com/hyperledger/fabric/cmd/configtxgen")
}
func (c *Components) Cryptogen() string {
return c.Build("github.com/hyperledger/fabric/cmd/cryptogen")
}
func (c *Components) Discover() string {
return c.Build("github.com/hyperledger/fabric/cmd/discover")
}
func (c *Components) Idemixgen() string {
return c.Build("github.com/hyperledger/fabric/cmd/idemixgen")
}
func (c *Components) Orderer() string {
return c.Build("github.com/hyperledger/fabric/cmd/orderer")
}
func (c *Components) Peer() string {
return c.Build("github.com/hyperledger/fabric/cmd/peer")
}
func (c *Components) Cleanup() {}
func (c *Components) Build(path string) string {
Expect(c.ServerAddress).NotTo(BeEmpty(), "build server address is empty")
resp, err := http.Get(fmt.Sprintf("http://%s/%s", c.ServerAddress, path))
Expect(err).NotTo(HaveOccurred())
body, err := ioutil.ReadAll(resp.Body)
Expect(err).NotTo(HaveOccurred())
if resp.StatusCode != http.StatusOK {
Expect(resp.StatusCode).To(Equal(http.StatusOK), fmt.Sprintf("%s", body))
}
return string(body)
}
const CCEnvDefaultImage = "hyperledger/fabric-ccenv:latest"
var RequiredImages = []string{
CCEnvDefaultImage,
runner.CouchDBDefaultImage,
runner.KafkaDefaultImage,
runner.ZooKeeperDefaultImage,
}