forked from testcontainers/testcontainers-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into session-ids
* main: chore: define interfaces for file and project generation (testcontainers#1568) chore(deps): bump mkdocs-material from 8.2.7 to 9.2.6 (testcontainers#1567) chore(deps): bump the all group in /modules/neo4j with 1 update (testcontainers#1562) chore(deps): bump the all group in /modules/clickhouse with 1 update (testcontainers#1563) chore(deps): bump the all group in /modules/localstack with 1 update (testcontainers#1564) Update actions/github-script to 6.4.1 (testcontainers#1561) chore: Update Pipenv to use Python 3.8 (testcontainers#1558) feat: convert NATS example into a module (testcontainers#1559) chore(deps): bump the all group in /modulegen with 1 update (testcontainers#1554) modulegen: use cobra instead of native golang flag (testcontainers#1550)
- Loading branch information
Showing
52 changed files
with
1,391 additions
and
692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# NATS | ||
|
||
Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a> | ||
|
||
## Introduction | ||
|
||
The Testcontainers module for NATS. | ||
|
||
## Adding this module to your project dependencies | ||
|
||
Please run the following command to add the NATS module to your Go dependencies: | ||
|
||
``` | ||
go get github.com/testcontainers/testcontainers-go/modules/nats | ||
``` | ||
|
||
## Usage example | ||
|
||
<!--codeinclude--> | ||
[Creating a NATS container](../../modules/nats/nats_test.go) inside_block:createNATSContainer | ||
<!--/codeinclude--> | ||
|
||
## Module reference | ||
|
||
The NATS module exposes one entrypoint function to create the NATS container, and this function receives two parameters: | ||
|
||
```golang | ||
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*NATSContainer, error) | ||
``` | ||
|
||
- `context.Context`, the Go context. | ||
- `testcontainers.ContainerCustomizer`, a variadic argument for passing options. | ||
|
||
### Container Options | ||
|
||
When starting the NATS container, you can pass options in a variadic way to configure it. | ||
|
||
#### Image | ||
|
||
If you need to set a different NATS Docker image, you can use `testcontainers.WithImage` with a valid Docker image | ||
for NATS. E.g. `testcontainers.WithImage("nats:2.9")`. | ||
|
||
#### Wait Strategies | ||
|
||
If you need to set a different wait strategy for NATS, you can use `testcontainers.WithWaitStrategy` with a valid wait strategy | ||
for NATS. | ||
|
||
!!!info | ||
The default deadline for the wait strategy is 60 seconds. | ||
|
||
At the same time, it's possible to set a wait strategy and a custom deadline with `testcontainers.WithWaitStrategyAndDeadline`. | ||
|
||
#### Docker type modifiers | ||
|
||
If you need an advanced configuration for NATS, you can leverage the following Docker type modifiers: | ||
|
||
- `testcontainers.WithConfigModifier` | ||
- `testcontainers.WithHostConfigModifier` | ||
- `testcontainers.WithEndpointSettingsModifier` | ||
|
||
Please read the [Create containers: Advanced Settings](../features/creating_container.md#advanced-settings) documentation for more information. | ||
|
||
#### Set username and password | ||
|
||
If you need to set different credentials, you can use `WithUsername` and `WithPassword` | ||
options. By default, the username, the password are not set. | ||
|
||
<!--codeinclude--> | ||
[Define NATS container with credentials](../../modules/nats/nats_test.go) inside_block:withCredentials | ||
<!--/codeinclude--> | ||
|
||
To establish the connection with the NATS container: | ||
|
||
<!--codeinclude--> | ||
[Connect using the credentials](../../modules/nats/nats_test.go) inside_block:connectWithCredentials | ||
<!--/codeinclude--> | ||
|
||
### Container Methods | ||
|
||
The NATS container exposes the following methods: | ||
|
||
#### ConnectionString | ||
|
||
This method returns the connection string to connect to the NATS container, using the default `4222` port. | ||
It's possible to pass extra parameters to the connection string, in a variadic way. | ||
|
||
<!--codeinclude--> | ||
[Get connection string](../../modules/nats/nats_test.go) inside_block:connectionString | ||
<!--/codeinclude--> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package modules | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/testcontainers/testcontainers-go/modulegen/internal" | ||
) | ||
|
||
var newExampleCmd = &cobra.Command{ | ||
Use: "example", | ||
Short: "Create a new Example", | ||
Long: "Create a new Example", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return internal.Generate(tcModuleVar, false) | ||
}, | ||
} | ||
|
||
func init() { | ||
newExampleCmd.Flags().StringVarP(&tcModuleVar.Name, nameFlag, "n", "", "Name of the example. Only alphabetical characters are allowed.") | ||
newExampleCmd.Flags().StringVarP(&tcModuleVar.NameTitle, titleFlag, "t", "", "(Optional) Title of the example name, used to override the name in the case of mixed casing (Mongodb -> MongoDB). Use camel-case when needed. Only alphabetical characters are allowed.") | ||
newExampleCmd.Flags().StringVarP(&tcModuleVar.Image, imageFlag, "i", "", "Fully-qualified name of the Docker image to be used by the example") | ||
|
||
_ = newExampleCmd.MarkFlagRequired(imageFlag) | ||
_ = newExampleCmd.MarkFlagRequired(nameFlag) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package modules | ||
|
||
const ( | ||
imageFlag = "image" | ||
nameFlag = "name" | ||
titleFlag = "title" | ||
) |
Oops, something went wrong.