Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OpenSearchContainer ¶
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 ¶
package main import ( "context" "fmt" "log" "github.com/testcontainers/testcontainers-go/modules/opensearch" ) func main() { // runOpenSearchContainer { ctx := context.Background() opensearchContainer, err := opensearch.Run( ctx, "opensearchproject/opensearch:2.11.1", opensearch.WithUsername("new-username"), opensearch.WithPassword("new-password"), ) if err != nil { log.Fatalf("failed to start container: %s", err) } // Clean up the container defer func() { if err := opensearchContainer.Terminate(ctx); err != nil { log.Fatalf("failed to terminate container: %s", err) // nolint:gocritic } }() // } state, err := opensearchContainer.State(ctx) if err != nil { log.Fatalf("failed to get container state: %s", err) // nolint:gocritic } 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 ¶
type Option func(*Options)
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.
Click to show internal directories.
Click to hide internal directories.