opensearch

package module
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2024 License: MIT Imports: 9 Imported by: 0

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
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

func (*OpenSearchContainer) Address

func (c *OpenSearchContainer) Address(ctx context.Context) (string, error)

Address retrieves the address of the OpenSearch container. It will use http as protocol, as TLS is not supported at the moment.

type Option

type Option func(*Options)

Option is an option for the OpenSearch container.

func WithPassword

func WithPassword(password string) Option

WithPassword sets the password for the OpenSearch container.

func WithUsername

func WithUsername(username string) Option

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.

type Options

type Options struct {
	Password string
	Username string
}

Options is a struct for specifying options for the OpenSearch container.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL