mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-02 21:23:20 -04:00
Bumps [github.com/testcontainers/testcontainers-go/modules/opensearch](https://github.com/testcontainers/testcontainers-go) from 0.41.0 to 0.42.0. - [Release notes](https://github.com/testcontainers/testcontainers-go/releases) - [Commits](https://github.com/testcontainers/testcontainers-go/compare/v0.41.0...v0.42.0) --- updated-dependencies: - dependency-name: github.com/testcontainers/testcontainers-go/modules/opensearch dependency-version: 0.42.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
66 lines
1.7 KiB
Go
66 lines
1.7 KiB
Go
package wait
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"io"
|
|
"time"
|
|
|
|
"github.com/moby/moby/api/types/container"
|
|
"github.com/moby/moby/api/types/network"
|
|
|
|
"github.com/testcontainers/testcontainers-go/exec"
|
|
)
|
|
|
|
// Strategy defines the basic interface for a Wait Strategy
|
|
type Strategy interface {
|
|
WaitUntilReady(context.Context, StrategyTarget) error
|
|
}
|
|
|
|
// StrategyTimeout allows MultiStrategy to configure a Strategy's Timeout
|
|
type StrategyTimeout interface {
|
|
Timeout() *time.Duration
|
|
}
|
|
|
|
type StrategyTarget interface {
|
|
Host(context.Context) (string, error)
|
|
Inspect(context.Context) (*container.InspectResponse, error)
|
|
Ports(ctx context.Context) (network.PortMap, error) // Deprecated: use Inspect instead
|
|
MappedPort(context.Context, string) (network.Port, error)
|
|
Logs(context.Context) (io.ReadCloser, error)
|
|
Exec(context.Context, []string, ...exec.ProcessOption) (int, io.Reader, error)
|
|
State(context.Context) (*container.State, error)
|
|
CopyFileFromContainer(ctx context.Context, filePath string) (io.ReadCloser, error)
|
|
}
|
|
|
|
func checkTarget(ctx context.Context, target StrategyTarget) error {
|
|
state, err := target.State(ctx)
|
|
if err != nil {
|
|
return fmt.Errorf("get state: %w", err)
|
|
}
|
|
|
|
return checkState(state)
|
|
}
|
|
|
|
func checkState(state *container.State) error {
|
|
switch {
|
|
case state.Running:
|
|
return nil
|
|
case state.OOMKilled:
|
|
return errors.New("container crashed with out-of-memory (OOMKilled)")
|
|
case state.Status == container.StateExited:
|
|
return fmt.Errorf("container exited with code %d", state.ExitCode)
|
|
default:
|
|
return fmt.Errorf("unexpected container status %q", state.Status)
|
|
}
|
|
}
|
|
|
|
func defaultStartupTimeout() time.Duration {
|
|
return 60 * time.Second
|
|
}
|
|
|
|
func defaultPollInterval() time.Duration {
|
|
return 100 * time.Millisecond
|
|
}
|