@@ -28,6 +28,14 @@ final case class ServiceLogConsumer(serviceName: String, consumer: Consumer[Outp
28
28
29
29
final case class WaitingForService (serviceName : String , waitStrategy : WaitStrategy )
30
30
31
+ sealed trait Services
32
+ object Services {
33
+ case object All extends Services
34
+ final case class Specific (services : Seq [Service ]) extends Services
35
+ }
36
+
37
+ final case class Service (name : String )
38
+
31
39
object DockerComposeContainer {
32
40
val ID_LENGTH = 6
33
41
@@ -63,7 +71,8 @@ object DockerComposeContainer {
63
71
env : Map [String , String ] = Map .empty,
64
72
tailChildContainers : Boolean = false ,
65
73
logConsumers : Seq [ServiceLogConsumer ] = Seq .empty,
66
- waitingFor : Option [WaitingForService ] = None ): DockerComposeContainer =
74
+ waitingFor : Option [WaitingForService ] = None ,
75
+ services : Services = Services .All ): DockerComposeContainer =
67
76
new DockerComposeContainer (composeFiles,
68
77
exposedServices,
69
78
identifier,
@@ -73,7 +82,8 @@ object DockerComposeContainer {
73
82
env,
74
83
tailChildContainers,
75
84
logConsumers,
76
- waitingFor)
85
+ waitingFor,
86
+ services)
77
87
78
88
case class Def (
79
89
composeFiles : ComposeFile ,
@@ -85,7 +95,8 @@ object DockerComposeContainer {
85
95
env : Map [String , String ] = Map .empty,
86
96
tailChildContainers : Boolean = false ,
87
97
logConsumers : Seq [ServiceLogConsumer ] = Seq .empty,
88
- waitingFor : Option [WaitingForService ] = None
98
+ waitingFor : Option [WaitingForService ] = None ,
99
+ services : Services = Services .All
89
100
) extends ContainerDef {
90
101
91
102
override type Container = DockerComposeContainer
@@ -101,7 +112,8 @@ object DockerComposeContainer {
101
112
env,
102
113
tailChildContainers,
103
114
logConsumers,
104
- waitingFor
115
+ waitingFor,
116
+ services
105
117
)
106
118
}
107
119
}
@@ -117,7 +129,8 @@ class DockerComposeContainer(composeFiles: ComposeFile,
117
129
env : Map [String , String ] = Map .empty,
118
130
tailChildContainers : Boolean = false ,
119
131
logConsumers : Seq [ServiceLogConsumer ] = Seq .empty,
120
- waitingFor : Option [WaitingForService ] = None )
132
+ waitingFor : Option [WaitingForService ] = None ,
133
+ services : Services = Services .All )
121
134
extends TestContainerProxy [JavaDockerComposeContainer [_]] {
122
135
123
136
override val container : JavaDockerComposeContainer [_] = {
@@ -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