/
types.go
50 lines (40 loc) · 1.94 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package localstack
import (
"github.com/testcontainers/testcontainers-go"
)
// LocalStackContainer represents the LocalStack container type used in the module
type LocalStackContainer struct {
testcontainers.Container
}
// LocalStackContainerRequest represents the LocalStack container request type used in the module
// to configure the container
type LocalStackContainerRequest struct {
testcontainers.GenericContainerRequest
}
// OverrideContainerRequestOption is a type that can be used to configure the Testcontainers container request.
// The passed request will be merged with the default one.
// Deprecated: use testcontainers.ContainerCustomizer instead
type OverrideContainerRequestOption func(req testcontainers.ContainerRequest) testcontainers.ContainerRequest
// NoopOverrideContainerRequest returns a helper function that does not override the container request
// Deprecated: use testcontainers.ContainerCustomizer instead
var NoopOverrideContainerRequest = func(req testcontainers.ContainerRequest) testcontainers.ContainerRequest {
return req
}
func (opt OverrideContainerRequestOption) Customize(req *testcontainers.GenericContainerRequest) {
req.ContainerRequest = opt(req.ContainerRequest)
}
// OverrideContainerRequest returns a function that can be used to merge the passed container request with one that is created by the LocalStack container
// Deprecated: use testcontainers.CustomizeRequest instead
func OverrideContainerRequest(r testcontainers.ContainerRequest) func(req testcontainers.ContainerRequest) testcontainers.ContainerRequest {
destContainerReq := testcontainers.GenericContainerRequest{
ContainerRequest: r,
}
return func(req testcontainers.ContainerRequest) testcontainers.ContainerRequest {
srcContainerReq := testcontainers.GenericContainerRequest{
ContainerRequest: req,
}
opt := testcontainers.CustomizeRequest(destContainerReq)
opt.Customize(&srcContainerReq)
return srcContainerReq.ContainerRequest
}
}