2022-11-01 19:03:23 +00:00
|
|
|
package cluster
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/testcontainers/testcontainers-go"
|
|
|
|
)
|
|
|
|
|
2023-01-11 21:34:27 +00:00
|
|
|
func createNetwork(t TestingT, name string) (testcontainers.Network, error) {
|
2022-11-01 19:03:23 +00:00
|
|
|
req := testcontainers.GenericNetworkRequest{
|
|
|
|
NetworkRequest: testcontainers.NetworkRequest{
|
|
|
|
Name: name,
|
|
|
|
Attachable: true,
|
|
|
|
CheckDuplicate: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
network, err := testcontainers.GenericNetwork(context.Background(), req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not create network")
|
|
|
|
}
|
2023-01-11 21:34:27 +00:00
|
|
|
t.Cleanup(func() {
|
|
|
|
_ = network.Remove(context.Background())
|
|
|
|
})
|
2022-11-01 19:03:23 +00:00
|
|
|
return network, nil
|
|
|
|
}
|