-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
49 lines (41 loc) 路 1.51 KB
/
options.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
package testcontainers
import (
"fmt"
"github.com/testcontainers/testcontainers-go"
)
// WithNamePrefix sets a prefix for the request name.
func WithNamePrefix(prefix string) GenericContainerOption {
return genericContainerOptionFunc(func(o *genericContainerOptions) {
o.request.Name = fmt.Sprintf("%s_%s", prefix, o.request.Name)
})
}
// WithNameSuffix sets a suffix for the request name.
func WithNameSuffix(suffix string) GenericContainerOption {
return genericContainerOptionFunc(func(o *genericContainerOptions) {
o.request.Name = fmt.Sprintf("%s_%s", o.request.Name, suffix)
})
}
// WithImageName sets the image name.
func WithImageName(name string) GenericContainerOption {
return genericContainerOptionFunc(func(o *genericContainerOptions) {
o.request.Image = changeImageName(o.request.Image, name)
})
}
// WithImageTag sets the image tag.
func WithImageTag(tag string) GenericContainerOption {
return genericContainerOptionFunc(func(o *genericContainerOptions) {
o.request.Image = changeImageTag(o.request.Image, tag)
})
}
// WithCallback adds a new callback to run after the container is ready.
func WithCallback(f ContainerCallback) GenericContainerOption {
return genericContainerOptionFunc(func(o *genericContainerOptions) {
o.callbacks = append(o.callbacks, f)
})
}
// WithProviderType sets the provider type.
func WithProviderType(providerType testcontainers.ProviderType) GenericContainerOption {
return genericContainerOptionFunc(func(o *genericContainerOptions) {
o.providerType = providerType
})
}