github.com/anjalikarhana/fabric@v2.1.1+incompatible/integration/nwo/components.go (about) 1 /* 2 Copyright IBM Corp All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package nwo 8 9 import ( 10 "fmt" 11 "io/ioutil" 12 "net/http" 13 14 "github.com/hyperledger/fabric/integration/runner" 15 . "github.com/onsi/gomega" 16 ) 17 18 type Components struct { 19 ServerAddress string `json:"server_address"` 20 } 21 22 func (c *Components) ConfigTxGen() string { 23 return c.Build("github.com/hyperledger/fabric/cmd/configtxgen") 24 } 25 26 func (c *Components) Cryptogen() string { 27 return c.Build("github.com/hyperledger/fabric/cmd/cryptogen") 28 } 29 30 func (c *Components) Discover() string { 31 return c.Build("github.com/hyperledger/fabric/cmd/discover") 32 } 33 34 func (c *Components) Idemixgen() string { 35 return c.Build("github.com/hyperledger/fabric/cmd/idemixgen") 36 } 37 38 func (c *Components) Orderer() string { 39 return c.Build("github.com/hyperledger/fabric/cmd/orderer") 40 } 41 42 func (c *Components) Peer() string { 43 return c.Build("github.com/hyperledger/fabric/cmd/peer") 44 } 45 46 func (c *Components) Cleanup() {} 47 48 func (c *Components) Build(path string) string { 49 Expect(c.ServerAddress).NotTo(BeEmpty(), "build server address is empty") 50 51 resp, err := http.Get(fmt.Sprintf("http://%s/%s", c.ServerAddress, path)) 52 Expect(err).NotTo(HaveOccurred()) 53 54 body, err := ioutil.ReadAll(resp.Body) 55 Expect(err).NotTo(HaveOccurred()) 56 57 if resp.StatusCode != http.StatusOK { 58 Expect(resp.StatusCode).To(Equal(http.StatusOK), fmt.Sprintf("%s", body)) 59 } 60 61 return string(body) 62 } 63 64 const CCEnvDefaultImage = "hyperledger/fabric-ccenv:latest" 65 66 var RequiredImages = []string{ 67 CCEnvDefaultImage, 68 runner.CouchDBDefaultImage, 69 runner.KafkaDefaultImage, 70 runner.ZooKeeperDefaultImage, 71 }