-
Notifications
You must be signed in to change notification settings - Fork 0
/
orderer.go
48 lines (40 loc) · 1.11 KB
/
orderer.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
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package runner
import (
"fmt"
"os/exec"
"github.com/tedsuo/ifrit/ginkgomon"
)
type Orderer struct {
Path string
ConfigDir string
LedgerLocation string
ConfigtxOrdererKafkaBrokers string
LogLevel string
}
func (o *Orderer) setupEnvironment(cmd *exec.Cmd) {
if o.ConfigDir != "" {
cmd.Env = append(cmd.Env, fmt.Sprintf("FABRIC_CFG_PATH=%s", o.ConfigDir))
}
if o.LedgerLocation != "" {
cmd.Env = append(cmd.Env, fmt.Sprintf("ORDERER_FILELEDGER_LOCATION=%s", o.LedgerLocation))
}
if o.ConfigtxOrdererKafkaBrokers != "" {
cmd.Env = append(cmd.Env, fmt.Sprintf("CONFIGTX_ORDERER_KAFKA_BROKERS=%s", o.ConfigtxOrdererKafkaBrokers))
}
if o.LogLevel != "" {
cmd.Env = append(cmd.Env, fmt.Sprintf("ORDERER_GENERAL_LOGLEVEL=%s", o.LogLevel))
}
}
func (o *Orderer) New() *ginkgomon.Runner {
cmd := exec.Command(o.Path)
o.setupEnvironment(cmd)
return ginkgomon.New(ginkgomon.Config{
Name: "orderer",
AnsiColorCode: "35m",
Command: cmd,
})
}