/
githubmirror
/
trivy
Обзор
Документация
Войти
/
githubmirror
/
trivy
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
v0.67.2
internal/testutil/localstack.go
51 строка
1 KB
Nikita Pivkin
feat(terraform): Terraform Plan snapshot scanning support (#6176)
05 мар 2024, 01:37
Не верифицирован
05 мар 2024, 01:37
9361cdb
Код
Авторство
О чём код?
package testutil import ( "context" "fmt" "os" dockercontainer "github.com/docker/docker/api/types/container" "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/localstack" ) func SetupLocalStack(ctx context.Context, version string) (*localstack.LocalStackContainer, string, error) { if err := os.Setenv("TESTCONTAINERS_RYUK_DISABLED", "true"); err != nil { return nil, "", err } container, err := localstack.RunContainer(ctx, testcontainers.CustomizeRequest( testcontainers.GenericContainerRequest{ ContainerRequest: testcontainers.ContainerRequest{ Image: "localstack/localstack:" + version, HostConfigModifier: func(hostConfig *dockercontainer.HostConfig) { hostConfig.AutoRemove = true }, }, }, )) if err != nil { return nil, "", err } p, err := container.MappedPort(ctx, "4566/tcp") if err != nil { return nil, "", err } provider, err := testcontainers.NewDockerProvider() if err != nil { return nil, "", err } defer provider.Close() host, err := provider.DaemonHost(ctx) if err != nil { return nil, "", err } return container, fmt.Sprintf("http://%s:%d", host, p.Int()), nil }