Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OpenSearchContainer ¶
type OpenSearchContainer struct {
testcontainers.Container
User string
Password string
}
OpenSearchContainer represents the OpenSearch container type used in the module
func Run ¶ added in v0.32.0
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*OpenSearchContainer, error)
Run creates an instance of the OpenSearch container type
Example ¶
// runOpenSearchContainer {
ctx := context.Background()
opensearchContainer, err := opensearch.Run(
ctx,
"opensearchproject/opensearch:2.11.1",
opensearch.WithUsername("new-username"),
opensearch.WithPassword("new-password"),
)
defer func() {
if err := testcontainers.TerminateContainer(opensearchContainer); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// }
state, err := opensearchContainer.State(ctx)
if err != nil {
log.Printf("failed to get container state: %s", err)
return
}
fmt.Println(state.Running)
fmt.Printf("%s : %s\n", opensearchContainer.User, opensearchContainer.Password)
Output: true new-username : new-password
func RunContainer
deprecated
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*OpenSearchContainer, error)
Deprecated: use Run instead RunContainer creates an instance of the OpenSearch container type
type Option ¶
Option is an option for the OpenSearch container.
func WithPassword ¶
WithPassword sets the password for the OpenSearch container.
func WithUsername ¶
WithUsername sets the username for the OpenSearch container.
func (Option) Customize ¶
func (o Option) Customize(*testcontainers.GenericContainerRequest) error
Customize is a NOOP. It's defined to satisfy the testcontainers.ContainerCustomizer interface.
Click to show internal directories.
Click to hide internal directories.