@@ -12,6 +12,14 @@ import org.testcontainers.utility.Base58
12
12
13
13
import scala .collection .JavaConverters ._
14
14
15
+ sealed trait Services
16
+ object Services {
17
+ case object All extends Services
18
+ final case class Specific (services : Seq [Service ]) extends Services
19
+ }
20
+
21
+ final case class Service (name : String )
22
+
15
23
object ExposedService {
16
24
def apply (name : String , port : Int , instance : Int , waitStrategy : WaitStrategy ): ExposedService =
17
25
ExposedService (name, port, waitStrategy, Option (instance))
@@ -52,9 +60,10 @@ object DockerComposeContainer {
52
60
@ deprecated(" Please use expanded `apply` method" )
53
61
def apply (composeFiles : ComposeFile ,
54
62
exposedService : Map [String , Int ]): DockerComposeContainer =
55
- new DockerComposeContainer (composeFiles, exposedService)
63
+ new DockerComposeContainer (composeFiles, Services . All , exposedService)
56
64
57
65
def apply (composeFiles : ComposeFile ,
66
+ services : Services = Services .All ,
58
67
exposedServices : Seq [ExposedService ] = Seq .empty,
59
68
identifier : String = DockerComposeContainer .randomIdentifier,
60
69
scaledServices : Seq [ScaledService ] = Seq .empty,
@@ -65,6 +74,7 @@ object DockerComposeContainer {
65
74
logConsumers : Seq [ServiceLogConsumer ] = Seq .empty,
66
75
waitingFor : Option [WaitingForService ] = None ): DockerComposeContainer =
67
76
new DockerComposeContainer (composeFiles,
77
+ services,
68
78
exposedServices,
69
79
identifier,
70
80
scaledServices,
@@ -77,6 +87,7 @@ object DockerComposeContainer {
77
87
78
88
case class Def (
79
89
composeFiles : ComposeFile ,
90
+ services : Services = Services .All ,
80
91
exposedServices : Seq [ExposedService ] = Seq .empty,
81
92
identifier : String = DockerComposeContainer .randomIdentifier,
82
93
scaledServices : Seq [ScaledService ] = Seq .empty,
@@ -93,6 +104,7 @@ object DockerComposeContainer {
93
104
override def createContainer (): DockerComposeContainer = {
94
105
DockerComposeContainer (
95
106
composeFiles,
107
+ services,
96
108
exposedServices,
97
109
identifier,
98
110
scaledServices,
@@ -109,6 +121,7 @@ object DockerComposeContainer {
109
121
}
110
122
111
123
class DockerComposeContainer (composeFiles : ComposeFile ,
124
+ services : Services = Services .All ,
112
125
exposedServices : Seq [ExposedService ] = Seq .empty,
113
126
identifier : String = DockerComposeContainer .randomIdentifier,
114
127
scaledServices : Seq [ScaledService ] = Seq .empty,
@@ -126,6 +139,11 @@ class DockerComposeContainer(composeFiles: ComposeFile,
126
139
case ComposeFile (Right (files)) => files.asJava
127
140
})
128
141
142
+ services match {
143
+ case Services .Specific (services) => container.withServices(services.map(_.name) : _* )
144
+ case Services .All =>
145
+ }
146
+
129
147
exposedServices.foreach { service =>
130
148
if (service.instance.isDefined) {
131
149
container.withExposedService(service.name, service.instance.get, service.port, service.waitStrategy)
0 commit comments