Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Refactoring: move docker driver Simulate field as a config parameter. #673

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pkg/driver/docker_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ import (

// DockerDriver is capable of running Docker invocation images using Docker itself.
type DockerDriver struct {
config map[string]string
// If true, this will not actually run Docker
Simulate bool
config map[string]string
dockerCli command.Cli
dockerConfigurationOptions []DockerConfigurationOption
containerOut io.Writer
Expand All @@ -50,6 +48,7 @@ func (d *DockerDriver) AddConfigurationOptions(opts ...DockerConfigurationOption
// Config returns the Docker driver configuration options
func (d *DockerDriver) Config() map[string]string {
return map[string]string{
"SIMULATE": "If enabled (0|1), this will actually prevent Docker from running",
"VERBOSE": "Increase verbosity. true, false are supported values",
"PULL_ALWAYS": "Always pull image, even if locally available (0|1)",
"DOCKER_DRIVER_QUIET": "Make the Docker driver quiet (only print container stdout/stderr)",
Expand Down Expand Up @@ -131,7 +130,7 @@ func (d *DockerDriver) exec(op *Operation) error {
return err
}

if d.Simulate {
if d.config["SIMULATE"] == "1" {
return nil
}
if d.config["PULL_ALWAYS"] == "1" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestDockerDriver_Run(t *testing.T) {
d, err := Lookup("docker")

// Don't actually run Docker
d.(*DockerDriver).Simulate = true
d.(*DockerDriver).SetConfig(map[string]string{"SIMULATE": "1"})

is := assert.New(t)
is.NoError(err)
Expand Down