@@ -181,11 +181,115 @@ public ContainerResourceBuilder AddPortMapping(int internalPort, int externalPor
181
181
_options . AdditionalPortMappings . Add (
182
182
new ContainerPortMapping ( )
183
183
{
184
- ExternalPort = externalPort , InternalPort = internalPort
184
+ ExternalPort = externalPort ,
185
+ InternalPort = internalPort
185
186
} ) ;
186
187
return this ;
187
188
}
188
189
190
+ /// <summary>
191
+ /// If you only want to expose one port, please use <see cref="InternalPort"/> and
192
+ /// <see cref="ExternalPort"/> to so do!
193
+ /// Exposes additional port mappings for this container.
194
+ /// </summary>
195
+ /// <param name="internalPort">
196
+ /// The internal port of a container that shall be exposed.
197
+ /// </param>
198
+ /// <param name="externalPortVariableName">
199
+ /// The external port number will be resolved before the container creation and stored in
200
+ /// variable.
201
+ /// Only provide an external port if a static external port is required.
202
+ /// When the given external port is already in use by a container, the creation will fail.
203
+ /// </param>
204
+ /// <returns></returns>
205
+ public ContainerResourceBuilder AddPortMapping (
206
+ int internalPort ,
207
+ string externalPortVariableName )
208
+ {
209
+ _options . AdditionalPortMappings . Add (
210
+ new ContainerPortMapping ( )
211
+ {
212
+ InternalPort = internalPort ,
213
+ ExternalPortVariableName = externalPortVariableName ,
214
+ } ) ;
215
+ return this ;
216
+ }
217
+
218
+
219
+ /// <summary>
220
+ /// If you only want to expose one port, please use <see cref="InternalPort"/> and
221
+ /// <see cref="ExternalPort"/> to so do!
222
+ /// Exposes additional port mappings for this container.
223
+ /// </summary>
224
+ /// <param name="internalPortVariableName">
225
+ /// The internal port number will be resolved before the container creation and stored
226
+ /// in variable.
227
+ /// </param>
228
+ /// <param name="externalPort">
229
+ /// The external static port of a container that the internal port will be mapped to.
230
+ /// Defaults to 0, which will let the OS choose a free port for you.
231
+ ///
232
+ /// Only provide an external port if a static external port is required.
233
+ /// When the given external port is already in use by a container, the creation will fail.
234
+ /// </param>
235
+ /// <returns></returns>
236
+ public ContainerResourceBuilder AddPortMapping (
237
+ string internalPortVariableName ,
238
+ int externalPort = 0 )
239
+ {
240
+ _options . AdditionalPortMappings . Add (
241
+ new ContainerPortMapping ( )
242
+ {
243
+ InternalPortVariableName = internalPortVariableName ,
244
+ ExternalPort = externalPort ,
245
+ } ) ;
246
+ return this ;
247
+ }
248
+
249
+ /// <summary>
250
+ /// If you only want to expose one port, please use <see cref="InternalPort"/> and
251
+ /// <see cref="ExternalPort"/> to so do!
252
+ /// Exposes additional port mappings for this container.
253
+ /// </summary>
254
+ /// <param name="internalPortVariableName">
255
+ /// The internal port number will be resolved before the container creation and stored
256
+ /// in variable.
257
+ /// </param>
258
+ /// <param name="externalPortVariableName">
259
+ /// The external port number will be resolved before the container creation and stored in
260
+ /// variable.
261
+ /// Only provide an external port if a static external port is required.
262
+ /// When the given external port is already in use by a container, the creation will fail.
263
+ /// </param>
264
+ /// <returns></returns>
265
+ public ContainerResourceBuilder AddPortMapping (
266
+ string internalPortVariableName ,
267
+ string externalPortVariableName )
268
+ {
269
+ _options . AdditionalPortMappings . Add (
270
+ new ContainerPortMapping ( )
271
+ {
272
+ InternalPortVariableName = internalPortVariableName ,
273
+ ExternalPortVariableName = externalPortVariableName
274
+ } ) ;
275
+ return this ;
276
+ }
277
+
278
+ /// <summary>
279
+ /// Variables that will be resolved before container is created. They can be then
280
+ /// used in port AdditionalPortMappings and EnvironmentVariables (referenced between
281
+ /// '{}' brackets eg. {RUNTIME_VARIABLE_1}.)
282
+ /// </summary>
283
+ /// <param name="name"></param>
284
+ /// <param name="type"></param>
285
+ /// <returns></returns>
286
+ public ContainerResourceBuilder AddVariable ( string name , VariableType type )
287
+ {
288
+ _options . Variables . Add ( new Variable ( name , type ) ) ;
289
+
290
+ return this ;
291
+ }
292
+
189
293
/// <summary>
190
294
/// Wait timeout in seconds
191
295
/// </summary>
0 commit comments