Skip to content

Commit

Permalink
chore: minio network (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
fracasula authored Sep 4, 2024
1 parent a7649f6 commit 7b26236
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions testhelper/docker/resource/minio/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package minio

import (
"github.com/ory/dockertest/v3/docker"
)

type Opt func(*Config)

func WithTag(tag string) Opt {
Expand All @@ -8,6 +12,12 @@ func WithTag(tag string) Opt {
}
}

func WithNetwork(network *docker.Network) Opt {
return func(c *Config) {
c.Network = network
}
}

func WithOptions(options ...string) Opt {
return func(c *Config) {
c.Options = options
Expand All @@ -16,5 +26,6 @@ func WithOptions(options ...string) Opt {

type Config struct {
Tag string
Network *docker.Network
Options []string
}
6 changes: 6 additions & 0 deletions testhelper/docker/resource/minio/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ func Setup(pool *dockertest.Pool, d resource.Cleaner, opts ...func(*Config)) (*R
opt(c)
}

var networkID string
if c.Network != nil {
networkID = c.Network.ID
}

minioContainer, err := pool.RunWithOptions(&dockertest.RunOptions{
Repository: "minio/minio",
Tag: c.Tag,
NetworkID: networkID,
Cmd: []string{"server", "/data"},
Env: append([]string{
fmt.Sprintf("MINIO_ACCESS_KEY=%s", accessKeyId),
Expand Down

0 comments on commit 7b26236

Please sign in to comment.