Skip to content

Commit

Permalink
Implement mapping of env var to same var in host via empty value
Browse files Browse the repository at this point in the history
  • Loading branch information
silphid committed Jun 22, 2021
1 parent 5c38095 commit 98e33dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/internal/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type Context struct {
Image string
Build DockerBuild
Env map[string]string
HostEnv []string `yaml:"hostenv,omitempty"`
Mounts map[string]string
Cmd []string
EntryPoint []string
Expand All @@ -43,8 +42,6 @@ func (c Context) Clone() Context {
for key, value := range c.Build.Args {
clone.Build.Args[key] = value
}
clone.HostEnv = make([]string, len(c.HostEnv))
copy(clone.HostEnv, c.HostEnv)
return clone
}

Expand Down Expand Up @@ -76,7 +73,6 @@ func (c Context) Merge(source Context) Context {
if source.Network != "" {
merged.Network = source.Network
}
merged.HostEnv = append(merged.HostEnv, source.HostEnv...)
return merged
}

Expand Down
11 changes: 5 additions & 6 deletions src/internal/docker/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,11 @@ func runContainer(ctx context.Context, yeyCtx yey.Context, containerName string,

// Context env vars
for name, value := range yeyCtx.Env {
args = append(args, "--env", fmt.Sprintf("%s=%s", name, value))
}

// Env vars passed as-is from host
for _, name := range yeyCtx.HostEnv {
args = append(args, "--env", name)
arg := name
if value != "" {
arg = fmt.Sprintf("%s=%s", name, value)
}
args = append(args, "--env", arg)
}

// Mount binds
Expand Down

0 comments on commit 98e33dc

Please sign in to comment.