Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: transformer network #656

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading