From 4132d79ea6caffe14ccca55d742740d52960e7a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Dec 2025 08:50:14 +0000 Subject: [PATCH] build(deps): bump github.com/testcontainers/testcontainers-go/modules/opensearch Bumps [github.com/testcontainers/testcontainers-go/modules/opensearch](https://github.com/testcontainers/testcontainers-go) from 0.39.0 to 0.40.0. - [Release notes](https://github.com/testcontainers/testcontainers-go/releases) - [Commits](https://github.com/testcontainers/testcontainers-go/compare/v0.39.0...v0.40.0) --- updated-dependencies: - dependency-name: github.com/testcontainers/testcontainers-go/modules/opensearch dependency-version: 0.40.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../modules/opensearch/opensearch.go | 122 ++++++++---------- .../modules/opensearch/options.go | 8 +- vendor/modules.txt | 2 +- 5 files changed, 63 insertions(+), 75 deletions(-) diff --git a/go.mod b/go.mod index d8ccd2f048..2d100d9e99 100644 --- a/go.mod +++ b/go.mod @@ -83,7 +83,7 @@ require ( github.com/stretchr/testify v1.11.1 github.com/test-go/testify v1.1.4 github.com/testcontainers/testcontainers-go v0.40.0 - github.com/testcontainers/testcontainers-go/modules/opensearch v0.39.0 + github.com/testcontainers/testcontainers-go/modules/opensearch v0.40.0 github.com/theckman/yacspin v0.13.12 github.com/thejerf/suture/v4 v4.0.6 github.com/tidwall/gjson v1.18.0 diff --git a/go.sum b/go.sum index b60f11514a..e69c95cb08 100644 --- a/go.sum +++ b/go.sum @@ -1206,8 +1206,8 @@ github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU= github.com/testcontainers/testcontainers-go v0.40.0 h1:pSdJYLOVgLE8YdUY2FHQ1Fxu+aMnb6JfVz1mxk7OeMU= github.com/testcontainers/testcontainers-go v0.40.0/go.mod h1:FSXV5KQtX2HAMlm7U3APNyLkkap35zNLxukw9oBi/MY= -github.com/testcontainers/testcontainers-go/modules/opensearch v0.39.0 h1:IkJUhR8AigQxv7qHZho/OtTU6JtiSdBGVh76o175JGo= -github.com/testcontainers/testcontainers-go/modules/opensearch v0.39.0/go.mod h1:B7AhrDmQ4QbpzA0BeWvqzaJ8vbwcdEQDzybr35sBRfw= +github.com/testcontainers/testcontainers-go/modules/opensearch v0.40.0 h1:3TIrGk0zXyO9CG2N6APo7auwWIwAvhkwE1reISif8LM= +github.com/testcontainers/testcontainers-go/modules/opensearch v0.40.0/go.mod h1:VA0UCTPu+Gcs7MzdzBnSl0qDnxquuphv3ngSGdX97Xs= github.com/thanhpk/randstr v1.0.6 h1:psAOktJFD4vV9NEVb3qkhRSMvYh4ORRaj1+w/hn4B+o= github.com/thanhpk/randstr v1.0.6/go.mod h1:M/H2P1eNLZzlDwAzpkkkUvoyNNMbzRGhESZuEQk3r0U= github.com/theckman/yacspin v0.13.12 h1:CdZ57+n0U6JMuh2xqjnjRq5Haj6v1ner2djtLQRzJr4= diff --git a/vendor/github.com/testcontainers/testcontainers-go/modules/opensearch/opensearch.go b/vendor/github.com/testcontainers/testcontainers-go/modules/opensearch/opensearch.go index 09b54759ba..b2e400f0f9 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/modules/opensearch/opensearch.go +++ b/vendor/github.com/testcontainers/testcontainers-go/modules/opensearch/opensearch.go @@ -35,17 +35,29 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize // Run creates an instance of the OpenSearch container type func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*OpenSearchContainer, error) { - req := testcontainers.ContainerRequest{ - Image: img, - ExposedPorts: []string{defaultHTTPPort, "9600/tcp"}, - Env: map[string]string{ + // Gather all config options (defaults and then apply provided options) + settings := defaultOptions() + for _, opt := range opts { + if apply, ok := opt.(Option); ok { + if err := apply(settings); err != nil { + return nil, fmt.Errorf("apply option: %w", err) + } + } + } + + username := settings.Username + password := settings.Password + + moduleOpts := []testcontainers.ContainerCustomizer{ + testcontainers.WithEnv(map[string]string{ "discovery.type": "single-node", "DISABLE_INSTALL_DEMO_CONFIG": "true", "DISABLE_SECURITY_PLUGIN": "true", - "OPENSEARCH_USERNAME": defaultUsername, - "OPENSEARCH_PASSWORD": defaultPassword, - }, - HostConfigModifier: func(hc *container.HostConfig) { + "OPENSEARCH_USERNAME": username, + "OPENSEARCH_PASSWORD": password, + }), + testcontainers.WithExposedPorts(defaultHTTPPort, "9600/tcp"), + testcontainers.WithHostConfigModifier(func(hc *container.HostConfig) { hc.Ulimits = []*units.Ulimit{ { Name: "memlock", @@ -58,73 +70,47 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom Hard: 65536, }, } - }, + }), + // the wait strategy does not support TLS at the moment, + // so we need to disable it in the strategy for now. + testcontainers.WithWaitStrategy(wait.ForHTTP("/"). + WithPort("9200"). + WithTLS(false). + WithStartupTimeout(120*time.Second). + WithStatusCodeMatcher(func(status int) bool { + return status == 200 + }). + WithBasicAuth(username, password). + WithResponseMatcher(func(body io.Reader) bool { + bs, err := io.ReadAll(body) + if err != nil { + return false + } + + type response struct { + Tagline string `json:"tagline"` + } + + var r response + err = json.Unmarshal(bs, &r) + if err != nil { + return false + } + + return r.Tagline == "The OpenSearch Project: https://opensearch.org/" + })), } - genericContainerReq := testcontainers.GenericContainerRequest{ - ContainerRequest: req, - Started: true, - } + moduleOpts = append(moduleOpts, opts...) - // Gather all config options (defaults and then apply provided options) - settings := defaultOptions() - for _, opt := range opts { - if apply, ok := opt.(Option); ok { - apply(settings) - } - if err := opt.Customize(&genericContainerReq); err != nil { - return nil, err - } - } - - // set credentials if they are provided, otherwise use the defaults - if settings.Username != "" { - genericContainerReq.Env["OPENSEARCH_USERNAME"] = settings.Username - } - if settings.Password != "" { - genericContainerReq.Env["OPENSEARCH_PASSWORD"] = settings.Password - } - - username := genericContainerReq.Env["OPENSEARCH_USERNAME"] - password := genericContainerReq.Env["OPENSEARCH_PASSWORD"] - - // the wat strategy does not support TLS at the moment, - // so we need to disable it in the strategy for now. - genericContainerReq.WaitingFor = wait.ForHTTP("/"). - WithPort("9200"). - WithTLS(false). - WithStartupTimeout(120*time.Second). - WithStatusCodeMatcher(func(status int) bool { - return status == 200 - }). - WithBasicAuth(username, password). - WithResponseMatcher(func(body io.Reader) bool { - bs, err := io.ReadAll(body) - if err != nil { - return false - } - - type response struct { - Tagline string `json:"tagline"` - } - - var r response - err = json.Unmarshal(bs, &r) - if err != nil { - return false - } - - return r.Tagline == "The OpenSearch Project: https://opensearch.org/" - }) - - container, err := testcontainers.GenericContainer(ctx, genericContainerReq) + ctr, err := testcontainers.Run(ctx, img, moduleOpts...) var c *OpenSearchContainer - if container != nil { - c = &OpenSearchContainer{Container: container, User: username, Password: password} + if ctr != nil { + c = &OpenSearchContainer{Container: ctr, User: username, Password: password} } if err != nil { - return c, fmt.Errorf("generic container: %w", err) + return c, fmt.Errorf("run opensearch: %w", err) } return c, nil diff --git a/vendor/github.com/testcontainers/testcontainers-go/modules/opensearch/options.go b/vendor/github.com/testcontainers/testcontainers-go/modules/opensearch/options.go index f1223762a3..94f793b252 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/modules/opensearch/options.go +++ b/vendor/github.com/testcontainers/testcontainers-go/modules/opensearch/options.go @@ -19,7 +19,7 @@ func defaultOptions() *Options { var _ testcontainers.ContainerCustomizer = (*Option)(nil) // Option is an option for the OpenSearch container. -type Option func(*Options) +type Option func(*Options) error // Customize is a NOOP. It's defined to satisfy the testcontainers.ContainerCustomizer interface. func (o Option) Customize(*testcontainers.GenericContainerRequest) error { @@ -29,14 +29,16 @@ func (o Option) Customize(*testcontainers.GenericContainerRequest) error { // WithPassword sets the password for the OpenSearch container. func WithPassword(password string) Option { - return func(o *Options) { + return func(o *Options) error { o.Password = password + return nil } } // WithUsername sets the username for the OpenSearch container. func WithUsername(username string) Option { - return func(o *Options) { + return func(o *Options) error { o.Username = username + return nil } } diff --git a/vendor/modules.txt b/vendor/modules.txt index 2edd741d11..9333e0261b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -2099,7 +2099,7 @@ github.com/testcontainers/testcontainers-go/internal/core github.com/testcontainers/testcontainers-go/internal/core/network github.com/testcontainers/testcontainers-go/log github.com/testcontainers/testcontainers-go/wait -# github.com/testcontainers/testcontainers-go/modules/opensearch v0.39.0 +# github.com/testcontainers/testcontainers-go/modules/opensearch v0.40.0 ## explicit; go 1.24.0 github.com/testcontainers/testcontainers-go/modules/opensearch # github.com/theckman/yacspin v0.13.12