Skip to content

Commit 1c9e828

Browse files
authored
Add env variable support (#80)
* Add env varible support * Fix
1 parent f9cd167 commit 1c9e828

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

internal/components.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func (o *OpNode) Run(service *service, ctx *ExContext) {
7070
WithImage("us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node").
7171
WithTag("v1.11.0").
7272
WithEntrypoint("op-node").
73+
WithEnv("A", "B"). // this is just a placeholder to make sure env works since we e2e test with the recipes
7374
WithArgs(
7475
"--l1", Connect(o.L1Node, "http"),
7576
"--l1.beacon", Connect(o.L1Beacon, "http"),

internal/local_runner.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ func (d *LocalRunner) toDockerComposeService(s *service) (map[string]interface{}
383383
"labels": map[string]string{"playground": "true"},
384384
}
385385

386+
if len(s.env) > 0 {
387+
service["environment"] = s.env
388+
}
389+
386390
if runtime.GOOS == "linux" {
387391
// We rely on host.docker.internal as the DNS address for the host inside
388392
// the container. But, this is only available on Macos and Windows.

internal/manifest.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ type service struct {
296296

297297
labels map[string]string
298298

299+
// list of environment variables to set for the service
300+
env map[string]string
301+
299302
ports []*Port
300303
nodeRefs []*NodeRef
301304

@@ -333,6 +336,14 @@ func (s *service) UseHostExecution() *service {
333336
return s
334337
}
335338

339+
func (s *service) WithEnv(key, value string) *service {
340+
if s.env == nil {
341+
s.env = make(map[string]string)
342+
}
343+
s.env[key] = value
344+
return s
345+
}
346+
336347
func (s *service) WithLabel(key, value string) *service {
337348
if s.labels == nil {
338349
s.labels = make(map[string]string)

0 commit comments

Comments
 (0)