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] <support@github.com>
This commit is contained in:
committed by
Ralf Haferkamp
parent
9fb773891f
commit
4132d79ea6
@@ -83,7 +83,7 @@ require (
|
|||||||
github.com/stretchr/testify v1.11.1
|
github.com/stretchr/testify v1.11.1
|
||||||
github.com/test-go/testify v1.1.4
|
github.com/test-go/testify v1.1.4
|
||||||
github.com/testcontainers/testcontainers-go v0.40.0
|
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/theckman/yacspin v0.13.12
|
||||||
github.com/thejerf/suture/v4 v4.0.6
|
github.com/thejerf/suture/v4 v4.0.6
|
||||||
github.com/tidwall/gjson v1.18.0
|
github.com/tidwall/gjson v1.18.0
|
||||||
|
|||||||
@@ -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/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 h1:pSdJYLOVgLE8YdUY2FHQ1Fxu+aMnb6JfVz1mxk7OeMU=
|
||||||
github.com/testcontainers/testcontainers-go v0.40.0/go.mod h1:FSXV5KQtX2HAMlm7U3APNyLkkap35zNLxukw9oBi/MY=
|
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.40.0 h1:3TIrGk0zXyO9CG2N6APo7auwWIwAvhkwE1reISif8LM=
|
||||||
github.com/testcontainers/testcontainers-go/modules/opensearch v0.39.0/go.mod h1:B7AhrDmQ4QbpzA0BeWvqzaJ8vbwcdEQDzybr35sBRfw=
|
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 h1:psAOktJFD4vV9NEVb3qkhRSMvYh4ORRaj1+w/hn4B+o=
|
||||||
github.com/thanhpk/randstr v1.0.6/go.mod h1:M/H2P1eNLZzlDwAzpkkkUvoyNNMbzRGhESZuEQk3r0U=
|
github.com/thanhpk/randstr v1.0.6/go.mod h1:M/H2P1eNLZzlDwAzpkkkUvoyNNMbzRGhESZuEQk3r0U=
|
||||||
github.com/theckman/yacspin v0.13.12 h1:CdZ57+n0U6JMuh2xqjnjRq5Haj6v1ner2djtLQRzJr4=
|
github.com/theckman/yacspin v0.13.12 h1:CdZ57+n0U6JMuh2xqjnjRq5Haj6v1ner2djtLQRzJr4=
|
||||||
|
|||||||
Generated
Vendored
+54
-68
@@ -35,17 +35,29 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize
|
|||||||
|
|
||||||
// Run creates an instance of the OpenSearch container type
|
// Run creates an instance of the OpenSearch container type
|
||||||
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*OpenSearchContainer, error) {
|
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*OpenSearchContainer, error) {
|
||||||
req := testcontainers.ContainerRequest{
|
// Gather all config options (defaults and then apply provided options)
|
||||||
Image: img,
|
settings := defaultOptions()
|
||||||
ExposedPorts: []string{defaultHTTPPort, "9600/tcp"},
|
for _, opt := range opts {
|
||||||
Env: map[string]string{
|
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",
|
"discovery.type": "single-node",
|
||||||
"DISABLE_INSTALL_DEMO_CONFIG": "true",
|
"DISABLE_INSTALL_DEMO_CONFIG": "true",
|
||||||
"DISABLE_SECURITY_PLUGIN": "true",
|
"DISABLE_SECURITY_PLUGIN": "true",
|
||||||
"OPENSEARCH_USERNAME": defaultUsername,
|
"OPENSEARCH_USERNAME": username,
|
||||||
"OPENSEARCH_PASSWORD": defaultPassword,
|
"OPENSEARCH_PASSWORD": password,
|
||||||
},
|
}),
|
||||||
HostConfigModifier: func(hc *container.HostConfig) {
|
testcontainers.WithExposedPorts(defaultHTTPPort, "9600/tcp"),
|
||||||
|
testcontainers.WithHostConfigModifier(func(hc *container.HostConfig) {
|
||||||
hc.Ulimits = []*units.Ulimit{
|
hc.Ulimits = []*units.Ulimit{
|
||||||
{
|
{
|
||||||
Name: "memlock",
|
Name: "memlock",
|
||||||
@@ -58,73 +70,47 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
|
|||||||
Hard: 65536,
|
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{
|
moduleOpts = append(moduleOpts, opts...)
|
||||||
ContainerRequest: req,
|
|
||||||
Started: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gather all config options (defaults and then apply provided options)
|
ctr, err := testcontainers.Run(ctx, img, moduleOpts...)
|
||||||
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)
|
|
||||||
var c *OpenSearchContainer
|
var c *OpenSearchContainer
|
||||||
if container != nil {
|
if ctr != nil {
|
||||||
c = &OpenSearchContainer{Container: container, User: username, Password: password}
|
c = &OpenSearchContainer{Container: ctr, User: username, Password: password}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c, fmt.Errorf("generic container: %w", err)
|
return c, fmt.Errorf("run opensearch: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
|
|||||||
+5
-3
@@ -19,7 +19,7 @@ func defaultOptions() *Options {
|
|||||||
var _ testcontainers.ContainerCustomizer = (*Option)(nil)
|
var _ testcontainers.ContainerCustomizer = (*Option)(nil)
|
||||||
|
|
||||||
// Option is an option for the OpenSearch container.
|
// 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.
|
// Customize is a NOOP. It's defined to satisfy the testcontainers.ContainerCustomizer interface.
|
||||||
func (o Option) Customize(*testcontainers.GenericContainerRequest) error {
|
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.
|
// WithPassword sets the password for the OpenSearch container.
|
||||||
func WithPassword(password string) Option {
|
func WithPassword(password string) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) error {
|
||||||
o.Password = password
|
o.Password = password
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithUsername sets the username for the OpenSearch container.
|
// WithUsername sets the username for the OpenSearch container.
|
||||||
func WithUsername(username string) Option {
|
func WithUsername(username string) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) error {
|
||||||
o.Username = username
|
o.Username = username
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -2099,7 +2099,7 @@ github.com/testcontainers/testcontainers-go/internal/core
|
|||||||
github.com/testcontainers/testcontainers-go/internal/core/network
|
github.com/testcontainers/testcontainers-go/internal/core/network
|
||||||
github.com/testcontainers/testcontainers-go/log
|
github.com/testcontainers/testcontainers-go/log
|
||||||
github.com/testcontainers/testcontainers-go/wait
|
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
|
## explicit; go 1.24.0
|
||||||
github.com/testcontainers/testcontainers-go/modules/opensearch
|
github.com/testcontainers/testcontainers-go/modules/opensearch
|
||||||
# github.com/theckman/yacspin v0.13.12
|
# github.com/theckman/yacspin v0.13.12
|
||||||
|
|||||||
Reference in New Issue
Block a user