diff --git a/database/cassandra/cassandra_test.go b/database/cassandra/cassandra_test.go index 84af2853e..5e6cbc0b8 100644 --- a/database/cassandra/cassandra_test.go +++ b/database/cassandra/cassandra_test.go @@ -9,8 +9,8 @@ import ( ) import ( - "github.com/dhui/dktest" "github.com/gocql/gocql" + "github.com/golang-migrate/migrate/v4/dktest" ) import ( diff --git a/database/clickhouse/clickhouse_test.go b/database/clickhouse/clickhouse_test.go index 0af0fa880..5bcc78d3c 100644 --- a/database/clickhouse/clickhouse_test.go +++ b/database/clickhouse/clickhouse_test.go @@ -9,10 +9,10 @@ import ( "testing" _ "github.com/ClickHouse/clickhouse-go" - "github.com/dhui/dktest" "github.com/golang-migrate/migrate/v4" "github.com/golang-migrate/migrate/v4/database/clickhouse" dt "github.com/golang-migrate/migrate/v4/database/testing" + "github.com/golang-migrate/migrate/v4/dktest" "github.com/golang-migrate/migrate/v4/dktesting" _ "github.com/golang-migrate/migrate/v4/source/file" ) diff --git a/database/cockroachdb/cockroachdb_test.go b/database/cockroachdb/cockroachdb_test.go index 7b259ab3e..e355c1688 100644 --- a/database/cockroachdb/cockroachdb_test.go +++ b/database/cockroachdb/cockroachdb_test.go @@ -13,7 +13,7 @@ import ( ) import ( - "github.com/dhui/dktest" + "github.com/golang-migrate/migrate/v4/dktest" _ "github.com/lib/pq" ) diff --git a/database/firebird/firebird_test.go b/database/firebird/firebird_test.go index 1e6701c4e..31a8a9418 100644 --- a/database/firebird/firebird_test.go +++ b/database/firebird/firebird_test.go @@ -12,7 +12,7 @@ import ( "strings" "testing" - "github.com/dhui/dktest" + "github.com/golang-migrate/migrate/v4/dktest" dt "github.com/golang-migrate/migrate/v4/database/testing" "github.com/golang-migrate/migrate/v4/dktesting" diff --git a/database/mongodb/mongodb_test.go b/database/mongodb/mongodb_test.go index a08d094ea..2fc90785f 100644 --- a/database/mongodb/mongodb_test.go +++ b/database/mongodb/mongodb_test.go @@ -16,7 +16,7 @@ import ( ) import ( - "github.com/dhui/dktest" + "github.com/golang-migrate/migrate/v4/dktest" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" diff --git a/database/mysql/mysql_test.go b/database/mysql/mysql_test.go index e0416dd87..2e000e3e9 100644 --- a/database/mysql/mysql_test.go +++ b/database/mysql/mysql_test.go @@ -17,10 +17,10 @@ import ( "strconv" "testing" - "github.com/dhui/dktest" "github.com/go-sql-driver/mysql" "github.com/golang-migrate/migrate/v4" dt "github.com/golang-migrate/migrate/v4/database/testing" + "github.com/golang-migrate/migrate/v4/dktest" "github.com/golang-migrate/migrate/v4/dktesting" _ "github.com/golang-migrate/migrate/v4/source/file" "github.com/stretchr/testify/assert" diff --git a/database/neo4j/neo4j_test.go b/database/neo4j/neo4j_test.go index c8e914525..0519823fa 100644 --- a/database/neo4j/neo4j_test.go +++ b/database/neo4j/neo4j_test.go @@ -7,7 +7,7 @@ import ( "log" "testing" - "github.com/dhui/dktest" + "github.com/golang-migrate/migrate/v4/dktest" "github.com/neo4j/neo4j-go-driver/neo4j" "github.com/golang-migrate/migrate/v4" diff --git a/database/pgx/pgx_test.go b/database/pgx/pgx_test.go index d86caeb36..0242ef04d 100644 --- a/database/pgx/pgx_test.go +++ b/database/pgx/pgx_test.go @@ -15,9 +15,9 @@ import ( "sync" "testing" - "github.com/dhui/dktest" "github.com/golang-migrate/migrate/v4" "github.com/golang-migrate/migrate/v4/database" + "github.com/golang-migrate/migrate/v4/dktest" dt "github.com/golang-migrate/migrate/v4/database/testing" "github.com/golang-migrate/migrate/v4/dktesting" diff --git a/database/pgx/v5/pgx_test.go b/database/pgx/v5/pgx_test.go index 9a8652768..004a374f9 100644 --- a/database/pgx/v5/pgx_test.go +++ b/database/pgx/v5/pgx_test.go @@ -17,7 +17,7 @@ import ( "github.com/golang-migrate/migrate/v4" - "github.com/dhui/dktest" + "github.com/golang-migrate/migrate/v4/dktest" "github.com/golang-migrate/migrate/v4/database" dt "github.com/golang-migrate/migrate/v4/database/testing" diff --git a/database/postgres/postgres_test.go b/database/postgres/postgres_test.go index 3a49c50ab..dfa6fc5b5 100644 --- a/database/postgres/postgres_test.go +++ b/database/postgres/postgres_test.go @@ -17,7 +17,7 @@ import ( "github.com/golang-migrate/migrate/v4" - "github.com/dhui/dktest" + "github.com/golang-migrate/migrate/v4/dktest" "github.com/golang-migrate/migrate/v4/database" dt "github.com/golang-migrate/migrate/v4/database/testing" diff --git a/database/redshift/redshift_test.go b/database/redshift/redshift_test.go index 030d87b6e..6f9ab4e29 100644 --- a/database/redshift/redshift_test.go +++ b/database/redshift/redshift_test.go @@ -18,7 +18,7 @@ import ( ) import ( - "github.com/dhui/dktest" + "github.com/golang-migrate/migrate/v4/dktest" ) import ( diff --git a/database/rqlite/rqlite_test.go b/database/rqlite/rqlite_test.go index c19f7476b..07631648a 100644 --- a/database/rqlite/rqlite_test.go +++ b/database/rqlite/rqlite_test.go @@ -8,7 +8,7 @@ import ( "net/http" "testing" - "github.com/dhui/dktest" + "github.com/golang-migrate/migrate/v4/dktest" "github.com/rqlite/gorqlite" "github.com/stretchr/testify/assert" diff --git a/database/sqlserver/sqlserver_test.go b/database/sqlserver/sqlserver_test.go index 402f4480f..e6206176c 100644 --- a/database/sqlserver/sqlserver_test.go +++ b/database/sqlserver/sqlserver_test.go @@ -11,8 +11,8 @@ import ( "testing" "time" - "github.com/dhui/dktest" "github.com/golang-migrate/migrate/v4" + "github.com/golang-migrate/migrate/v4/dktest" dt "github.com/golang-migrate/migrate/v4/database/testing" "github.com/golang-migrate/migrate/v4/dktesting" diff --git a/database/yugabytedb/yugabytedb_test.go b/database/yugabytedb/yugabytedb_test.go index 05fb14fa7..60bbf8bb4 100644 --- a/database/yugabytedb/yugabytedb_test.go +++ b/database/yugabytedb/yugabytedb_test.go @@ -11,8 +11,8 @@ import ( "testing" "time" - "github.com/dhui/dktest" "github.com/golang-migrate/migrate/v4" + "github.com/golang-migrate/migrate/v4/dktest" _ "github.com/lib/pq" diff --git a/dktest/container_info.go b/dktest/container_info.go new file mode 100644 index 000000000..8be701a46 --- /dev/null +++ b/dktest/container_info.go @@ -0,0 +1,96 @@ +package dktest + +import ( + "fmt" + "strconv" + + "github.com/docker/go-connections/nat" +) + +// ContainerInfo holds information about a running Docker container. +type ContainerInfo struct { + ID string + Name string + ImageName string + Ports nat.PortMap +} + +func (c ContainerInfo) String() string { + return fmt.Sprintf("dktest.ContainerInfo{ID:%q, Name:%q, ImageName:%q}", c.ID, c.Name, c.ImageName) +} + +// Port gets the specified published TCP port. +func (c ContainerInfo) Port(containerPort uint16) (hostIP string, hostPort string, err error) { + port, err := nat.NewPort("tcp", strconv.Itoa(int(containerPort))) + if err != nil { + return "", "", err + } + return mapPort(c.Ports, port) +} + +// UDPPort gets the specified published UDP port. +func (c ContainerInfo) UDPPort(containerPort uint16) (hostIP string, hostPort string, err error) { + port, err := nat.NewPort("udp", strconv.Itoa(int(containerPort))) + if err != nil { + return "", "", err + } + return mapPort(c.Ports, port) +} + +// FirstPort gets the first published TCP port. +func (c ContainerInfo) FirstPort() (hostIP string, hostPort string, err error) { + return firstPort(c.Ports, "tcp") +} + +// FirstUDPPort gets the first published UDP port. +func (c ContainerInfo) FirstUDPPort() (hostIP string, hostPort string, err error) { + return firstPort(c.Ports, "udp") +} + +func mapPort(portMap nat.PortMap, port nat.Port) (hostIP string, hostPort string, err error) { + if bindings, ok := portMap[port]; ok { + for _, binding := range bindings { + return mapHost(binding.HostIP), binding.HostPort, nil + } + } + + portInt := port.Int() + proto := port.Proto() + for p, bindings := range portMap { + if p.Proto() != proto { + continue + } + start, end, err := p.Range() + if err != nil || portInt < start || portInt > end { + continue + } + offset := portInt - start + if offset >= len(bindings) { + continue + } + binding := bindings[offset] + return mapHost(binding.HostIP), binding.HostPort, nil + } + return "", "", errNoPort +} + +func firstPort(portMap nat.PortMap, proto string) (hostIP string, hostPort string, err error) { + for port, bindings := range portMap { + if port.Proto() != proto { + continue + } + for _, binding := range bindings { + return mapHost(binding.HostIP), binding.HostPort, nil + } + } + return "", "", errNoPort +} + +func mapHost(host string) string { + switch host { + case "", "0.0.0.0": + return "127.0.0.1" + default: + return host + } +} diff --git a/dktest/dktest.go b/dktest/dktest.go new file mode 100644 index 000000000..dcf9d6e25 --- /dev/null +++ b/dktest/dktest.go @@ -0,0 +1,232 @@ +package dktest + +import ( + "context" + "fmt" + "io" + "strings" + "testing" + "time" + + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/network" + "github.com/moby/moby/client" +) + +var ( + // DefaultPullTimeout is the default timeout used when pulling images. + DefaultPullTimeout = time.Minute + // DefaultTimeout is the default timeout used when starting a container and checking if it's ready. + DefaultTimeout = time.Minute + // DefaultReadyTimeout is the default timeout used for each container ready check. + DefaultReadyTimeout = 2 * time.Second + // DefaultCleanupTimeout is the default timeout used when stopping and removing a container. + DefaultCleanupTimeout = 15 * time.Second +) + +const label = "dktest" + +// Run runs the given test function once the specified Docker image is running. +func Run(t *testing.T, imgName string, opts Options, testFunc func(*testing.T, ContainerInfo)) { + err := RunContext(context.Background(), t, imgName, opts, func(containerInfo ContainerInfo) error { + testFunc(t, containerInfo) + return nil + }) + if err != nil { + t.Fatal("Failed:", err) + } +} + +// RunContext is similar to Run, but takes a parent context and returns errors. +func RunContext(ctx context.Context, logger Logger, imgName string, opts Options, testFunc func(ContainerInfo) error) (retErr error) { + dc, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) + if err != nil { + return fmt.Errorf("error getting Docker client: %w", err) + } + defer func() { + if err := dc.Close(); err != nil && retErr == nil { + retErr = fmt.Errorf("error closing Docker client: %w", err) + } + }() + + opts.init() + pullCtx, pullCancel := context.WithTimeout(ctx, opts.PullTimeout) + defer pullCancel() + + if err := pullImage(pullCtx, logger, dc, opts.PullRegistryAuth, imgName, opts.Platform); err != nil { + return fmt.Errorf("error pulling image %s: %w", imgName, err) + } + + runCtx, runCancel := context.WithTimeout(ctx, opts.Timeout) + defer runCancel() + + c, err := runImage(runCtx, logger, dc, imgName, opts) + if err != nil { + return fmt.Errorf("error running image %s: %w", imgName, err) + } + defer func() { + stopCtx, stopCancel := context.WithTimeout(ctx, opts.CleanupTimeout) + defer stopCancel() + stopContainer(stopCtx, logger, dc, c, opts.LogStdout, opts.LogStderr) + if opts.CleanupImage { + removeImage(stopCtx, logger, dc, imgName) + } + }() + + if !waitContainerReady(runCtx, logger, c, opts.ReadyFunc, opts.ReadyTimeout) { + return fmt.Errorf("timed out waiting for container to get ready: %v", c.String()) + } + if err := testFunc(c); err != nil { + return fmt.Errorf("error running test func: %w", err) + } + return nil +} + +func pullImage(ctx context.Context, logger Logger, dc *client.Client, registryAuth, imgName, platform string) error { + logger.Log("Pulling image:", imgName) + + opts := client.ImagePullOptions{RegistryAuth: registryAuth} + if platform != "" { + if parsed, ok := parsePlatform(platform); ok { + opts.Platforms = append(opts.Platforms, parsed) + } + } + + resp, err := dc.ImagePull(ctx, imgName, opts) + if err != nil { + return err + } + defer func() { + if err := resp.Close(); err != nil { + logger.Log("Failed to close image response:", err) + } + }() + + var output strings.Builder + if _, err := io.Copy(&output, resp); err != nil { + return err + } + if output.Len() > 0 { + logger.Log("Image pull response:", output.String()) + } + return nil +} + +func removeImage(ctx context.Context, logger Logger, dc *client.Client, imgName string) { + logger.Log("Removing image:", imgName) + if _, err := dc.ImageRemove(ctx, imgName, client.ImageRemoveOptions{Force: true, PruneChildren: true}); err != nil { + logger.Log("Failed to remove image:", err) + } +} + +func runImage(ctx context.Context, logger Logger, dc *client.Client, imgName string, opts Options) (ContainerInfo, error) { + c := ContainerInfo{Name: genContainerName(), ImageName: imgName} + portBindings, err := toNetworkPortMap(opts.PortBindings) + if err != nil { + return c, err + } + exposedPorts, err := toNetworkPortSet(opts.ExposedPorts) + if err != nil { + return c, err + } + + resp, err := dc.ContainerCreate(ctx, client.ContainerCreateOptions{ + Config: &container.Config{ + Image: imgName, + Labels: map[string]string{label: "true"}, + Env: opts.env(), + Entrypoint: opts.Entrypoint, + Cmd: opts.Cmd, + Volumes: opts.volumes(), + Hostname: opts.Hostname, + ExposedPorts: exposedPorts, + }, + HostConfig: &container.HostConfig{ + PublishAllPorts: true, + PortBindings: portBindings, + ShmSize: opts.ShmSize, + Mounts: opts.Mounts, + }, + NetworkingConfig: &network.NetworkingConfig{}, + Name: c.Name, + }) + if err != nil { + return c, err + } + c.ID = resp.ID + logger.Log("Created container:", c.String()) + + if _, err := dc.ContainerStart(ctx, resp.ID, client.ContainerStartOptions{}); err != nil { + return c, err + } + logger.Log("Started container:", c.String()) + + if !opts.PortRequired { + return c, nil + } + + inspectResp, err := dc.ContainerInspect(ctx, c.ID, client.ContainerInspectOptions{}) + if err != nil { + return c, err + } + if inspectResp.Container.NetworkSettings == nil { + return c, errNoNetworkSettings + } + c.Ports = fromNetworkPortMap(inspectResp.Container.NetworkSettings.Ports) + logger.Log("Inspected container:", c.String()) + return c, nil +} + +func stopContainer(ctx context.Context, logger Logger, dc *client.Client, c ContainerInfo, logStdout, logStderr bool) { + if logStdout || logStderr { + logs, err := dc.ContainerLogs(ctx, c.ID, client.ContainerLogsOptions{ + Timestamps: true, + ShowStdout: logStdout, + ShowStderr: logStderr, + }) + if err != nil { + logger.Log("Error fetching container logs:", err) + } else { + if b, err := io.ReadAll(logs); err == nil { + logger.Log("Container logs:", string(b)) + } else { + logger.Log("Error reading container logs:", err) + } + if err := logs.Close(); err != nil { + logger.Log("Error closing logs:", err) + } + } + } + + if _, err := dc.ContainerStop(ctx, c.ID, client.ContainerStopOptions{}); err != nil { + logger.Log("Error stopping container:", c.String(), "error:", err) + } + if _, err := dc.ContainerRemove(ctx, c.ID, client.ContainerRemoveOptions{RemoveVolumes: true, Force: true}); err != nil { + logger.Log("Error removing container:", c.String(), "error:", err) + } + logger.Log("Removed container:", c.String()) +} + +func waitContainerReady(ctx context.Context, logger Logger, c ContainerInfo, readyFunc func(context.Context, ContainerInfo) bool, readyTimeout time.Duration) bool { + if readyFunc == nil { + return true + } + + ticker := time.NewTicker(time.Second) + defer ticker.Stop() + + for { + select { + case <-ticker.C: + readyCtx, cancel := context.WithTimeout(ctx, readyTimeout) + ready := readyFunc(readyCtx, c) + cancel() + if ready { + return true + } + case <-ctx.Done(): + logger.Log("Container was never ready:", c.String()) + return false + } + } +} diff --git a/dktest/errors.go b/dktest/errors.go new file mode 100644 index 000000000..65c341918 --- /dev/null +++ b/dktest/errors.go @@ -0,0 +1,8 @@ +package dktest + +import "errors" + +var ( + errNoNetworkSettings = errors.New("no network settings") + errNoPort = errors.New("no port") +) diff --git a/dktest/logger.go b/dktest/logger.go new file mode 100644 index 000000000..4804da698 --- /dev/null +++ b/dktest/logger.go @@ -0,0 +1,6 @@ +package dktest + +// Logger is the interface used to log messages. +type Logger interface { + Log(...interface{}) +} diff --git a/dktest/options.go b/dktest/options.go new file mode 100644 index 000000000..22c70ea11 --- /dev/null +++ b/dktest/options.go @@ -0,0 +1,78 @@ +package dktest + +import ( + "context" + "strings" + "time" + + "github.com/docker/go-connections/nat" + "github.com/moby/moby/api/types/mount" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" +) + +// Options contains the configurable options for running tests in a Docker image. +type Options struct { + PullTimeout time.Duration + PullRegistryAuth string + Timeout time.Duration + ReadyTimeout time.Duration + CleanupTimeout time.Duration + CleanupImage bool + ReadyFunc func(context.Context, ContainerInfo) bool + Env map[string]string + Entrypoint []string + Cmd []string + PortBindings nat.PortMap + PortRequired bool + LogStdout bool + LogStderr bool + ShmSize int64 + Volumes []string + Mounts []mount.Mount + Hostname string + Platform string + ExposedPorts nat.PortSet +} + +func (o *Options) init() { + if o.PullTimeout <= 0 { + o.PullTimeout = DefaultPullTimeout + } + if o.Timeout <= 0 { + o.Timeout = DefaultTimeout + } + if o.ReadyTimeout <= 0 { + o.ReadyTimeout = DefaultReadyTimeout + } + if o.CleanupTimeout <= 0 { + o.CleanupTimeout = DefaultCleanupTimeout + } +} + +func (o *Options) volumes() map[string]struct{} { + volumes := make(map[string]struct{}, len(o.Volumes)) + for _, volume := range o.Volumes { + volumes[volume] = struct{}{} + } + return volumes +} + +func (o *Options) env() []string { + env := make([]string, 0, len(o.Env)) + for key, value := range o.Env { + env = append(env, key+"="+value) + } + return env +} + +func parsePlatform(raw string) (ocispec.Platform, bool) { + parts := strings.Split(raw, "/") + if len(parts) < 2 || len(parts) > 3 { + return ocispec.Platform{}, false + } + platform := ocispec.Platform{OS: parts[0], Architecture: parts[1]} + if len(parts) == 3 { + platform.Variant = parts[2] + } + return platform, true +} diff --git a/dktest/ports.go b/dktest/ports.go new file mode 100644 index 000000000..8539d8ced --- /dev/null +++ b/dktest/ports.go @@ -0,0 +1,67 @@ +package dktest + +import ( + "net/netip" + + "github.com/docker/go-connections/nat" + "github.com/moby/moby/api/types/network" +) + +func toNetworkPortMap(portMap nat.PortMap) (network.PortMap, error) { + networkPortMap := make(network.PortMap, len(portMap)) + for port, bindings := range portMap { + networkPort, err := network.ParsePort(string(port)) + if err != nil { + return nil, err + } + + networkBindings := make([]network.PortBinding, 0, len(bindings)) + for _, binding := range bindings { + networkBinding := network.PortBinding{HostPort: binding.HostPort} + if binding.HostIP != "" { + if hostIP, err := netip.ParseAddr(binding.HostIP); err == nil { + networkBinding.HostIP = hostIP + } + } + networkBindings = append(networkBindings, networkBinding) + } + networkPortMap[networkPort] = networkBindings + } + return networkPortMap, nil +} + +func toNetworkPortSet(portSet nat.PortSet) (network.PortSet, error) { + networkPortSet := make(network.PortSet, len(portSet)) + for port := range portSet { + networkPort, err := network.ParsePort(string(port)) + if err != nil { + return nil, err + } + networkPortSet[networkPort] = struct{}{} + } + return networkPortSet, nil +} + +func fromNetworkPortMap(portMap network.PortMap) nat.PortMap { + natPortMap := make(nat.PortMap, len(portMap)) + for port, bindings := range portMap { + natPort, err := nat.NewPort(string(port.Proto()), port.Port()) + if err != nil { + continue + } + + natBindings := make([]nat.PortBinding, 0, len(bindings)) + for _, binding := range bindings { + hostIP := "" + if binding.HostIP.IsValid() { + hostIP = binding.HostIP.String() + } + natBindings = append(natBindings, nat.PortBinding{ + HostIP: hostIP, + HostPort: binding.HostPort, + }) + } + natPortMap[natPort] = natBindings + } + return natPortMap +} diff --git a/dktest/rand.go b/dktest/rand.go new file mode 100644 index 000000000..d51aad9f0 --- /dev/null +++ b/dktest/rand.go @@ -0,0 +1,12 @@ +package dktest + +import "math/rand/v2" + +func genContainerName() string { + const letters = "abcdefghijklmnopqrstuvwxyz0123456789" + b := make([]byte, 10) + for i := range b { + b[i] = letters[rand.IntN(len(letters))] + } + return "dktest-" + string(b) +} diff --git a/dktesting/dktesting.go b/dktesting/dktesting.go index 6e94fc646..6d627e1ce 100644 --- a/dktesting/dktesting.go +++ b/dktesting/dktesting.go @@ -5,9 +5,8 @@ import ( "fmt" "testing" - "github.com/dhui/dktest" - "github.com/docker/docker/api/types/image" - "github.com/docker/docker/client" + "github.com/golang-migrate/migrate/v4/dktest" + "github.com/moby/moby/client" ) // ContainerSpec holds Docker testing setup specifications @@ -34,7 +33,7 @@ func (s *ContainerSpec) Cleanup() (retErr error) { } ctx, timeoutCancelFunc := context.WithTimeout(context.Background(), cleanupTimeout) defer timeoutCancelFunc() - if _, err := dc.ImageRemove(ctx, s.ImageName, image.RemoveOptions{Force: true, PruneChildren: true}); err != nil { + if _, err := dc.ImageRemove(ctx, s.ImageName, client.ImageRemoveOptions{Force: true, PruneChildren: true}); err != nil { return err } return nil diff --git a/dktesting/example_test.go b/dktesting/example_test.go index 5f5ccaac1..aa4c3c201 100644 --- a/dktesting/example_test.go +++ b/dktesting/example_test.go @@ -6,7 +6,7 @@ import ( ) import ( - "github.com/dhui/dktest" + "github.com/golang-migrate/migrate/v4/dktest" ) import ( diff --git a/go.mod b/go.mod index eacffe3e0..b6e02be9a 100644 --- a/go.mod +++ b/go.mod @@ -10,8 +10,7 @@ require ( github.com/aws/aws-sdk-go v1.49.6 github.com/cenkalti/backoff/v4 v4.1.2 github.com/cockroachdb/cockroach-go/v2 v2.1.1 - github.com/dhui/dktest v0.4.6 - github.com/docker/docker v28.3.3+incompatible + github.com/docker/go-connections v0.7.0 github.com/fsouza/fake-gcs-server v1.17.0 github.com/go-sql-driver/mysql v1.5.0 github.com/gobuffalo/here v0.6.0 @@ -26,6 +25,8 @@ require ( github.com/markbates/pkger v0.15.1 github.com/mattn/go-sqlite3 v1.14.22 github.com/microsoft/go-mssqldb v1.0.0 + github.com/moby/moby/api v1.54.2 + github.com/moby/moby/client v0.4.1 github.com/mutecomm/go-sqlcipher/v4 v4.4.0 github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8 github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba @@ -52,7 +53,6 @@ require ( github.com/containerd/errdefs v1.0.0 // indirect github.com/containerd/errdefs/pkg v0.3.0 // indirect github.com/distribution/reference v0.6.0 // indirect - github.com/docker/go-connections v0.5.0 // indirect github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/go-jose/go-jose/v4 v4.0.5 // indirect @@ -60,7 +60,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect - github.com/moby/sys/sequential v0.6.0 // indirect github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect github.com/zeebo/errs v1.4.0 // indirect @@ -69,12 +68,10 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect go.opentelemetry.io/otel v1.40.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0 // indirect go.opentelemetry.io/otel/metric v1.40.0 // indirect go.opentelemetry.io/otel/sdk v1.40.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.40.0 // indirect go.opentelemetry.io/otel/trace v1.40.0 // indirect - go.opentelemetry.io/proto/otlp v1.3.1 // indirect golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8 // indirect golang.org/x/tools v0.38.0 // indirect ) @@ -89,7 +86,6 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0 // indirect - github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/Azure/go-autorest v14.2.0+incompatible // indirect github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect github.com/Azure/go-autorest/logger v0.2.1 // indirect @@ -126,7 +122,6 @@ require ( github.com/go-stack/stack v1.8.0 // indirect github.com/goccy/go-json v0.9.11 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.2 // indirect github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect @@ -160,13 +155,11 @@ require ( github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect github.com/mitchellh/mapstructure v1.1.2 // indirect - github.com/moby/term v0.5.0 // indirect - github.com/morikuni/aec v1.0.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/onsi/ginkgo v1.16.4 // indirect github.com/onsi/gomega v1.15.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0 // indirect + github.com/opencontainers/image-spec v1.1.1 github.com/pierrec/lz4/v4 v4.1.16 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pkg/errors v0.9.1 // indirect diff --git a/go.sum b/go.sum index 039672531..9f8521460 100644 --- a/go.sum +++ b/go.sum @@ -634,8 +634,6 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 h1:+5VZ72z0Qan5Bog5C+ZkgSq github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0 h1:u/LLAOFgsMv7HmNL4Qufg58y+qElGOt5qv0z1mURkRY= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0/go.mod h1:2e8rMJtl2+2j+HXbTBwnyGpm5Nou7KhvSfxOq8JpTag= -github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= -github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest/adal v0.9.16 h1:P8An8Z9rH1ldbOLdFpxYorgOt2sywL9V24dAwWHPuGc= @@ -770,14 +768,10 @@ github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= -github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= -github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= -github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369 h1:XNT/Zf5l++1Pyg08/HV04ppB0gKxAqtZQBRYiYrUuYk= github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= @@ -786,17 +780,13 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dhui/dktest v0.4.6 h1:+DPKyScKSEp3VLtbMDHcUq6V5Lm5zfZZVb0Sk7Ahom4= -github.com/dhui/dktest v0.4.6/go.mod h1:JHTSYDtKkvFNFHJKqCzVzqXecyv+tKt8EzceOmQOgbU= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= -github.com/docker/docker v28.3.3+incompatible h1:Dypm25kh4rmk49v1eiVbsAtpAsYURjYkaKubwuBdxEI= -github.com/docker/docker v28.3.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= -github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= +github.com/docker/go-connections v0.7.0 h1:6SsRfJddP22WMrCkj19x9WKjEDTB+ahsdiGYf0mN39c= +github.com/docker/go-connections v0.7.0/go.mod h1:no1qkHdjq7kLMGUXYAduOhYPSJxxvgWBh7ogVvptn3Q= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= @@ -881,8 +871,6 @@ github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6 github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI= @@ -1023,12 +1011,9 @@ github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= -github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8= @@ -1134,7 +1119,6 @@ github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uia github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/asmfmt v1.3.2 h1:4Ri7ox3EwapiOjCki+hw14RyKk201CN4rzyCJRFLpK4= github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= @@ -1203,17 +1187,13 @@ github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQz github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= -github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw= -github.com/moby/sys/atomicwriter v0.1.0/go.mod h1:Ul8oqv2ZMNHOceF643P6FKPXeCmYtlQMvpizfsSoaWs= -github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU= -github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko= -github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= -github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= +github.com/moby/moby/api v1.54.2 h1:wiat9QAhnDQjA7wk1kh/TqHz2I1uUA7M7t9SAl/JNXg= +github.com/moby/moby/api v1.54.2/go.mod h1:+RQ6wluLwtYaTd1WnPLykIDPekkuyD/ROWQClE83pzs= +github.com/moby/moby/client v0.4.1 h1:DMQgisVoMkmMs7fp3ROSdiBnoAu8+vo3GggFl06M/wY= +github.com/moby/moby/client v0.4.1/go.mod h1:z52C9O2POPOsnxZAy//WtKcQ32P+jT/NGeXu/7nfjGQ= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= -github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= github.com/mutecomm/go-sqlcipher/v4 v4.4.0 h1:sV1tWCWGAVlPhNGT95Q+z/txFxuhAYWwHD1afF5bMZg= @@ -1238,8 +1218,8 @@ github.com/onsi/gomega v1.15.0 h1:WjP/FQ/sk43MRmnEcT+MlDw2TFvkrXlprrPST/IudjU= github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= -github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= +github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= +github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= @@ -1368,10 +1348,6 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 h1:F7Jx+6h go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0/go.mod h1:UHB22Z8QsdRDrnAtX4PntOl36ajSxcdUMt1sF7Y6E7Q= go.opentelemetry.io/otel v1.40.0 h1:oA5YeOcpRTXq6NN7frwmwFR0Cn3RhTVZvXsP4duvCms= go.opentelemetry.io/otel v1.40.0/go.mod h1:IMb+uXZUKkMXdPddhwAHm6UfOwJyh4ct1ybIlV14J0g= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0 h1:dIIDULZJpgdiHz5tXrTgKIMLkus6jEFa7x5SOKcyR7E= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0/go.mod h1:jlRVBe7+Z1wyxFSUs48L6OBQZ5JwH2Hg/Vbl+t9rAgI= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 h1:QY7/0NeRPKlzusf40ZE4t1VlMKbqSNT7cJRYzWuja0s= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0/go.mod h1:HVkSiDhTM9BoUJU8qE6j2eSWLLXvi1USXjyd2BXT8PY= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.36.0 h1:rixTyDGXFxRy1xzhKrotaHy3/KXdPhlWARrCgK+eqUY= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.36.0/go.mod h1:dowW6UsM9MKbJq5JTz2AMVp3/5iW5I/TStsk8S+CfHw= go.opentelemetry.io/otel/metric v1.40.0 h1:rcZe317KPftE2rstWIBitCdVp89A2HqjkxR3c11+p9g= @@ -1385,8 +1361,6 @@ go.opentelemetry.io/otel/trace v1.40.0/go.mod h1:zeAhriXecNGP/s2SEG3+Y8X9ujcJOTq go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= -go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= -go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1784,7 +1758,6 @@ golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= @@ -1795,7 +1768,6 @@ golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= @@ -2132,8 +2104,8 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/postgres v1.0.8/go.mod h1:4eOzrI1MUfm6ObJU/UcmbXyiHSs8jSwH95G5P5dxcAg= gorm.io/gorm v1.20.12/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= gorm.io/gorm v1.21.4/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= -gotest.tools/v3 v3.1.0 h1:rVV8Tcg/8jHUkPUorwjaMTtemIMVXfIPKiOqnhEhakk= -gotest.tools/v3 v3.1.0/go.mod h1:fHy7eyTmJFO5bQbUsEGQ1v4m2J3Jz9eWL54TP2/ZuYQ= +gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= +gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -2211,6 +2183,8 @@ modernc.org/z v1.5.1 h1:RTNHdsrOpeoSeOF4FbzTo8gBYByaJ5xT7NgZ9ZqRiJM= modernc.org/z v1.5.1/go.mod h1:eWFB510QWW5Th9YGZT81s+LwvaAs3Q2yr4sP0rmLkv8= modernc.org/zappy v1.0.0 h1:dPVaP+3ueIUv4guk8PuZ2wiUGcJ1WUVvIheeSSTD0yk= modernc.org/zappy v1.0.0/go.mod h1:hHe+oGahLVII/aTTyWK/b53VDHMAGCBYYeZ9sn83HC4= +pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk= +pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/testing/docker.go b/testing/docker.go index 35193e747..58b31ac7d 100644 --- a/testing/docker.go +++ b/testing/docker.go @@ -1,6 +1,6 @@ // Package testing is used in driver tests and should only be used by migrate tests. // -// Deprecated: If you'd like to test using Docker images, use package github.com/dhui/dktest instead +// Deprecated: If you'd like to test using Docker images, use package github.com/golang-migrate/migrate/v4/dktest instead. package testing import ( @@ -15,10 +15,9 @@ import ( "strings" "testing" - dockercontainer "github.com/docker/docker/api/types/container" - dockerimage "github.com/docker/docker/api/types/image" - dockernetwork "github.com/docker/docker/api/types/network" - dockerclient "github.com/docker/docker/client" + dockercontainer "github.com/moby/moby/api/types/container" + dockernetwork "github.com/moby/moby/api/types/network" + dockerclient "github.com/moby/moby/client" ) func NewDockerContainer(t testing.TB, image string, env []string, cmd []string) (*DockerContainer, error) { @@ -72,7 +71,7 @@ func (d *DockerContainer) PullImage() (err error) { return errors.New("cannot pull image on a nil *DockerContainer") } d.t.Logf("Docker: Pull image %v", d.ImageName) - r, err := d.client.ImagePull(context.Background(), d.ImageName, dockerimage.PullOptions{}) + r, err := d.client.ImagePull(context.Background(), d.ImageName, dockerclient.ImagePullOptions{}) if err != nil { return err } @@ -104,19 +103,19 @@ func (d *DockerContainer) Start() error { containerName := fmt.Sprintf("migrate_test_%s", pseudoRandStr(10)) // create container first - resp, err := d.client.ContainerCreate(context.Background(), - &dockercontainer.Config{ + resp, err := d.client.ContainerCreate(context.Background(), dockerclient.ContainerCreateOptions{ + Config: &dockercontainer.Config{ Image: d.ImageName, Labels: map[string]string{"migrate_test": "true"}, Env: d.ENV, Cmd: d.Cmd, }, - &dockercontainer.HostConfig{ + HostConfig: &dockercontainer.HostConfig{ PublishAllPorts: true, }, - &dockernetwork.NetworkingConfig{}, - nil, - containerName) + NetworkingConfig: &dockernetwork.NetworkingConfig{}, + Name: containerName, + }) if err != nil { return err } @@ -125,7 +124,7 @@ func (d *DockerContainer) Start() error { d.ContainerName = containerName // then start it - if err := d.client.ContainerStart(context.Background(), resp.ID, dockercontainer.StartOptions{}); err != nil { + if _, err := d.client.ContainerStart(context.Background(), resp.ID, dockerclient.ContainerStartOptions{}); err != nil { return err } @@ -156,8 +155,8 @@ func (d *DockerContainer) Remove() error { if len(d.ContainerId) == 0 { return errors.New("missing containerId") } - if err := d.client.ContainerRemove(context.Background(), d.ContainerId, - dockercontainer.RemoveOptions{ + if _, err := d.client.ContainerRemove(context.Background(), d.ContainerId, + dockerclient.ContainerRemoveOptions{ Force: true, }); err != nil { d.t.Log(err) @@ -175,12 +174,12 @@ func (d *DockerContainer) Inspect() error { if len(d.ContainerId) == 0 { return errors.New("missing containerId") } - resp, err := d.client.ContainerInspect(context.Background(), d.ContainerId) + resp, err := d.client.ContainerInspect(context.Background(), d.ContainerId, dockerclient.ContainerInspectOptions{}) if err != nil { return err } - d.ContainerJSON = resp + d.ContainerJSON = resp.Container d.containerInspected = true return nil } @@ -193,7 +192,7 @@ func (d *DockerContainer) Logs() (io.ReadCloser, error) { return nil, errors.New("missing containerId") } - return d.client.ContainerLogs(context.Background(), d.ContainerId, dockercontainer.LogsOptions{ + return d.client.ContainerLogs(context.Background(), d.ContainerId, dockerclient.ContainerLogsOptions{ ShowStdout: true, ShowStderr: true, }) @@ -207,7 +206,7 @@ func (d *DockerContainer) portMapping(selectFirst bool, cPort int) (hostIP strin } for port, bindings := range d.ContainerJSON.NetworkSettings.Ports { - if !selectFirst && port.Int() != cPort { + if !selectFirst && int(port.Num()) != cPort { // Skip ahead until we find the port we want continue } @@ -217,7 +216,11 @@ func (d *DockerContainer) portMapping(selectFirst bool, cPort int) (hostIP strin if err != nil { return "", 0, err } - return bindings[0].HostIP, uint(hostPortUint), nil + hostIP := "" + if binding.HostIP.IsValid() { + hostIP = binding.HostIP.String() + } + return hostIP, uint(hostPortUint), nil } } diff --git a/testing/testing.go b/testing/testing.go index 164d9ef6c..49cd77053 100644 --- a/testing/testing.go +++ b/testing/testing.go @@ -7,7 +7,7 @@ import ( "testing" "time" - dockercontainer "github.com/docker/docker/api/types/container" + dockercontainer "github.com/moby/moby/api/types/container" ) type IsReadyFunc func(Instance) bool