Run oidc tests fully in docker

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby 2022-10-07 10:45:23 +02:00
parent aca3a667c4
commit 85df2c80a8
No known key found for this signature in database
4 changed files with 43 additions and 18 deletions

View file

@ -316,3 +316,22 @@ func GetEnvBool(key string) (bool, error) {
return v, nil
}
func GetFirstOrCreateNetwork(pool *dockertest.Pool, name string) (dockertest.Network, error) {
networks, err := pool.NetworksByName(name)
if err != nil || len(networks) == 0 {
if _, err := pool.CreateNetwork(name); err == nil {
// Create does not give us an updated version of the resource, so we need to
// get it again.
networks, err := pool.NetworksByName(name)
if err != nil {
return dockertest.Network{}, err
}
return networks[0], nil
}
}
return networks[0], nil
}