You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Interacting with services that require TLS certificates is a common issue when working with containers. You can create one or more on-the-fly certificates in order to communicate with your services.
4
+
5
+
_Testcontainers for Go_ uses a library to generate certificates on-the-fly. This library is called [tlscert](https://github.com/mdelapenya/tlscert).
6
+
7
+
### Examples
8
+
9
+
In the following example we are going to start an HTTP server with a self-signed certificate.
10
+
It exposes one single handler that will return a simple message when accessed.
11
+
The example will also create a client that will connect to the server using the generated certificate,
12
+
demonstrating how to use the generated certificate to communicate with a service.
13
+
14
+
<!--codeinclude-->
15
+
[Create a self-signed certificate](../../modules/cockroachdb/certs.go) inside_block:exampleSelfSignedCert
16
+
[Sign a self-signed certificate](../../modules/cockroachdb/certs.go) inside_block:exampleSignSelfSignedCert
Not available until the next release of testcontainers-go <ahref="https://github.com/testcontainers/testcontainers-go"><spanclass="tc-version">:material-tag: main</span></a>
4
+
5
+
## Introduction
6
+
7
+
The Testcontainers module for Dolt.
8
+
9
+
## Adding this module to your project dependencies
10
+
11
+
Please run the following command to add the Dolt module to your Go dependencies:
12
+
13
+
```
14
+
go get github.com/testcontainers/testcontainers-go/modules/dolt
15
+
```
16
+
17
+
## Usage example
18
+
19
+
<!--codeinclude-->
20
+
[Creating a Dolt container](../../modules/dolt/examples_test.go) inside_block:runDoltContainer
21
+
<!--/codeinclude-->
22
+
23
+
## Module reference
24
+
25
+
The Dolt module exposes one entrypoint function to create the Dolt container, and this function receives two parameters:
- `testcontainers.ContainerCustomizer`, a variadic argument for passing options.
33
+
34
+
### Container Options
35
+
36
+
When starting the Dolt container, you can pass options in a variadic way to configure it.
37
+
38
+
#### Image
39
+
40
+
If you need to set a different Dolt Docker image, you can use `testcontainers.WithImage` with a valid Docker image
41
+
for Dolt. E.g. `testcontainers.WithImage("dolthub/dolt-sql-server:1.32.4")`.
42
+
43
+
{% include "../features/common_functional_options.md" %}
44
+
45
+
#### Set username, password and database name
46
+
47
+
If you need to set a different database, and its credentials, you can use `WithUsername`, `WithPassword`, `WithDatabase`
48
+
options.
49
+
50
+
!!!info
51
+
The default values for the username is `root`, for password is `test` and for the default database name is `test`.
52
+
53
+
#### InitScripts
54
+
55
+
If you would like to perform DDL or DML operations in the Dolt container, add one or more `*.sql`, `*.sql.gz`, or `*.sh`
56
+
scripts to the container request, using the `WithScripts(scriptPaths ...string)`. Those files will be copied under `/docker-entrypoint-initdb.d`.
57
+
58
+
#### Clone from remotes
59
+
60
+
If you would like to clone data from a remote into the Dolt container, add an `*.sh`
61
+
scripts to the container request, using the `WithScripts(scriptPaths ...string)`. Additionally, use `WithDoltCloneRemoteUrl(url string)` to specify
62
+
the remote to clone, and use `WithDoltCredsPublicKey(key string)` along with `WithCredsFile(credsFile string)` to authorize the Dolt container to clone from the remote.
63
+
64
+
<!--codeinclude-->
65
+
[Example of Clone script](../../modules/dolt/testdata/clone-db.sh)
66
+
<!--/codeinclude-->
67
+
68
+
#### Custom configuration
69
+
70
+
If you need to set a custom configuration, you can use `WithConfigFile` option to pass the path to a custom configuration file.
71
+
72
+
### ContainerMethods
73
+
74
+
#### ConnectionString
75
+
76
+
This method returns the connection string to connect to the Dolt container, using the default`3306` port.
77
+
It's possible to pass extra parameters to the connection string, e.g. `tls=skip-verify` or `application_name=myapp`, in a variadic way.
0 commit comments