@@ -25,7 +25,7 @@ import (
25
25
"gopkg.in/yaml.v2"
26
26
)
27
27
28
- const networkName = "ethplayground"
28
+ const defaultNetworkName = "ethplayground"
29
29
30
30
// LocalRunner is a component that runs the services from the manifest on the local host machine.
31
31
// By default, it uses docker and docker compose to run all the services.
@@ -67,6 +67,9 @@ type LocalRunner struct {
67
67
// sessionID is a random sequence that is used to identify the session
68
68
// it is used to identify the containers in the cleanup process
69
69
sessionID string
70
+
71
+ // networkName is the name of the network to use for the services
72
+ networkName string
70
73
}
71
74
72
75
type task struct {
@@ -96,7 +99,8 @@ func newDockerClient() (*client.Client, error) {
96
99
return client , nil
97
100
}
98
101
99
- func NewLocalRunner (out * output , manifest * Manifest , overrides map [string ]string , interactive bool , bindHostPortsLocally bool ) (* LocalRunner , error ) {
102
+ // TODO: add a runner config struct
103
+ func NewLocalRunner (out * output , manifest * Manifest , overrides map [string ]string , interactive bool , bindHostPortsLocally bool , networkName string ) (* LocalRunner , error ) {
100
104
client , err := newDockerClient ()
101
105
if err != nil {
102
106
return nil , fmt .Errorf ("failed to create docker client: %w" , err )
@@ -141,6 +145,9 @@ func NewLocalRunner(out *output, manifest *Manifest, overrides map[string]string
141
145
}
142
146
}
143
147
148
+ if networkName == "" {
149
+ networkName = defaultNetworkName
150
+ }
144
151
d := & LocalRunner {
145
152
out : out ,
146
153
manifest : manifest ,
@@ -153,6 +160,7 @@ func NewLocalRunner(out *output, manifest *Manifest, overrides map[string]string
153
160
exitErr : make (chan error , 2 ),
154
161
bindHostPortsLocally : bindHostPortsLocally ,
155
162
sessionID : uuid .New ().String (),
163
+ networkName : networkName ,
156
164
}
157
165
158
166
if interactive {
@@ -563,7 +571,7 @@ func (d *LocalRunner) toDockerComposeService(s *service) (map[string]interface{}
563
571
fmt .Sprintf ("%s:/artifacts" , outputFolder ),
564
572
},
565
573
// Add the ethereum network
566
- "networks" : []string {networkName },
574
+ "networks" : []string {d . networkName },
567
575
"labels" : labels ,
568
576
}
569
577
@@ -648,8 +656,8 @@ func (d *LocalRunner) generateDockerCompose() ([]byte, error) {
648
656
// We create a new network to be used by all the services so that
649
657
// we can do DNS discovery between them.
650
658
"networks" : map [string ]interface {}{
651
- networkName : map [string ]interface {}{
652
- "name" : networkName ,
659
+ d . networkName : map [string ]interface {}{
660
+ "name" : d . networkName ,
653
661
},
654
662
},
655
663
}
0 commit comments