Allow consul repo override via env (#9500)

This commit is contained in:
Freddy 2020-07-16 08:48:12 -06:00 committed by GitHub
parent faf2958cde
commit dc76fa6fe8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,7 @@ import (
consulapi "github.com/hashicorp/consul/api"
"github.com/hashicorp/vault/helper/testhelpers/docker"
"github.com/ory/dockertest"
dc "github.com/ory/dockertest/docker"
)
// PrepareTestContainer creates a Consul docker container. If version is empty,
@ -46,6 +47,14 @@ func PrepareTestContainer(t *testing.T, version string) (cleanup func(), retAddr
Tag: version,
Cmd: []string{"agent", "-dev", "-client", "0.0.0.0", "-hcl", config},
}
consulRepo := os.Getenv("CONSUL_DOCKER_REPO")
if consulRepo != "" {
dockerOptions.Repository = consulRepo
dockerOptions.Auth = dc.AuthConfiguration{
Username: os.Getenv("CONSUL_DOCKER_USERNAME"),
Password: os.Getenv("CONSUL_DOCKER_PASSWORD"),
}
}
resource, err := pool.RunWithOptions(dockerOptions)
if err != nil {
t.Fatalf("Could not start local Consul %s docker container: %s", version, err)