This repository has been archived by the owner on Nov 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
components.go
75 lines (60 loc) · 2.18 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
72
73
74
75
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package nwo
import (
"fmt"
"os"
"runtime"
"github.com/hyperledger/fabric/integration/helpers"
"github.com/hyperledger/fabric/integration/runner"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
type Components struct {
Paths map[string]string
}
var RequiredImages = []string{
fmt.Sprintf("hyperledger/fabric-ccenv:%s-latest", runtime.GOARCH),
runner.CouchDBDefaultImage,
runner.KafkaDefaultImage,
runner.ZooKeeperDefaultImage,
}
func (c *Components) Build(args ...string) {
helpers.AssertImagesExist(RequiredImages...)
if c.Paths == nil {
c.Paths = map[string]string{}
}
cryptogen, err := gexec.Build("github.com/hyperledger/fabric/common/tools/cryptogen", args...)
Expect(err).NotTo(HaveOccurred())
c.Paths["cryptogen"] = cryptogen
idemixgen, err := gexec.Build("github.com/hyperledger/fabric/common/tools/idemixgen", args...)
Expect(err).NotTo(HaveOccurred())
c.Paths["idemixgen"] = idemixgen
configtxgen, err := gexec.Build("github.com/hyperledger/fabric/common/tools/configtxgen", args...)
Expect(err).NotTo(HaveOccurred())
c.Paths["configtxgen"] = configtxgen
orderer, err := gexec.Build("github.com/hyperledger/fabric/orderer", args...)
Expect(err).NotTo(HaveOccurred())
c.Paths["orderer"] = orderer
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() {
for _, path := range c.Paths {
err := os.Remove(path)
Expect(err).NotTo(HaveOccurred())
}
gexec.CleanupBuildArtifacts()
}
func (c *Components) Cryptogen() string { return c.Paths["cryptogen"] }
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"] }