Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vpranckaitis committed Nov 25, 2020
1 parent 422c895 commit 7da7dd8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/cmd/tools/dtest/docker/harness/resources/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
Expand Down
31 changes: 10 additions & 21 deletions src/cmd/tools/dtest/docker/harness/resources/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}

0 comments on commit 7da7dd8

Please sign in to comment.