diff --git a/src/cmd/tools/dtest/docker/harness/resources/harness.go b/src/cmd/tools/dtest/docker/harness/resources/harness.go index db316a2517..8c89688a32 100644 --- a/src/cmd/tools/dtest/docker/harness/resources/harness.go +++ b/src/cmd/tools/dtest/docker/harness/resources/harness.go @@ -66,8 +66,8 @@ type dockerResources struct { // single DB node. func SetupSingleM3DBNode(opts ...SetupOptions) (DockerResources, error) { options := setupOptions{} - for _, o := range opts { - o.apply(&options) + for _, f := range opts { + f(&options) } pool, err := dockertest.NewPool("") diff --git a/src/cmd/tools/dtest/docker/harness/resources/options.go b/src/cmd/tools/dtest/docker/harness/resources/options.go index 8dab4aecf0..aa1ab92da1 100644 --- a/src/cmd/tools/dtest/docker/harness/resources/options.go +++ b/src/cmd/tools/dtest/docker/harness/resources/options.go @@ -30,30 +30,19 @@ type setupOptions struct { coordinatorImage dockerImage } -type SetupOptions interface { - apply(*setupOptions) -} - -type dbnodeImageNameOption struct { - dockerImage -} - -func (o dbnodeImageNameOption) apply(opts *setupOptions) { - opts.dbNodeImage = o.dockerImage -} +// SetupOptions is used for passing docker test setup parameters +type SetupOptions func(*setupOptions) +// WithDBNodeImage sets the name and tag of m3dbnode docker image to be used func WithDBNodeImage(name, tag string) SetupOptions { - return dbnodeImageNameOption{dockerImage{name, tag}} -} - -type coordinatorImageNameOption struct { - dockerImage -} - -func (o coordinatorImageNameOption) apply(opts *setupOptions) { - opts.coordinatorImage = o.dockerImage + return func(o *setupOptions) { + o.dbNodeImage = dockerImage{name, tag} + } } +// WithCoordinatorImage sets the name and tag of m3coordinator docker image to be used func WithCoordinatorImage(name, tag string) SetupOptions { - return coordinatorImageNameOption{dockerImage{name, tag}} + return func(o *setupOptions) { + o.coordinatorImage = dockerImage{name, tag} + } }