Skip to content

Commit

Permalink
chore: transformer network
Browse files Browse the repository at this point in the history
  • Loading branch information
fracasula committed Sep 25, 2024
1 parent 4f65bca commit fa721d3
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions testhelper/docker/resource/transformer/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import (
"net/http"
"strings"

"github.com/samber/lo"

dockertesthelper "github.com/rudderlabs/rudder-go-kit/testhelper/docker"

"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
"github.com/samber/lo"

"github.com/rudderlabs/rudder-go-kit/httputil"
dockertesthelper "github.com/rudderlabs/rudder-go-kit/testhelper/docker"
"github.com/rudderlabs/rudder-go-kit/testhelper/docker/resource"
"github.com/rudderlabs/rudder-go-kit/testhelper/docker/resource/internal"
)
Expand All @@ -30,6 +28,7 @@ type config struct {
exposedPorts []string
envs []string
extraHosts []string
network *docker.Network
}

func (c *config) setBackendConfigURL(url string) {
Expand Down Expand Up @@ -90,6 +89,12 @@ func WithDockerImageTag(tag string) func(*config) {
}
}

func WithDockerNetwork(network *docker.Network) func(*config) {
return func(conf *config) {
conf.network = network
}
}

func Setup(pool *dockertest.Pool, d resource.Cleaner, opts ...func(conf *config)) (*Resource, error) {
// Set Rudder Transformer
// pulls an image first to make sure we don't have an old cached version locally,
Expand All @@ -115,12 +120,17 @@ func Setup(pool *dockertest.Pool, d resource.Cleaner, opts ...func(conf *config)
return nil, fmt.Errorf("failed to pull image: %w", err)
}

var networkID string
if conf.network != nil {
networkID = conf.network.ID
}
transformerContainer, err := pool.RunWithOptions(&dockertest.RunOptions{
Repository: conf.repository,
Tag: conf.tag,
PortBindings: internal.IPv4PortBindings(conf.exposedPorts),
Env: conf.envs,
ExtraHosts: conf.extraHosts,
NetworkID: networkID,
}, internal.DefaultHostConfig)
if err != nil {
return nil, err
Expand Down

0 comments on commit fa721d3

Please sign in to comment.