@@ -21,7 +21,7 @@ import (
21
21
"github.com/docker/docker/pkg/jsonmessage"
22
22
"github.com/docker/docker/pkg/stdcopy"
23
23
"github.com/docker/docker/registry"
24
- copystructure "github.com/mitchellh/copystructure"
24
+ "github.com/mitchellh/copystructure"
25
25
)
26
26
27
27
// Driver is capable of running Docker invocation images using Docker itself.
@@ -33,8 +33,8 @@ type Driver struct {
33
33
dockerConfigurationOptions []ConfigurationOption
34
34
containerOut io.Writer
35
35
containerErr io.Writer
36
- containerHostCfg * container.HostConfig
37
- containerCfg * container.Config
36
+ containerHostCfg container.HostConfig
37
+ containerCfg container.Config
38
38
}
39
39
40
40
// Run executes the Docker driver
@@ -55,33 +55,33 @@ func (d *Driver) AddConfigurationOptions(opts ...ConfigurationOption) {
55
55
// GetContainerConfig returns a copy of the container configuration
56
56
// used by the driver during container exec
57
57
func (d * Driver ) GetContainerConfig () (container.Config , error ) {
58
- cpy , err := copystructure .Copy (* d .containerCfg )
58
+ cpy , err := copystructure .Copy (d .containerCfg )
59
59
if err != nil {
60
60
return container.Config {}, err
61
61
}
62
62
63
- containerCfg , ok := cpy .(container.Config )
63
+ cfg , ok := cpy .(container.Config )
64
64
if ! ok {
65
65
return container.Config {}, errors .New ("unable to process container config" )
66
66
}
67
67
68
- return containerCfg , nil
68
+ return cfg , nil
69
69
}
70
70
71
71
// GetContainerHostConfig returns a copy of the container host configuration
72
72
// used by the driver during container exec
73
73
func (d * Driver ) GetContainerHostConfig () (container.HostConfig , error ) {
74
- cpy , err := copystructure .Copy (* d .containerHostCfg )
74
+ cpy , err := copystructure .Copy (d .containerHostCfg )
75
75
if err != nil {
76
76
return container.HostConfig {}, err
77
77
}
78
78
79
- hostCfg , ok := cpy .(container.HostConfig )
79
+ cfg , ok := cpy .(container.HostConfig )
80
80
if ! ok {
81
81
return container.HostConfig {}, errors .New ("unable to process container host config" )
82
82
}
83
83
84
- return hostCfg , nil
84
+ return cfg , nil
85
85
}
86
86
87
87
// Config returns the Docker driver configuration options
@@ -191,27 +191,27 @@ func (d *Driver) exec(op *driver.Operation) (driver.OperationResult, error) {
191
191
env = append (env , fmt .Sprintf ("%s=%v" , k , v ))
192
192
}
193
193
194
- d .containerCfg = & container.Config {
194
+ d .containerCfg = container.Config {
195
195
Image : op .Image .Image ,
196
196
Env : env ,
197
197
Entrypoint : strslice.StrSlice {"/cnab/app/run" },
198
198
AttachStderr : true ,
199
199
AttachStdout : true ,
200
200
}
201
201
202
- d .containerHostCfg = & container.HostConfig {}
203
- if err := d .applyConfigurationOptions (); err != nil {
202
+ d .containerHostCfg = container.HostConfig {}
203
+ if err := d .ApplyConfigurationOptions (); err != nil {
204
204
return driver.OperationResult {}, err
205
205
}
206
206
207
- resp , err := cli .Client ().ContainerCreate (ctx , d .containerCfg , d .containerHostCfg , nil , "" )
207
+ resp , err := cli .Client ().ContainerCreate (ctx , & d .containerCfg , & d .containerHostCfg , nil , "" )
208
208
switch {
209
209
case client .IsErrNotFound (err ):
210
210
fmt .Fprintf (cli .Err (), "Unable to find image '%s' locally\n " , op .Image .Image )
211
211
if err := pullImage (ctx , cli , op .Image .Image ); err != nil {
212
212
return driver.OperationResult {}, err
213
213
}
214
- if resp , err = cli .Client ().ContainerCreate (ctx , d .containerCfg , d .containerHostCfg , nil , "" ); err != nil {
214
+ if resp , err = cli .Client ().ContainerCreate (ctx , & d .containerCfg , & d .containerHostCfg , nil , "" ); err != nil {
215
215
return driver.OperationResult {}, fmt .Errorf ("cannot create container: %v" , err )
216
216
}
217
217
case err != nil :
@@ -293,9 +293,10 @@ func (d *Driver) exec(op *driver.Operation) (driver.OperationResult, error) {
293
293
return opResult , err
294
294
}
295
295
296
- func (d * Driver ) applyConfigurationOptions () error {
296
+ // ApplyConfigurationOptions applies the configuration options set on the driver
297
+ func (d * Driver ) ApplyConfigurationOptions () error {
297
298
for _ , opt := range d .dockerConfigurationOptions {
298
- if err := opt (d .containerCfg , d .containerHostCfg ); err != nil {
299
+ if err := opt (& d .containerCfg , & d .containerHostCfg ); err != nil {
299
300
return err
300
301
}
301
302
}
0 commit comments