Skip to content

Commit

Permalink
Add support for dockerArgs.
Browse files Browse the repository at this point in the history
Fix cmd property merging.
  • Loading branch information
silphid committed Jan 26, 2022
1 parent d183956 commit 8a639d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ remove: <true | false (default)>
# Network name to connect container to (docker --network flag)
network: <string | "host" (default)>
# Individual arguments that will be passed to docker cli as is.
dockerArgs:
- <string>
...
# Optional Dockerfile to build and run
build:
# Dockerfile to build
Expand Down
3 changes: 3 additions & 0 deletions src/internal/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Context struct {
EntryPoint string `yaml:"entrypoint,omitempty"`
Cmd []string
Network string
DockerArgs []string `yaml:"dockerArgs,omitempty"`
}

// Clone returns a deep-copy of this context
Expand Down Expand Up @@ -89,6 +90,8 @@ func (c Context) Merge(source Context, withVariations bool) Context {
if source.Network != "" {
merged.Network = source.Network
}
merged.Cmd = append(merged.Cmd, source.Cmd...)
merged.DockerArgs = append(merged.DockerArgs, source.DockerArgs...)
return merged
}

Expand Down
5 changes: 5 additions & 0 deletions src/internal/docker/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ func runContainer(ctx context.Context, yeyCtx yey.Context, containerName string,
args = append(args, "--entrypoint", yeyCtx.EntryPoint)
}

// DockerArgs
if len(yeyCtx.DockerArgs) > 0 {
args = append(args, yeyCtx.DockerArgs...)
}

args = append(args, yeyCtx.Image)
args = append(args, yeyCtx.Cmd...)

Expand Down

0 comments on commit 8a639d4

Please sign in to comment.