From 493e4904e988beaef9f5322bdb1c36e81177c709 Mon Sep 17 00:00:00 2001 From: coffeegoddd Date: Mon, 29 Jan 2024 13:34:15 -0800 Subject: [PATCH 01/12] /modules/dolt: wip, kinda working --- modules/dolt/Makefile | 5 + modules/dolt/dolt.go | 233 +++++++++++++++++++++++++++++++ modules/dolt/dolt_test.go | 152 ++++++++++++++++++++ modules/dolt/examples_test.go | 96 +++++++++++++ modules/dolt/go.mod | 63 +++++++++ modules/dolt/go.sum | 178 +++++++++++++++++++++++ modules/dolt/testdata/my_8.cnf | 36 +++++ modules/dolt/testdata/schema.sql | 7 + modules/k3s/go.mod | 4 +- 9 files changed, 773 insertions(+), 1 deletion(-) create mode 100644 modules/dolt/Makefile create mode 100644 modules/dolt/dolt.go create mode 100644 modules/dolt/dolt_test.go create mode 100644 modules/dolt/examples_test.go create mode 100644 modules/dolt/go.mod create mode 100644 modules/dolt/go.sum create mode 100644 modules/dolt/testdata/my_8.cnf create mode 100644 modules/dolt/testdata/schema.sql diff --git a/modules/dolt/Makefile b/modules/dolt/Makefile new file mode 100644 index 0000000000..f22edec419 --- /dev/null +++ b/modules/dolt/Makefile @@ -0,0 +1,5 @@ +include ../../commons-test.mk + +.PHONY: test +test: + $(MAKE) test-dolt diff --git a/modules/dolt/dolt.go b/modules/dolt/dolt.go new file mode 100644 index 0000000000..b33536d6c2 --- /dev/null +++ b/modules/dolt/dolt.go @@ -0,0 +1,233 @@ +package dolt + +import ( + "context" + "database/sql" + "fmt" + "path/filepath" + "strings" + + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" +) + +const ( + rootUser = "root" + defaultUser = "test" + defaultPassword = "test" + defaultDatabaseName = "test" +) + +// defaultImage { +const defaultImage = "dolthub/dolt-sql-server:latest" + +// } + +// DoltContainer represents the Dolt container type used in the module +type DoltContainer struct { + testcontainers.Container + username string + password string + database string +} + +func WithDefaultCredentials() testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) { + username := req.Env["DOLT_USER"] + password := req.Env["DOLT_PASSWORD"] + if strings.EqualFold(rootUser, username) { + delete(req.Env, "DOLT_USER") + } + if len(password) != 0 && password != "" { + req.Env["DOLT_ROOT_PASSWORD"] = password + } else if strings.EqualFold(rootUser, username) { + delete(req.Env, "DOLT_PASSWORD") + } + } +} + +// RunContainer creates an instance of the Dolt container type +func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*DoltContainer, error) { + req := testcontainers.ContainerRequest{ + Image: defaultImage, + ExposedPorts: []string{"3306/tcp", "33060/tcp"}, + Env: map[string]string{ + "DOLT_USER": defaultUser, + "DOLT_PASSWORD": defaultPassword, + "DOLT_DATABASE": defaultDatabaseName, + }, + WaitingFor: wait.ForLog("Server ready. Accepting connections."), + } + + genericContainerReq := testcontainers.GenericContainerRequest{ + ContainerRequest: req, + Started: true, + } + + opts = append(opts, WithDefaultCredentials()) + + for _, opt := range opts { + opt.Customize(&genericContainerReq) + } + + createUser := true + username, ok := req.Env["DOLT_USER"] + if !ok { + username = rootUser + createUser = false + } + password := req.Env["DOLT_PASSWORD"] + + if len(password) == 0 && password == "" && !strings.EqualFold(rootUser, username) { + return nil, fmt.Errorf("empty password can be used only with the root user") + } + + container, err := testcontainers.GenericContainer(ctx, genericContainerReq) + if err != nil { + return nil, err + } + + database := req.Env["DOLT_DATABASE"] + if database == "" { + database = defaultDatabaseName + } + + dc := &DoltContainer{container, username, password, database} + + // dolthub/dolt-sql-server does not create user or database, so we do so here + err = dc.initialize(ctx, createUser) + return dc, err +} + +func (c *DoltContainer) initialize(ctx context.Context, createUser bool) (err error) { + var connectionString string + connectionString, err = c.initialConnectionString(ctx) + if err != nil { + return + } + + var db *sql.DB + db, err = sql.Open("mysql", connectionString) + if err != nil { + return + } + defer func() { + rerr := db.Close() + if err == nil { + err = rerr + } + }() + + if err = db.Ping(); err != nil { + err = fmt.Errorf("error pinging db: %+v\n", err) + return + } + + // create database + _, err = db.Exec(fmt.Sprintf("CREATE DATABASE %s;", c.database)) + if err != nil { + err = fmt.Errorf("error creating database %s: %+v\n", c.database, err) + return + } + + if createUser { + // create user + _, err = db.Exec(fmt.Sprintf("CREATE USER '%s' IDENTIFIED BY '%s';", c.username, c.password)) + if err != nil { + err = fmt.Errorf("error creating user %s: %+v\n", c.username, err) + return + } + + q := fmt.Sprintf("GRANT ALL ON %s.* TO '%s';", c.database, c.username) + // grant user privileges + _, err = db.Exec(q) + if err != nil { + err = fmt.Errorf("error creating user %s: %+v\n", c.username, err) + return + } + } + + return +} + +func (c *DoltContainer) initialConnectionString(ctx context.Context) (string, error) { + containerPort, err := c.MappedPort(ctx, "3306/tcp") + if err != nil { + return "", err + } + + host, err := c.Host(ctx) + if err != nil { + return "", err + } + + connectionString := fmt.Sprintf("root:@tcp(%s:%s)/", host, containerPort.Port()) + return connectionString, nil +} + +func (c *DoltContainer) ConnectionString(ctx context.Context, args ...string) (string, error) { + containerPort, err := c.MappedPort(ctx, "3306/tcp") + if err != nil { + return "", err + } + + host, err := c.Host(ctx) + if err != nil { + return "", err + } + + extraArgs := "" + if len(args) > 0 { + extraArgs = strings.Join(args, "&") + } + if extraArgs != "" { + extraArgs = "?" + extraArgs + } + + connectionString := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s%s", c.username, c.password, host, containerPort.Port(), c.database, extraArgs) + return connectionString, nil +} + +func WithUsername(username string) testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) { + req.Env["DOLT_USER"] = username + } +} + +func WithPassword(password string) testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) { + req.Env["DOLT_PASSWORD"] = password + } +} + +func WithDatabase(database string) testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) { + req.Env["DOLT_DATABASE"] = database + } +} + +func WithConfigFile(configFile string) testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) { + cf := testcontainers.ContainerFile{ + HostFilePath: configFile, + ContainerFilePath: "/etc/dolt/servercfg.d/my.cnf", + FileMode: 0o755, + } + req.Files = append(req.Files, cf) + } +} + +func WithScripts(scripts ...string) testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) { + var initScripts []testcontainers.ContainerFile + for _, script := range scripts { + cf := testcontainers.ContainerFile{ + HostFilePath: script, + ContainerFilePath: "/docker-entrypoint-initdb.d/" + filepath.Base(script), + FileMode: 0o755, + } + initScripts = append(initScripts, cf) + } + req.Files = append(req.Files, initScripts...) + } +} diff --git a/modules/dolt/dolt_test.go b/modules/dolt/dolt_test.go new file mode 100644 index 0000000000..3c1f5831d1 --- /dev/null +++ b/modules/dolt/dolt_test.go @@ -0,0 +1,152 @@ +package dolt_test + +import ( + "context" + "database/sql" + "github.com/testcontainers/testcontainers-go/modules/mysql" + "path/filepath" + "testing" + + // Import mysql into the scope of this package (required) + _ "github.com/go-sql-driver/mysql" + + "github.com/testcontainers/testcontainers-go/modules/dolt" +) + +func TestDolt(t *testing.T) { + ctx := context.Background() + + container, err := dolt.RunContainer(ctx) + if err != nil { + t.Fatal(err) + } + + // Clean up the container after the test is complete + t.Cleanup(func() { + if err := container.Terminate(ctx); err != nil { + t.Fatalf("failed to terminate container: %s", err) + } + }) + + // perform assertions + // connectionString { + connectionString, err := container.ConnectionString(ctx) + // } + if err != nil { + t.Fatal(err) + } + + db, err := sql.Open("mysql", connectionString) + if err != nil { + t.Fatal(err) + } + defer db.Close() + + if err = db.Ping(); err != nil { + t.Errorf("error pinging db: %+v\n", err) + } + _, err = db.Exec("CREATE TABLE IF NOT EXISTS a_table ( \n" + + " `col_1` VARCHAR(128) NOT NULL, \n" + + " `col_2` VARCHAR(128) NOT NULL, \n" + + " PRIMARY KEY (`col_1`, `col_2`) \n" + + ")") + if err != nil { + t.Errorf("error creating table: %+v\n", err) + } +} + +func TestDoltWithNonRootUserAndEmptyPassword(t *testing.T) { + ctx := context.Background() + + _, err := mysql.RunContainer(ctx, + mysql.WithDatabase("foo"), + mysql.WithUsername("test"), + mysql.WithPassword("")) + if err.Error() != "empty password can be used only with the root user" { + t.Fatal(err) + } +} + +func TestDoltWithRootUserAndEmptyPassword(t *testing.T) { + ctx := context.Background() + + container, err := mysql.RunContainer(ctx, + mysql.WithDatabase("foo"), + mysql.WithUsername("root"), + mysql.WithPassword("")) + if err != nil { + t.Fatal(err) + } + + // Clean up the container after the test is complete + t.Cleanup(func() { + if err := container.Terminate(ctx); err != nil { + t.Fatalf("failed to terminate container: %s", err) + } + }) + + // perform assertions + connectionString, _ := container.ConnectionString(ctx) + + db, err := sql.Open("mysql", connectionString) + if err != nil { + t.Fatal(err) + } + defer db.Close() + + if err = db.Ping(); err != nil { + t.Errorf("error pinging db: %+v\n", err) + } + _, err = db.Exec("CREATE TABLE IF NOT EXISTS a_table ( \n" + + " `col_1` VARCHAR(128) NOT NULL, \n" + + " `col_2` VARCHAR(128) NOT NULL, \n" + + " PRIMARY KEY (`col_1`, `col_2`) \n" + + ")") + if err != nil { + t.Errorf("error creating table: %+v\n", err) + } +} + +func TestDoltWithScripts(t *testing.T) { + ctx := context.Background() + + container, err := mysql.RunContainer(ctx, + mysql.WithScripts(filepath.Join("testdata", "schema.sql"))) + if err != nil { + t.Fatal(err) + } + + // Clean up the container after the test is complete + t.Cleanup(func() { + if err := container.Terminate(ctx); err != nil { + t.Fatalf("failed to terminate container: %s", err) + } + }) + + // perform assertions + connectionString, _ := container.ConnectionString(ctx) + + db, err := sql.Open("mysql", connectionString) + if err != nil { + t.Fatal(err) + } + defer db.Close() + + if err = db.Ping(); err != nil { + t.Errorf("error pinging db: %+v\n", err) + } + stmt, err := db.Prepare("SELECT name from profile") + if err != nil { + t.Fatal(err) + } + defer stmt.Close() + row := stmt.QueryRow() + var name string + err = row.Scan(&name) + if err != nil { + t.Errorf("error fetching data") + } + if name != "profile 1" { + t.Fatal("The expected record was not found in the database.") + } +} diff --git a/modules/dolt/examples_test.go b/modules/dolt/examples_test.go new file mode 100644 index 0000000000..1d0f688ea2 --- /dev/null +++ b/modules/dolt/examples_test.go @@ -0,0 +1,96 @@ +package dolt_test + +import ( + "context" + "database/sql" + "fmt" + "path/filepath" + + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/modules/mysql" +) + +func ExampleRunContainer() { + // runMySQLContainer { + ctx := context.Background() + + mysqlContainer, err := mysql.RunContainer(ctx, + testcontainers.WithImage("mysql:8.0.36"), + mysql.WithConfigFile(filepath.Join("testdata", "my_8.cnf")), + mysql.WithDatabase("foo"), + mysql.WithUsername("root"), + mysql.WithPassword("password"), + mysql.WithScripts(filepath.Join("testdata", "schema.sql")), + ) + if err != nil { + panic(err) + } + + // Clean up the container + defer func() { + if err := mysqlContainer.Terminate(ctx); err != nil { + panic(err) + } + }() + // } + + state, err := mysqlContainer.State(ctx) + if err != nil { + panic(err) + } + + fmt.Println(state.Running) + + // Output: + // true +} + +func ExampleRunContainer_connect() { + ctx := context.Background() + + mysqlContainer, err := mysql.RunContainer(ctx, + testcontainers.WithImage("mysql:8.0.36"), + mysql.WithConfigFile(filepath.Join("testdata", "my_8.cnf")), + mysql.WithDatabase("foo"), + mysql.WithUsername("root"), + mysql.WithPassword("password"), + mysql.WithScripts(filepath.Join("testdata", "schema.sql")), + ) + if err != nil { + panic(err) + } + + defer func() { + if err := mysqlContainer.Terminate(ctx); err != nil { + panic(err) + } + }() + + connectionString, _ := mysqlContainer.ConnectionString(ctx) + + db, err := sql.Open("mysql", connectionString) + if err != nil { + panic(err) + } + defer db.Close() + + if err = db.Ping(); err != nil { + panic(err) + } + stmt, err := db.Prepare("SELECT @@GLOBAL.tmpdir") + if err != nil { + panic(err) + } + defer stmt.Close() + row := stmt.QueryRow() + tmpDir := "" + err = row.Scan(&tmpDir) + if err != nil { + panic(err) + } + + fmt.Println(tmpDir) + + // Output: + // /tmp +} diff --git a/modules/dolt/go.mod b/modules/dolt/go.mod new file mode 100644 index 0000000000..b68df5b310 --- /dev/null +++ b/modules/dolt/go.mod @@ -0,0 +1,63 @@ +module github.com/testcontainers/testcontainers-go/modules/dolt + +go 1.20 + +require ( + github.com/go-sql-driver/mysql v1.7.1 + github.com/testcontainers/testcontainers-go v0.27.0 + github.com/testcontainers/testcontainers-go/modules/mysql v0.27.0 + +) + +require ( + dario.cat/mergo v1.0.0 // indirect + github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/hcsshim v0.11.4 // indirect + github.com/cenkalti/backoff/v4 v4.2.1 // indirect + github.com/containerd/containerd v1.7.12 // indirect + github.com/containerd/log v0.1.0 // indirect + github.com/cpuguy83/dockercfg v0.3.1 // indirect + github.com/distribution/reference v0.5.0 // indirect + github.com/docker/docker v25.0.1+incompatible // indirect + github.com/docker/go-connections v0.5.0 // indirect + github.com/docker/go-units v0.5.0 // indirect + github.com/felixge/httpsnoop v1.0.3 // indirect + github.com/go-logr/logr v1.2.4 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/klauspost/compress v1.16.0 // indirect + github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/moby/patternmatcher v0.6.0 // indirect + github.com/moby/sys/sequential v0.5.0 // indirect + github.com/moby/sys/user v0.1.0 // indirect + github.com/moby/term v0.5.0 // indirect + github.com/morikuni/aec v1.0.0 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.0-rc5 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect + github.com/shirou/gopsutil/v3 v3.23.12 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect + github.com/yusufpapurcu/wmi v1.2.3 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect + go.opentelemetry.io/otel v1.19.0 // indirect + go.opentelemetry.io/otel/metric v1.19.0 // indirect + go.opentelemetry.io/otel/trace v1.19.0 // indirect + golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect + golang.org/x/mod v0.11.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/tools v0.10.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/grpc v1.58.3 // indirect + google.golang.org/protobuf v1.31.0 // indirect +) + +replace github.com/testcontainers/testcontainers-go => ../.. diff --git a/modules/dolt/go.sum b/modules/dolt/go.sum new file mode 100644 index 0000000000..402733a62f --- /dev/null +++ b/modules/dolt/go.sum @@ -0,0 +1,178 @@ +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= +github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/containerd/containerd v1.7.12 h1:+KQsnv4VnzyxWcfO9mlxxELaoztsDEjOuCMPAuPqgU0= +github.com/containerd/containerd v1.7.12/go.mod h1:/5OMpE1p0ylxtEUGY8kuCYkDRzJm9NO1TFMWjUpdevk= +github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= +github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= +github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= +github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= +github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= +github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/docker/docker v25.0.1+incompatible h1:k5TYd5rIVQRSqcTwCID+cyVA0yRg86+Pcrz1ls0/frA= +github.com/docker/docker v25.0.1+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-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= +github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= +github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= +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/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= +github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= +github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= +github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= +github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo= +github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg= +github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU= +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/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +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-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= +github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/shirou/gopsutil/v3 v3.23.12 h1:z90NtUkp3bMtmICZKpC4+WaknU1eXtp5vtbQ11DgpE4= +github.com/shirou/gopsutil/v3 v3.23.12/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/testcontainers/testcontainers-go/modules/mysql v0.27.0 h1:6p/o/bAZPcFiBWTd71umQmj/i4L6ipVK3B2ZJBqn5HM= +github.com/testcontainers/testcontainers-go/modules/mysql v0.27.0/go.mod h1:zhVYEruMWC10K9sNwpUqpY3/vUmnyfhSWFs80ySA4mY= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= +github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 h1:x8Z78aZx8cOF0+Kkazoc7lwUNMGy0LrzEMxTm4BbTxg= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0/go.mod h1:62CPTSry9QZtOaSsE3tOzhx6LzDhHnXJ6xHeMNNiM6Q= +go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs= +go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg= +go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= +go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= +go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= +go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= +go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= +go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQJHQdp89IZBA/+azVC4= +golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= +golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg= +golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g= +google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= +google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= diff --git a/modules/dolt/testdata/my_8.cnf b/modules/dolt/testdata/my_8.cnf new file mode 100644 index 0000000000..c4c6039b8a --- /dev/null +++ b/modules/dolt/testdata/my_8.cnf @@ -0,0 +1,36 @@ +# For advice on how to change settings please see +# http://dev.mysql.com/doc/refman/8.1/en/server-configuration-defaults.html + +[mysqld] +# +# Remove leading # and set to the amount of RAM for the most important data +# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. +# innodb_buffer_pool_size = 128M +# +# Remove leading # to turn on a very important data integrity option: logging +# changes to the binary log between backups. +# log_bin +# +# Remove leading # to set options mainly useful for reporting servers. +# The server defaults are faster for transactions and fast SELECTs. +# Adjust sizes as needed, experiment to find the optimal values. +# join_buffer_size = 128M +# sort_buffer_size = 2M +# read_rnd_buffer_size = 2M + +# Remove leading # to revert to previous value for default_authentication_plugin, +# this will increase compatibility with older clients. For background, see: +# https://dev.mysql.com/doc/refman/8.1/en/server-system-variables.html#sysvar_default_authentication_plugin +# default-authentication-plugin=mysql_native_password +host_cache_size=0 +skip-name-resolve +datadir=/var/lib/mysql +socket=/var/run/mysqld/mysqld.sock +secure-file-priv=/var/lib/mysql-files +user=mysql + +pid-file=/var/run/mysqld/mysqld.pid +[client] +socket=/var/run/mysqld/mysqld.sock + +!includedir /etc/mysql/conf.d/ \ No newline at end of file diff --git a/modules/dolt/testdata/schema.sql b/modules/dolt/testdata/schema.sql new file mode 100644 index 0000000000..590774b81c --- /dev/null +++ b/modules/dolt/testdata/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS profile ( + id MEDIUMINT NOT NULL AUTO_INCREMENT, + name VARCHAR(30) NOT NULL, + PRIMARY KEY (id) +); + +INSERT INTO profile (name) values ('profile 1'); diff --git a/modules/k3s/go.mod b/modules/k3s/go.mod index 5b3c0f8d6a..b55761fa00 100644 --- a/modules/k3s/go.mod +++ b/modules/k3s/go.mod @@ -1,6 +1,8 @@ module github.com/testcontainers/testcontainers-go/modules/k3s -go 1.20 +go 1.21 + +toolchain go1.21.6 require ( github.com/docker/docker v25.0.1+incompatible From 95558676192e9561ab6b6acea1781d7556e40f81 Mon Sep 17 00:00:00 2001 From: coffeegoddd Date: Mon, 29 Jan 2024 14:05:50 -0800 Subject: [PATCH 02/12] /modules/dolt: get tests passing --- modules/dolt/dolt.go | 12 ++++---- modules/dolt/examples_test.go | 50 +++++++++++++++++----------------- modules/dolt/testdata/dolt.cnf | 46 +++++++++++++++++++++++++++++++ modules/dolt/testdata/my_8.cnf | 36 ------------------------ 4 files changed, 76 insertions(+), 68 deletions(-) create mode 100644 modules/dolt/testdata/dolt.cnf delete mode 100644 modules/dolt/testdata/my_8.cnf diff --git a/modules/dolt/dolt.go b/modules/dolt/dolt.go index b33536d6c2..e12552d85b 100644 --- a/modules/dolt/dolt.go +++ b/modules/dolt/dolt.go @@ -34,13 +34,8 @@ type DoltContainer struct { func WithDefaultCredentials() testcontainers.CustomizeRequestOption { return func(req *testcontainers.GenericContainerRequest) { username := req.Env["DOLT_USER"] - password := req.Env["DOLT_PASSWORD"] if strings.EqualFold(rootUser, username) { delete(req.Env, "DOLT_USER") - } - if len(password) != 0 && password != "" { - req.Env["DOLT_ROOT_PASSWORD"] = password - } else if strings.EqualFold(rootUser, username) { delete(req.Env, "DOLT_PASSWORD") } } @@ -222,8 +217,11 @@ func WithScripts(scripts ...string) testcontainers.CustomizeRequestOption { var initScripts []testcontainers.ContainerFile for _, script := range scripts { cf := testcontainers.ContainerFile{ - HostFilePath: script, - ContainerFilePath: "/docker-entrypoint-initdb.d/" + filepath.Base(script), + HostFilePath: script, + // dolthub/dolt-sql-server will run init scripts located in /docker-entrypoint-initdb.d/ + // before any database or user is created. to avoid this, we mount init scripts in a different + // location + ContainerFilePath: "/etc/dolt/scripts/initdb.d/" + filepath.Base(script), FileMode: 0o755, } initScripts = append(initScripts, cf) diff --git a/modules/dolt/examples_test.go b/modules/dolt/examples_test.go index 1d0f688ea2..1dd7d02fa3 100644 --- a/modules/dolt/examples_test.go +++ b/modules/dolt/examples_test.go @@ -4,23 +4,23 @@ import ( "context" "database/sql" "fmt" + "github.com/testcontainers/testcontainers-go/modules/dolt" "path/filepath" "github.com/testcontainers/testcontainers-go" - "github.com/testcontainers/testcontainers-go/modules/mysql" ) func ExampleRunContainer() { - // runMySQLContainer { + // runDoltContainer { ctx := context.Background() - mysqlContainer, err := mysql.RunContainer(ctx, - testcontainers.WithImage("mysql:8.0.36"), - mysql.WithConfigFile(filepath.Join("testdata", "my_8.cnf")), - mysql.WithDatabase("foo"), - mysql.WithUsername("root"), - mysql.WithPassword("password"), - mysql.WithScripts(filepath.Join("testdata", "schema.sql")), + doltContainer, err := dolt.RunContainer(ctx, + testcontainers.WithImage("dolthub/dolt-sql-server:1.32.4"), + dolt.WithConfigFile(filepath.Join("testdata", "dolt.cnf")), + dolt.WithDatabase("foo"), + dolt.WithUsername("root"), + dolt.WithPassword("password"), + dolt.WithScripts(filepath.Join("testdata", "schema.sql")), ) if err != nil { panic(err) @@ -28,13 +28,13 @@ func ExampleRunContainer() { // Clean up the container defer func() { - if err := mysqlContainer.Terminate(ctx); err != nil { + if err := doltContainer.Terminate(ctx); err != nil { panic(err) } }() // } - state, err := mysqlContainer.State(ctx) + state, err := doltContainer.State(ctx) if err != nil { panic(err) } @@ -48,25 +48,25 @@ func ExampleRunContainer() { func ExampleRunContainer_connect() { ctx := context.Background() - mysqlContainer, err := mysql.RunContainer(ctx, - testcontainers.WithImage("mysql:8.0.36"), - mysql.WithConfigFile(filepath.Join("testdata", "my_8.cnf")), - mysql.WithDatabase("foo"), - mysql.WithUsername("root"), - mysql.WithPassword("password"), - mysql.WithScripts(filepath.Join("testdata", "schema.sql")), + doltContainer, err := dolt.RunContainer(ctx, + testcontainers.WithImage("dolthub/dolt-sql-server:1.32.4"), + dolt.WithConfigFile(filepath.Join("testdata", "dolt.cnf")), + dolt.WithDatabase("foo"), + dolt.WithUsername("bar"), + dolt.WithPassword("password"), + dolt.WithScripts(filepath.Join("testdata", "schema.sql")), ) if err != nil { panic(err) } defer func() { - if err := mysqlContainer.Terminate(ctx); err != nil { + if err := doltContainer.Terminate(ctx); err != nil { panic(err) } }() - connectionString, _ := mysqlContainer.ConnectionString(ctx) + connectionString, _ := doltContainer.ConnectionString(ctx) db, err := sql.Open("mysql", connectionString) if err != nil { @@ -77,20 +77,20 @@ func ExampleRunContainer_connect() { if err = db.Ping(); err != nil { panic(err) } - stmt, err := db.Prepare("SELECT @@GLOBAL.tmpdir") + stmt, err := db.Prepare("SELECT dolt_version();") if err != nil { panic(err) } defer stmt.Close() row := stmt.QueryRow() - tmpDir := "" - err = row.Scan(&tmpDir) + version := "" + err = row.Scan(&version) if err != nil { panic(err) } - fmt.Println(tmpDir) + fmt.Println(version) // Output: - // /tmp + // 1.32.4 } diff --git a/modules/dolt/testdata/dolt.cnf b/modules/dolt/testdata/dolt.cnf new file mode 100644 index 0000000000..5fd6bdccf7 --- /dev/null +++ b/modules/dolt/testdata/dolt.cnf @@ -0,0 +1,46 @@ +log_level: info + +behavior: + read_only: false + autocommit: true + persistence_behavior: load + disable_client_multi_statements: false + dolt_transaction_commit: false + event_scheduler: "ON" + +user: + name: "root" + password: "" + +listener: + host: localhost + port: 3306 + max_connections: 100 + read_timeout_millis: 28800000 + write_timeout_millis: 28800000 + tls_key: null + tls_cert: null + require_secure_transport: null + allow_cleartext_passwords: null + +performance: + query_parallelism: null + +data_dir: /var/lib/dolt + +cfg_dir: /etc/dolt/doltcfg.d + +metrics: + labels: {} + host: null + port: -1 + +remotesapi: {} + +privilege_file: .doltcfg/privileges.db + +branch_control_file: .doltcfg/branch_control.db + +user_session_vars: [] + +jwks: [] diff --git a/modules/dolt/testdata/my_8.cnf b/modules/dolt/testdata/my_8.cnf deleted file mode 100644 index c4c6039b8a..0000000000 --- a/modules/dolt/testdata/my_8.cnf +++ /dev/null @@ -1,36 +0,0 @@ -# For advice on how to change settings please see -# http://dev.mysql.com/doc/refman/8.1/en/server-configuration-defaults.html - -[mysqld] -# -# Remove leading # and set to the amount of RAM for the most important data -# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. -# innodb_buffer_pool_size = 128M -# -# Remove leading # to turn on a very important data integrity option: logging -# changes to the binary log between backups. -# log_bin -# -# Remove leading # to set options mainly useful for reporting servers. -# The server defaults are faster for transactions and fast SELECTs. -# Adjust sizes as needed, experiment to find the optimal values. -# join_buffer_size = 128M -# sort_buffer_size = 2M -# read_rnd_buffer_size = 2M - -# Remove leading # to revert to previous value for default_authentication_plugin, -# this will increase compatibility with older clients. For background, see: -# https://dev.mysql.com/doc/refman/8.1/en/server-system-variables.html#sysvar_default_authentication_plugin -# default-authentication-plugin=mysql_native_password -host_cache_size=0 -skip-name-resolve -datadir=/var/lib/mysql -socket=/var/run/mysqld/mysqld.sock -secure-file-priv=/var/lib/mysql-files -user=mysql - -pid-file=/var/run/mysqld/mysqld.pid -[client] -socket=/var/run/mysqld/mysqld.sock - -!includedir /etc/mysql/conf.d/ \ No newline at end of file From 963ab3d0eeea4e8b1728c5dc4b440a92214d0a2e Mon Sep 17 00:00:00 2001 From: coffeegoddd Date: Mon, 29 Jan 2024 14:50:50 -0800 Subject: [PATCH 03/12] /{.github,.vscode,docs,mkdocs,modules,sonar-project}: use modulegen tool --- .github/dependabot.yml | 7 ++ .github/workflows/ci.yml | 2 +- .vscode/.testcontainers-go.code-workspace | 4 + docs/modules/dolt.md | 75 +++++++++++++++++++ mkdocs.yml | 1 + modules/dolt/dolt.go | 20 ++--- modules/dolt/dolt_test.go | 21 +++--- modules/dolt/examples_test.go | 4 +- modules/dolt/go.mod | 8 +- modules/dolt/go.sum | 2 - .../testdata/{dolt.cnf => dolt_1_32_4.cnf} | 0 modules/dolt/testdata/schema.sql | 2 + sonar-project.properties | 2 +- 13 files changed, 112 insertions(+), 36 deletions(-) create mode 100644 docs/modules/dolt.md rename modules/dolt/testdata/{dolt.cnf => dolt_1_32_4.cnf} (100%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 25b9e9a0cb..38e2e3f636 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -93,6 +93,13 @@ updates: day: sunday open-pull-requests-limit: 3 rebase-strategy: disabled + - package-ecosystem: gomod + directory: /modules/dolt + schedule: + interval: monthly + day: sunday + open-pull-requests-limit: 3 + rebase-strategy: disabled - package-ecosystem: gomod directory: /modules/elasticsearch schedule: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2302a66a4..3dbf12aa80 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,7 +104,7 @@ jobs: matrix: go-version: [1.20.x, 1.x] platform: [ubuntu-latest] - module: [artemis, cassandra, clickhouse, cockroachdb, compose, couchbase, elasticsearch, gcloud, inbucket, k3s, k6, kafka, localstack, mariadb, minio, mockserver, mongodb, mssql, mysql, nats, neo4j, openldap, postgres, pulsar, rabbitmq, redis, redpanda, vault] + module: [artemis, cassandra, clickhouse, cockroachdb, compose, couchbase, dolt, elasticsearch, gcloud, inbucket, k3s, k6, kafka, localstack, mariadb, minio, mockserver, mongodb, mssql, mysql, nats, neo4j, openldap, postgres, pulsar, rabbitmq, redis, redpanda, vault] exclude: - go-version: 1.20.x module: compose diff --git a/.vscode/.testcontainers-go.code-workspace b/.vscode/.testcontainers-go.code-workspace index 962dbe5886..ceb6efb313 100644 --- a/.vscode/.testcontainers-go.code-workspace +++ b/.vscode/.testcontainers-go.code-workspace @@ -41,6 +41,10 @@ "name": "module / couchbase", "path": "../modules/couchbase" }, + { + "name": "module / dolt", + "path": "../modules/dolt" + }, { "name": "module / elasticsearch", "path": "../modules/elasticsearch" diff --git a/docs/modules/dolt.md b/docs/modules/dolt.md new file mode 100644 index 0000000000..019a59e7b7 --- /dev/null +++ b/docs/modules/dolt.md @@ -0,0 +1,75 @@ +# Dolt + +Not available until the next release of testcontainers-go :material-tag: main + +## Introduction + +The Testcontainers module for Dolt. + +## Adding this module to your project dependencies + +Please run the following command to add the Dolt module to your Go dependencies: + +``` +go get github.com/testcontainers/testcontainers-go/modules/dolt +``` + +## Usage example + + +[Creating a Dolt container](../../modules/dolt/examples_test.go) inside_block:runDoltContainer + + +## Module reference + +The Dolt module exposes one entrypoint function to create the Dolt container, and this function receives two parameters: + +```golang +func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*DoltContainer, error) +``` + +- `context.Context`, the Go context. +- `testcontainers.ContainerCustomizer`, a variadic argument for passing options. + +### Container Options + +When starting the Dolt container, you can pass options in a variadic way to configure it. + +#### Image + +If you need to set a different Dolt Docker image, you can use `testcontainers.WithImage` with a valid Docker image +for Dolt. E.g. `testcontainers.WithImage("dolthub/dolt-sql-server:1.32.4")`. + +{% include "../features/common_functional_options.md" %} + +#### Set username, password and database name + +If you need to set a different database, and its credentials, you can use `WithUsername`, `WithPassword`, `WithDatabase` +options. + +!!!info +The default values for the username is `root`, for password is `test` and for the default database name is `test`. + +#### Init Scripts + +If you would like to perform DDL or DML operations in the Dolt container, add one or more `*.sql`, `*.sql.gz`, or `*.sh` +scripts to the container request, using the `WithScripts(scriptPaths ...string)`. Those files will be copied under `/docker-entrypoint-initdb.d`. + + +[Example of Init script](../../modules/dolt/testdata/schema.sql) + + +#### Custom configuration + +If you need to set a custom configuration, you can use `WithConfigFile` option to pass the path to a custom configuration file. + +### Container Methods + +#### ConnectionString + +This method returns the connection string to connect to the Dolt container, using the default `3306` port. +It's possible to pass extra parameters to the connection string, e.g. `tls=skip-verify` or `application_name=myapp`, in a variadic way. + + +[Get connection string](../../modules/dolt/dolt_test.go) inside_block:connectionString + diff --git a/mkdocs.yml b/mkdocs.yml index 6d6e7b75a5..cabba57b67 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -68,6 +68,7 @@ nav: - modules/clickhouse.md - modules/cockroachdb.md - modules/couchbase.md + - modules/dolt.md - modules/elasticsearch.md - modules/gcloud.md - modules/inbucket.md diff --git a/modules/dolt/dolt.go b/modules/dolt/dolt.go index e12552d85b..8e0255d0b5 100644 --- a/modules/dolt/dolt.go +++ b/modules/dolt/dolt.go @@ -4,11 +4,11 @@ import ( "context" "database/sql" "fmt" + "github.com/testcontainers/testcontainers-go/wait" "path/filepath" "strings" "github.com/testcontainers/testcontainers-go" - "github.com/testcontainers/testcontainers-go/wait" ) const ( @@ -18,10 +18,7 @@ const ( defaultDatabaseName = "test" ) -// defaultImage { -const defaultImage = "dolthub/dolt-sql-server:latest" - -// } +const defaultImage = "dolthub/dolt-sql-server:1.32.4" // DoltContainer represents the Dolt container type used in the module type DoltContainer struct { @@ -119,7 +116,7 @@ func (c *DoltContainer) initialize(ctx context.Context, createUser bool) (err er } // create database - _, err = db.Exec(fmt.Sprintf("CREATE DATABASE %s;", c.database)) + _, err = db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s;", c.database)) if err != nil { err = fmt.Errorf("error creating database %s: %+v\n", c.database, err) return @@ -127,7 +124,7 @@ func (c *DoltContainer) initialize(ctx context.Context, createUser bool) (err er if createUser { // create user - _, err = db.Exec(fmt.Sprintf("CREATE USER '%s' IDENTIFIED BY '%s';", c.username, c.password)) + _, err = db.Exec(fmt.Sprintf("CREATE USER IF NOT EXISTS '%s' IDENTIFIED BY '%s';", c.username, c.password)) if err != nil { err = fmt.Errorf("error creating user %s: %+v\n", c.username, err) return @@ -205,7 +202,7 @@ func WithConfigFile(configFile string) testcontainers.CustomizeRequestOption { return func(req *testcontainers.GenericContainerRequest) { cf := testcontainers.ContainerFile{ HostFilePath: configFile, - ContainerFilePath: "/etc/dolt/servercfg.d/my.cnf", + ContainerFilePath: "/etc/dolt/servercfg.d/server.cnf", FileMode: 0o755, } req.Files = append(req.Files, cf) @@ -217,11 +214,8 @@ func WithScripts(scripts ...string) testcontainers.CustomizeRequestOption { var initScripts []testcontainers.ContainerFile for _, script := range scripts { cf := testcontainers.ContainerFile{ - HostFilePath: script, - // dolthub/dolt-sql-server will run init scripts located in /docker-entrypoint-initdb.d/ - // before any database or user is created. to avoid this, we mount init scripts in a different - // location - ContainerFilePath: "/etc/dolt/scripts/initdb.d/" + filepath.Base(script), + HostFilePath: script, + ContainerFilePath: "/docker-entrypoint-initdb.d/" + filepath.Base(script), FileMode: 0o755, } initScripts = append(initScripts, cf) diff --git a/modules/dolt/dolt_test.go b/modules/dolt/dolt_test.go index 3c1f5831d1..dca0cc2856 100644 --- a/modules/dolt/dolt_test.go +++ b/modules/dolt/dolt_test.go @@ -3,7 +3,6 @@ package dolt_test import ( "context" "database/sql" - "github.com/testcontainers/testcontainers-go/modules/mysql" "path/filepath" "testing" @@ -58,10 +57,10 @@ func TestDolt(t *testing.T) { func TestDoltWithNonRootUserAndEmptyPassword(t *testing.T) { ctx := context.Background() - _, err := mysql.RunContainer(ctx, - mysql.WithDatabase("foo"), - mysql.WithUsername("test"), - mysql.WithPassword("")) + _, err := dolt.RunContainer(ctx, + dolt.WithDatabase("foo"), + dolt.WithUsername("test"), + dolt.WithPassword("")) if err.Error() != "empty password can be used only with the root user" { t.Fatal(err) } @@ -70,10 +69,10 @@ func TestDoltWithNonRootUserAndEmptyPassword(t *testing.T) { func TestDoltWithRootUserAndEmptyPassword(t *testing.T) { ctx := context.Background() - container, err := mysql.RunContainer(ctx, - mysql.WithDatabase("foo"), - mysql.WithUsername("root"), - mysql.WithPassword("")) + container, err := dolt.RunContainer(ctx, + dolt.WithDatabase("foo"), + dolt.WithUsername("root"), + dolt.WithPassword("")) if err != nil { t.Fatal(err) } @@ -110,8 +109,8 @@ func TestDoltWithRootUserAndEmptyPassword(t *testing.T) { func TestDoltWithScripts(t *testing.T) { ctx := context.Background() - container, err := mysql.RunContainer(ctx, - mysql.WithScripts(filepath.Join("testdata", "schema.sql"))) + container, err := dolt.RunContainer(ctx, + dolt.WithScripts(filepath.Join("testdata", "schema.sql"))) if err != nil { t.Fatal(err) } diff --git a/modules/dolt/examples_test.go b/modules/dolt/examples_test.go index 1dd7d02fa3..c0bcc7f577 100644 --- a/modules/dolt/examples_test.go +++ b/modules/dolt/examples_test.go @@ -16,7 +16,7 @@ func ExampleRunContainer() { doltContainer, err := dolt.RunContainer(ctx, testcontainers.WithImage("dolthub/dolt-sql-server:1.32.4"), - dolt.WithConfigFile(filepath.Join("testdata", "dolt.cnf")), + dolt.WithConfigFile(filepath.Join("testdata", "dolt_1_32_4.cnf")), dolt.WithDatabase("foo"), dolt.WithUsername("root"), dolt.WithPassword("password"), @@ -50,7 +50,7 @@ func ExampleRunContainer_connect() { doltContainer, err := dolt.RunContainer(ctx, testcontainers.WithImage("dolthub/dolt-sql-server:1.32.4"), - dolt.WithConfigFile(filepath.Join("testdata", "dolt.cnf")), + dolt.WithConfigFile(filepath.Join("testdata", "dolt_1_32_4.cnf")), dolt.WithDatabase("foo"), dolt.WithUsername("bar"), dolt.WithPassword("password"), diff --git a/modules/dolt/go.mod b/modules/dolt/go.mod index b68df5b310..09ba66bc5c 100644 --- a/modules/dolt/go.mod +++ b/modules/dolt/go.mod @@ -2,12 +2,7 @@ module github.com/testcontainers/testcontainers-go/modules/dolt go 1.20 -require ( - github.com/go-sql-driver/mysql v1.7.1 - github.com/testcontainers/testcontainers-go v0.27.0 - github.com/testcontainers/testcontainers-go/modules/mysql v0.27.0 - -) +require github.com/testcontainers/testcontainers-go v0.27.0 require ( dario.cat/mergo v1.0.0 // indirect @@ -26,6 +21,7 @@ require ( github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect + github.com/go-sql-driver/mysql v1.7.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/uuid v1.6.0 // indirect diff --git a/modules/dolt/go.sum b/modules/dolt/go.sum index 402733a62f..811b2407b3 100644 --- a/modules/dolt/go.sum +++ b/modules/dolt/go.sum @@ -95,8 +95,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/testcontainers/testcontainers-go/modules/mysql v0.27.0 h1:6p/o/bAZPcFiBWTd71umQmj/i4L6ipVK3B2ZJBqn5HM= -github.com/testcontainers/testcontainers-go/modules/mysql v0.27.0/go.mod h1:zhVYEruMWC10K9sNwpUqpY3/vUmnyfhSWFs80ySA4mY= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= diff --git a/modules/dolt/testdata/dolt.cnf b/modules/dolt/testdata/dolt_1_32_4.cnf similarity index 100% rename from modules/dolt/testdata/dolt.cnf rename to modules/dolt/testdata/dolt_1_32_4.cnf diff --git a/modules/dolt/testdata/schema.sql b/modules/dolt/testdata/schema.sql index 590774b81c..4a736a0434 100644 --- a/modules/dolt/testdata/schema.sql +++ b/modules/dolt/testdata/schema.sql @@ -1,3 +1,5 @@ +CREATE DATABASE IF NOT EXISTS test; +USE test; CREATE TABLE IF NOT EXISTS profile ( id MEDIUMINT NOT NULL AUTO_INCREMENT, name VARCHAR(30) NOT NULL, diff --git a/sonar-project.properties b/sonar-project.properties index e332ab9c27..3a4f02f68d 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -18,4 +18,4 @@ sonar.test.inclusions=**/*_test.go sonar.test.exclusions=**/vendor/** sonar.go.coverage.reportPaths=**/coverage.out -sonar.go.tests.reportPaths=TEST-unit.xml,examples/consul/TEST-unit.xml,examples/nginx/TEST-unit.xml,examples/toxiproxy/TEST-unit.xml,modulegen/TEST-unit.xml,modules/artemis/TEST-unit.xml,modules/cassandra/TEST-unit.xml,modules/clickhouse/TEST-unit.xml,modules/cockroachdb/TEST-unit.xml,modules/compose/TEST-unit.xml,modules/couchbase/TEST-unit.xml,modules/elasticsearch/TEST-unit.xml,modules/gcloud/TEST-unit.xml,modules/inbucket/TEST-unit.xml,modules/k3s/TEST-unit.xml,modules/k6/TEST-unit.xml,modules/kafka/TEST-unit.xml,modules/localstack/TEST-unit.xml,modules/mariadb/TEST-unit.xml,modules/minio/TEST-unit.xml,modules/mockserver/TEST-unit.xml,modules/mongodb/TEST-unit.xml,modules/mssql/TEST-unit.xml,modules/mysql/TEST-unit.xml,modules/nats/TEST-unit.xml,modules/neo4j/TEST-unit.xml,modules/openldap/TEST-unit.xml,modules/postgres/TEST-unit.xml,modules/pulsar/TEST-unit.xml,modules/rabbitmq/TEST-unit.xml,modules/redis/TEST-unit.xml,modules/redpanda/TEST-unit.xml,modules/vault/TEST-unit.xml +sonar.go.tests.reportPaths=TEST-unit.xml,examples/consul/TEST-unit.xml,examples/nginx/TEST-unit.xml,examples/toxiproxy/TEST-unit.xml,modulegen/TEST-unit.xml,modules/artemis/TEST-unit.xml,modules/cassandra/TEST-unit.xml,modules/clickhouse/TEST-unit.xml,modules/cockroachdb/TEST-unit.xml,modules/compose/TEST-unit.xml,modules/couchbase/TEST-unit.xml,modules/dolt/TEST-unit.xml,modules/elasticsearch/TEST-unit.xml,modules/gcloud/TEST-unit.xml,modules/inbucket/TEST-unit.xml,modules/k3s/TEST-unit.xml,modules/k6/TEST-unit.xml,modules/kafka/TEST-unit.xml,modules/localstack/TEST-unit.xml,modules/mariadb/TEST-unit.xml,modules/minio/TEST-unit.xml,modules/mockserver/TEST-unit.xml,modules/mongodb/TEST-unit.xml,modules/mssql/TEST-unit.xml,modules/mysql/TEST-unit.xml,modules/nats/TEST-unit.xml,modules/neo4j/TEST-unit.xml,modules/openldap/TEST-unit.xml,modules/postgres/TEST-unit.xml,modules/pulsar/TEST-unit.xml,modules/rabbitmq/TEST-unit.xml,modules/redis/TEST-unit.xml,modules/redpanda/TEST-unit.xml,modules/vault/TEST-unit.xml From 606c5aa1da672b405780f7018db7f1d566ee1875 Mon Sep 17 00:00:00 2001 From: coffeegoddd Date: Mon, 29 Jan 2024 15:47:23 -0800 Subject: [PATCH 04/12] /modules/dolt/{dolt.go,examples_test.go}: run linter --- modules/dolt/dolt.go | 10 +++++----- modules/dolt/examples_test.go | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/dolt/dolt.go b/modules/dolt/dolt.go index 8e0255d0b5..72e8800a67 100644 --- a/modules/dolt/dolt.go +++ b/modules/dolt/dolt.go @@ -4,11 +4,11 @@ import ( "context" "database/sql" "fmt" - "github.com/testcontainers/testcontainers-go/wait" "path/filepath" "strings" "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" ) const ( @@ -111,14 +111,14 @@ func (c *DoltContainer) initialize(ctx context.Context, createUser bool) (err er }() if err = db.Ping(); err != nil { - err = fmt.Errorf("error pinging db: %+v\n", err) + err = fmt.Errorf("error pinging db: %w\n", err) return } // create database _, err = db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s;", c.database)) if err != nil { - err = fmt.Errorf("error creating database %s: %+v\n", c.database, err) + err = fmt.Errorf("error creating database %s: %w\n", c.database, err) return } @@ -126,7 +126,7 @@ func (c *DoltContainer) initialize(ctx context.Context, createUser bool) (err er // create user _, err = db.Exec(fmt.Sprintf("CREATE USER IF NOT EXISTS '%s' IDENTIFIED BY '%s';", c.username, c.password)) if err != nil { - err = fmt.Errorf("error creating user %s: %+v\n", c.username, err) + err = fmt.Errorf("error creating user %s: %w\n", c.username, err) return } @@ -134,7 +134,7 @@ func (c *DoltContainer) initialize(ctx context.Context, createUser bool) (err er // grant user privileges _, err = db.Exec(q) if err != nil { - err = fmt.Errorf("error creating user %s: %+v\n", c.username, err) + err = fmt.Errorf("error creating user %s: %w\n", c.username, err) return } } diff --git a/modules/dolt/examples_test.go b/modules/dolt/examples_test.go index c0bcc7f577..38f259dc2c 100644 --- a/modules/dolt/examples_test.go +++ b/modules/dolt/examples_test.go @@ -4,10 +4,9 @@ import ( "context" "database/sql" "fmt" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/dolt" "path/filepath" - - "github.com/testcontainers/testcontainers-go" ) func ExampleRunContainer() { From 83a99d455fe1106fb0dd55d8e085bdd03b62be1d Mon Sep 17 00:00:00 2001 From: coffeegoddd Date: Tue, 30 Jan 2024 13:42:28 -0800 Subject: [PATCH 05/12] /modules/dolt/{dolt.go,examples_test.go}: add methods for cloning --- docs/modules/dolt.md | 6 ++++ modules/dolt/dolt.go | 14 ++++++++++ modules/dolt/dolt_test.go | 29 ++++++++++++++++++++ modules/dolt/examples_test.go | 3 +- modules/dolt/testdata/check_clone_private.sh | 11 ++++++++ modules/dolt/testdata/check_clone_public.sh | 6 ++++ 6 files changed, 68 insertions(+), 1 deletion(-) create mode 100755 modules/dolt/testdata/check_clone_private.sh create mode 100755 modules/dolt/testdata/check_clone_public.sh diff --git a/docs/modules/dolt.md b/docs/modules/dolt.md index 019a59e7b7..18dca3fd57 100644 --- a/docs/modules/dolt.md +++ b/docs/modules/dolt.md @@ -55,6 +55,12 @@ The default values for the username is `root`, for password is `test` and for th If you would like to perform DDL or DML operations in the Dolt container, add one or more `*.sql`, `*.sql.gz`, or `*.sh` scripts to the container request, using the `WithScripts(scriptPaths ...string)`. Those files will be copied under `/docker-entrypoint-initdb.d`. +#### Clone from remotes + +If you would like to clone data from a remote into the Dolt container, add an `*.sh` +scripts to the container request, using the `WithScripts(scriptPaths ...string)`. Additionally, use `WithDoltCloneRemoteUrl(url string)` to specify +the remote to clone, and use `WithDoltCredsPublicKey(key string)` to authorize the Dolt container to clone from the remote. + [Example of Init script](../../modules/dolt/testdata/schema.sql) diff --git a/modules/dolt/dolt.go b/modules/dolt/dolt.go index 72e8800a67..924b22616a 100644 --- a/modules/dolt/dolt.go +++ b/modules/dolt/dolt.go @@ -74,6 +74,8 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize return nil, fmt.Errorf("empty password can be used only with the root user") } + req.Env["SOME_BS"] = "wtfmaaaaaan" + container, err := testcontainers.GenericContainer(ctx, genericContainerReq) if err != nil { return nil, err @@ -192,6 +194,18 @@ func WithPassword(password string) testcontainers.CustomizeRequestOption { } } +func WithDoltCredsPublicKey(key string) testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) { + req.Env["DOLT_CREDS_PUB_KEY"] = key + } +} + +func WithDoltCloneRemoteUrl(url string) testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) { + req.Env["DOLT_REMOTE_CLONE_URL"] = url + } +} + func WithDatabase(database string) testcontainers.CustomizeRequestOption { return func(req *testcontainers.GenericContainerRequest) { req.Env["DOLT_DATABASE"] = database diff --git a/modules/dolt/dolt_test.go b/modules/dolt/dolt_test.go index dca0cc2856..8ce7af8a2d 100644 --- a/modules/dolt/dolt_test.go +++ b/modules/dolt/dolt_test.go @@ -66,6 +66,35 @@ func TestDoltWithNonRootUserAndEmptyPassword(t *testing.T) { } } +func TestDoltWithPublicRemoteCloneUrl(t *testing.T) { + ctx := context.Background() + + _, err := dolt.RunContainer(ctx, + dolt.WithDatabase("foo"), + dolt.WithUsername("test"), + dolt.WithPassword("test"), + dolt.WithScripts(filepath.Join("testdata", "check_clone_public.sh")), + dolt.WithDoltCloneRemoteUrl("fake-remote-url")) + if err != nil { + t.Fatal(err) + } +} + +func TestDoltWithPrivateRemoteCloneUrl(t *testing.T) { + ctx := context.Background() + + _, err := dolt.RunContainer(ctx, + dolt.WithDatabase("foo"), + dolt.WithUsername("test"), + dolt.WithPassword("test"), + dolt.WithScripts(filepath.Join("testdata", "check_clone_private.sh")), + dolt.WithDoltCloneRemoteUrl("fake-remote-url"), + dolt.WithDoltCredsPublicKey("fake-public-key")) + if err != nil { + t.Fatal(err) + } +} + func TestDoltWithRootUserAndEmptyPassword(t *testing.T) { ctx := context.Background() diff --git a/modules/dolt/examples_test.go b/modules/dolt/examples_test.go index 38f259dc2c..c95986b441 100644 --- a/modules/dolt/examples_test.go +++ b/modules/dolt/examples_test.go @@ -4,9 +4,10 @@ import ( "context" "database/sql" "fmt" + "path/filepath" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/dolt" - "path/filepath" ) func ExampleRunContainer() { diff --git a/modules/dolt/testdata/check_clone_private.sh b/modules/dolt/testdata/check_clone_private.sh new file mode 100755 index 0000000000..ece5c432d3 --- /dev/null +++ b/modules/dolt/testdata/check_clone_private.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +if [ -z "$DOLT_CREDS_PUB_KEY" ]; then + echo "failed: DOLT_CREDS_PUB_KEY was unset" + exit 1; +fi + +if [ -z "$DOLT_REMOTE_CLONE_URL" ]; then + echo "failed: DOLT_REMOTE_CLONE_URL was unset" + exit 1; +fi diff --git a/modules/dolt/testdata/check_clone_public.sh b/modules/dolt/testdata/check_clone_public.sh new file mode 100755 index 0000000000..183181ac0a --- /dev/null +++ b/modules/dolt/testdata/check_clone_public.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +if [ -z "$DOLT_REMOTE_CLONE_URL" ]; then + echo "failed: DOLT_REMOTE_CLONE_URL was unset" + exit 1; +fi From f948998a413c79e8f1d4e9bbb6bd8ee1369ed2a1 Mon Sep 17 00:00:00 2001 From: coffeegoddd Date: Tue, 30 Jan 2024 15:33:44 -0800 Subject: [PATCH 06/12] /{docs, modules}: add with creds file --- docs/modules/dolt.md | 2 +- modules/dolt/dolt.go | 11 +++++++++++ modules/dolt/dolt_test.go | 19 ++++++++++++++++++- modules/dolt/testdata/check_clone_private.sh | 10 ++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/docs/modules/dolt.md b/docs/modules/dolt.md index 18dca3fd57..47309886b2 100644 --- a/docs/modules/dolt.md +++ b/docs/modules/dolt.md @@ -59,7 +59,7 @@ scripts to the container request, using the `WithScripts(scriptPaths ...string)` If you would like to clone data from a remote into the Dolt container, add an `*.sh` scripts to the container request, using the `WithScripts(scriptPaths ...string)`. Additionally, use `WithDoltCloneRemoteUrl(url string)` to specify -the remote to clone, and use `WithDoltCredsPublicKey(key string)` to authorize the Dolt container to clone from the remote. +the remote to clone, and use `WithDoltCredsPublicKey(key string)` along with `WithCredsFile(credsFile string)` to authorize the Dolt container to clone from the remote. [Example of Init script](../../modules/dolt/testdata/schema.sql) diff --git a/modules/dolt/dolt.go b/modules/dolt/dolt.go index 924b22616a..e7770330a1 100644 --- a/modules/dolt/dolt.go +++ b/modules/dolt/dolt.go @@ -223,6 +223,17 @@ func WithConfigFile(configFile string) testcontainers.CustomizeRequestOption { } } +func WithCredsFile(credsFile string) testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) { + cf := testcontainers.ContainerFile{ + HostFilePath: credsFile, + ContainerFilePath: "/root/.dolt/creds/" + filepath.Base(credsFile), + FileMode: 0o755, + } + req.Files = append(req.Files, cf) + } +} + func WithScripts(scripts ...string) testcontainers.CustomizeRequestOption { return func(req *testcontainers.GenericContainerRequest) { var initScripts []testcontainers.ContainerFile diff --git a/modules/dolt/dolt_test.go b/modules/dolt/dolt_test.go index 8ce7af8a2d..ed3307d78b 100644 --- a/modules/dolt/dolt_test.go +++ b/modules/dolt/dolt_test.go @@ -3,6 +3,7 @@ package dolt_test import ( "context" "database/sql" + "os" "path/filepath" "testing" @@ -80,16 +81,32 @@ func TestDoltWithPublicRemoteCloneUrl(t *testing.T) { } } +func createTestCredsFile(t *testing.T) string { + file, err := os.CreateTemp(os.TempDir(), "prefix") + if err != nil { + t.Fatal(err) + } + defer file.Close() + _, err = file.WriteString("some-fake-creds") + if err != nil { + t.Fatal(err) + } + return file.Name() +} + func TestDoltWithPrivateRemoteCloneUrl(t *testing.T) { ctx := context.Background() + filename := createTestCredsFile(t) + defer os.RemoveAll(filename) _, err := dolt.RunContainer(ctx, dolt.WithDatabase("foo"), dolt.WithUsername("test"), dolt.WithPassword("test"), dolt.WithScripts(filepath.Join("testdata", "check_clone_private.sh")), dolt.WithDoltCloneRemoteUrl("fake-remote-url"), - dolt.WithDoltCredsPublicKey("fake-public-key")) + dolt.WithDoltCredsPublicKey("fake-public-key"), + dolt.WithCredsFile(filename)) if err != nil { t.Fatal(err) } diff --git a/modules/dolt/testdata/check_clone_private.sh b/modules/dolt/testdata/check_clone_private.sh index ece5c432d3..8a1d744d12 100755 --- a/modules/dolt/testdata/check_clone_private.sh +++ b/modules/dolt/testdata/check_clone_private.sh @@ -9,3 +9,13 @@ if [ -z "$DOLT_REMOTE_CLONE_URL" ]; then echo "failed: DOLT_REMOTE_CLONE_URL was unset" exit 1; fi + +if [ -z "$DOLT_REMOTE_CLONE_URL" ]; then + echo "failed: DOLT_REMOTE_CLONE_URL was unset" + exit 1; +fi + +if [ -z "$(ls -A /root/.dolt/creds)" ]; then + echo "failed: no creds found" + exit 1; +fi From c1fa127eca945c1e3061d5d6debf8eec34755900 Mon Sep 17 00:00:00 2001 From: coffeegoddd Date: Wed, 31 Jan 2024 10:23:53 -0800 Subject: [PATCH 07/12] /{docs,modules}: pr feedback, cleanup --- docs/modules/dolt.md | 2 +- modules/dolt/dolt.go | 2 -- modules/dolt/testdata/clone-db.sh | 9 +++++++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 modules/dolt/testdata/clone-db.sh diff --git a/docs/modules/dolt.md b/docs/modules/dolt.md index 47309886b2..3e7fdfc43e 100644 --- a/docs/modules/dolt.md +++ b/docs/modules/dolt.md @@ -62,7 +62,7 @@ scripts to the container request, using the `WithScripts(scriptPaths ...string)` the remote to clone, and use `WithDoltCredsPublicKey(key string)` along with `WithCredsFile(credsFile string)` to authorize the Dolt container to clone from the remote. -[Example of Init script](../../modules/dolt/testdata/schema.sql) +[Example of Clone script](../../modules/dolt/testdata/clone-db.sh) #### Custom configuration diff --git a/modules/dolt/dolt.go b/modules/dolt/dolt.go index e7770330a1..4e7a2d6200 100644 --- a/modules/dolt/dolt.go +++ b/modules/dolt/dolt.go @@ -74,8 +74,6 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize return nil, fmt.Errorf("empty password can be used only with the root user") } - req.Env["SOME_BS"] = "wtfmaaaaaan" - container, err := testcontainers.GenericContainer(ctx, genericContainerReq) if err != nil { return nil, err diff --git a/modules/dolt/testdata/clone-db.sh b/modules/dolt/testdata/clone-db.sh new file mode 100644 index 0000000000..aea3172e7a --- /dev/null +++ b/modules/dolt/testdata/clone-db.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# use credentials for remote +if [ -n "$DOLT_CREDS_PUB_KEY" ]; then + dolt creds use "$DOLT_CREDS_PUB_KEY" +fi + +# clone +dolt sql -q "CALL DOLT_CLONE('$DOLT_REMOTE_CLONE_URL', '$DOLT_DATABASE');" From 09c4f5532f7c30f244d0d3ba5defe401dfae9209 Mon Sep 17 00:00:00 2001 From: coffeegoddd Date: Tue, 6 Feb 2024 09:30:46 -0800 Subject: [PATCH 08/12] /modules/dolt/examples_test.go: remove panics, lint --- modules/dolt/examples_test.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/dolt/examples_test.go b/modules/dolt/examples_test.go index c95986b441..ee1e80cd3d 100644 --- a/modules/dolt/examples_test.go +++ b/modules/dolt/examples_test.go @@ -4,6 +4,7 @@ import ( "context" "database/sql" "fmt" + "log" "path/filepath" "github.com/testcontainers/testcontainers-go" @@ -23,20 +24,20 @@ func ExampleRunContainer() { dolt.WithScripts(filepath.Join("testdata", "schema.sql")), ) if err != nil { - panic(err) + log.Fatalf("failed to run dolt container: %s", err) // nolint:gocritic } // Clean up the container defer func() { if err := doltContainer.Terminate(ctx); err != nil { - panic(err) + log.Fatalf("failed to terminate dolt container: %s", err) // nolint:gocritic } }() // } state, err := doltContainer.State(ctx) if err != nil { - panic(err) + log.Fatalf("failed to get container state: %s", err) // nolint:gocritic } fmt.Println(state.Running) @@ -57,12 +58,12 @@ func ExampleRunContainer_connect() { dolt.WithScripts(filepath.Join("testdata", "schema.sql")), ) if err != nil { - panic(err) + log.Fatalf("failed to run dolt container: %s", err) // nolint:gocritic } defer func() { if err := doltContainer.Terminate(ctx); err != nil { - panic(err) + log.Fatalf("failed to terminate dolt container: %s", err) // nolint:gocritic } }() @@ -70,23 +71,23 @@ func ExampleRunContainer_connect() { db, err := sql.Open("mysql", connectionString) if err != nil { - panic(err) + log.Fatalf("failed to open database connection: %s", err) // nolint:gocritic } defer db.Close() if err = db.Ping(); err != nil { - panic(err) + log.Fatalf("failed to ping database: %s", err) // nolint:gocritic } stmt, err := db.Prepare("SELECT dolt_version();") if err != nil { - panic(err) + log.Fatalf("failed to prepate sql statement: %s", err) // nolint:gocritic } defer stmt.Close() row := stmt.QueryRow() version := "" err = row.Scan(&version) if err != nil { - panic(err) + log.Fatalf("failed to scan row: %s", err) // nolint:gocritic } fmt.Println(version) From 81d294a3442a97d5d53a174433f5e1d27dec8f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 12 Apr 2024 13:20:23 +0200 Subject: [PATCH 09/12] chore: run mod tidy --- modules/dolt/go.mod | 30 ++++++++++++----------- modules/dolt/go.sum | 60 ++++++++++++++++++++++++++++----------------- 2 files changed, 53 insertions(+), 37 deletions(-) diff --git a/modules/dolt/go.mod b/modules/dolt/go.mod index 09ba66bc5c..de3b871432 100644 --- a/modules/dolt/go.mod +++ b/modules/dolt/go.mod @@ -1,8 +1,11 @@ module github.com/testcontainers/testcontainers-go/modules/dolt -go 1.20 +go 1.21 -require github.com/testcontainers/testcontainers-go v0.27.0 +require ( + github.com/go-sql-driver/mysql v1.7.1 + github.com/testcontainers/testcontainers-go v0.30.0 +) require ( dario.cat/mergo v1.0.0 // indirect @@ -14,14 +17,13 @@ require ( github.com/containerd/log v0.1.0 // indirect github.com/cpuguy83/dockercfg v0.3.1 // indirect github.com/distribution/reference v0.5.0 // indirect - github.com/docker/docker v25.0.1+incompatible // indirect + github.com/docker/docker v25.0.5+incompatible // indirect github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect - github.com/felixge/httpsnoop v1.0.3 // indirect - github.com/go-logr/logr v1.2.4 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect - github.com/go-sql-driver/mysql v1.7.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/uuid v1.6.0 // indirect @@ -34,7 +36,7 @@ require ( github.com/moby/term v0.5.0 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0-rc5 // indirect + github.com/opencontainers/image-spec v1.1.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/shirou/gopsutil/v3 v3.23.12 // indirect @@ -43,17 +45,17 @@ require ( github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect - go.opentelemetry.io/otel v1.19.0 // indirect - go.opentelemetry.io/otel/metric v1.19.0 // indirect - go.opentelemetry.io/otel/trace v1.19.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect - golang.org/x/mod v0.11.0 // indirect + golang.org/x/mod v0.16.0 // indirect golang.org/x/sys v0.16.0 // indirect - golang.org/x/tools v0.10.0 // indirect + golang.org/x/tools v0.13.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect google.golang.org/grpc v1.58.3 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect ) replace github.com/testcontainers/testcontainers-go => ../.. diff --git a/modules/dolt/go.sum b/modules/dolt/go.sum index 811b2407b3..8f711685dd 100644 --- a/modules/dolt/go.sum +++ b/modules/dolt/go.sum @@ -1,6 +1,7 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= @@ -16,22 +17,23 @@ github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3 github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/docker v25.0.1+incompatible h1:k5TYd5rIVQRSqcTwCID+cyVA0yRg86+Pcrz1ls0/frA= -github.com/docker/docker v25.0.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE= +github.com/docker/docker v25.0.5+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-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= -github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= @@ -51,6 +53,7 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= 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/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= @@ -71,8 +74,8 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= 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-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= -github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= +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/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -93,8 +96,9 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= @@ -103,18 +107,22 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 h1:x8Z78aZx8cOF0+Kkazoc7lwUNMGy0LrzEMxTm4BbTxg= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0/go.mod h1:62CPTSry9QZtOaSsE3tOzhx6LzDhHnXJ6xHeMNNiM6Q= -go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs= -go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg= -go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= -go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= -go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= -go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= +go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= +go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -122,17 +130,19 @@ golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQ golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= -golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -148,29 +158,33 @@ golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg= -golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g= google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw= +google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= +gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= From 67fd4bf9f6297fb741ca9e7e4115b02d85df0430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 12 Apr 2024 13:23:57 +0200 Subject: [PATCH 10/12] chore: include MustConnectionString method --- modules/dolt/dolt.go | 8 ++++++++ modules/dolt/dolt_test.go | 4 ++-- modules/dolt/examples_test.go | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/dolt/dolt.go b/modules/dolt/dolt.go index 4e7a2d6200..20818ff8e4 100644 --- a/modules/dolt/dolt.go +++ b/modules/dolt/dolt.go @@ -157,6 +157,14 @@ func (c *DoltContainer) initialConnectionString(ctx context.Context) (string, er return connectionString, nil } +func (c *DoltContainer) MustConnectionString(ctx context.Context, args ...string) string { + addr, err := c.ConnectionString(ctx, args...) + if err != nil { + panic(err) + } + return addr +} + func (c *DoltContainer) ConnectionString(ctx context.Context, args ...string) (string, error) { containerPort, err := c.MappedPort(ctx, "3306/tcp") if err != nil { diff --git a/modules/dolt/dolt_test.go b/modules/dolt/dolt_test.go index ed3307d78b..253eb356fb 100644 --- a/modules/dolt/dolt_test.go +++ b/modules/dolt/dolt_test.go @@ -131,7 +131,7 @@ func TestDoltWithRootUserAndEmptyPassword(t *testing.T) { }) // perform assertions - connectionString, _ := container.ConnectionString(ctx) + connectionString := container.MustConnectionString(ctx) db, err := sql.Open("mysql", connectionString) if err != nil { @@ -169,7 +169,7 @@ func TestDoltWithScripts(t *testing.T) { }) // perform assertions - connectionString, _ := container.ConnectionString(ctx) + connectionString := container.MustConnectionString(ctx) db, err := sql.Open("mysql", connectionString) if err != nil { diff --git a/modules/dolt/examples_test.go b/modules/dolt/examples_test.go index ee1e80cd3d..ceb6a79a14 100644 --- a/modules/dolt/examples_test.go +++ b/modules/dolt/examples_test.go @@ -67,7 +67,7 @@ func ExampleRunContainer_connect() { } }() - connectionString, _ := doltContainer.ConnectionString(ctx) + connectionString := doltContainer.MustConnectionString(ctx) db, err := sql.Open("mysql", connectionString) if err != nil { From 5d56b38b429aef77f1796fc152bf04b3750a2ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 12 Apr 2024 13:27:12 +0200 Subject: [PATCH 11/12] chore: do not use named returns --- modules/dolt/dolt.go | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/modules/dolt/dolt.go b/modules/dolt/dolt.go index 20818ff8e4..3653c9b5e9 100644 --- a/modules/dolt/dolt.go +++ b/modules/dolt/dolt.go @@ -91,17 +91,16 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize return dc, err } -func (c *DoltContainer) initialize(ctx context.Context, createUser bool) (err error) { - var connectionString string - connectionString, err = c.initialConnectionString(ctx) +func (c *DoltContainer) initialize(ctx context.Context, createUser bool) error { + connectionString, err := c.initialConnectionString(ctx) if err != nil { - return + return err } var db *sql.DB db, err = sql.Open("mysql", connectionString) if err != nil { - return + return err } defer func() { rerr := db.Close() @@ -111,35 +110,31 @@ func (c *DoltContainer) initialize(ctx context.Context, createUser bool) (err er }() if err = db.Ping(); err != nil { - err = fmt.Errorf("error pinging db: %w\n", err) - return + return fmt.Errorf("error pinging db: %w", err) } // create database _, err = db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s;", c.database)) if err != nil { - err = fmt.Errorf("error creating database %s: %w\n", c.database, err) - return + return fmt.Errorf("error creating database %s: %w", c.database, err) } if createUser { // create user _, err = db.Exec(fmt.Sprintf("CREATE USER IF NOT EXISTS '%s' IDENTIFIED BY '%s';", c.username, c.password)) if err != nil { - err = fmt.Errorf("error creating user %s: %w\n", c.username, err) - return + return fmt.Errorf("error creating user %s: %w", c.username, err) } q := fmt.Sprintf("GRANT ALL ON %s.* TO '%s';", c.database, c.username) // grant user privileges _, err = db.Exec(q) if err != nil { - err = fmt.Errorf("error creating user %s: %w\n", c.username, err) - return + return fmt.Errorf("error creating user %s: %w", c.username, err) } } - return + return nil } func (c *DoltContainer) initialConnectionString(ctx context.Context) (string, error) { From f07cfd2f4b08265e6c23d00a9371e897fb1caac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 12 Apr 2024 13:35:13 +0200 Subject: [PATCH 12/12] chore: perform initialisation before the container has started --- modules/dolt/dolt.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/dolt/dolt.go b/modules/dolt/dolt.go index 3653c9b5e9..a6da442aa0 100644 --- a/modules/dolt/dolt.go +++ b/modules/dolt/dolt.go @@ -70,6 +70,11 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize } password := req.Env["DOLT_PASSWORD"] + database := req.Env["DOLT_DATABASE"] + if database == "" { + database = defaultDatabaseName + } + if len(password) == 0 && password == "" && !strings.EqualFold(rootUser, username) { return nil, fmt.Errorf("empty password can be used only with the root user") } @@ -79,11 +84,6 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize return nil, err } - database := req.Env["DOLT_DATABASE"] - if database == "" { - database = defaultDatabaseName - } - dc := &DoltContainer{container, username, password, database} // dolthub/dolt-sql-server does not create user or database, so we do so here