mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-22 07:57:34 +00:00
f68ba7504f
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
22 lines
551 B
Go
22 lines
551 B
Go
package dockertestutil
|
|
|
|
import "github.com/ory/dockertest/v3"
|
|
|
|
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 nil, err
|
|
}
|
|
|
|
return &networks[0], nil
|
|
}
|
|
}
|
|
|
|
return &networks[0], nil
|
|
}
|