-
Notifications
You must be signed in to change notification settings - Fork 836
/
node.go
57 lines (48 loc) · 1.54 KB
/
node.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
package upgrade
import "github.com/ory/dockertest/v3"
const jrpcPort = "8545"
// Node defines evmos node params for running container
// of specific version with custom docker run arguments
type Node struct {
repository string
version string
RunOptions *dockertest.RunOptions
withRunOptions bool
}
// NewNode creates new instance of the node and setups default dockertest RunOptions
func NewNode(repository, version string) *Node {
return &Node{
repository: repository,
version: version,
RunOptions: &dockertest.RunOptions{
Repository: repository,
Tag: version,
// exposing JSON-RPC port by default to ping node after start
ExposedPorts: []string{jrpcPort},
},
}
}
// SetEnvVars allows to set addition container environment variables in format
// []string{ "VAR_NAME=valaue" }
func (n *Node) SetEnvVars(vars []string) {
n.RunOptions.Env = vars
n.UseRunOptions()
}
// Mount sets the container mount point, which is used as the value for 'docker run --volume'
//
// See https://docs.docker.com/engine/reference/builder/#volume
func (n *Node) Mount(mountPath string) {
n.RunOptions.Mounts = []string{mountPath}
n.UseRunOptions()
}
// SetCmd sets the container entry command and overrides the image CMD instruction
//
// See https://docs.docker.com/engine/reference/builder/#cmd
func (n *Node) SetCmd(cmd []string) {
n.RunOptions.Cmd = cmd
n.UseRunOptions()
}
// UseRunOptions sets a flag to allow the node Manager to run the container with additional run options
func (n *Node) UseRunOptions() {
n.withRunOptions = true
}