Skip to content

Commit 4c7ffde

Browse files
authoredOct 10, 2023
feat: Use Docker's inspect API to get resource information (#1018)
1 parent 5a52c62 commit 4c7ffde

23 files changed

+150
-102
lines changed
 

‎src/Testcontainers/Builders/ContainerBuilder`3.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public TBuilderEntity WithImage(IImage image)
8484
}
8585

8686
/// <inheritdoc />
87-
public TBuilderEntity WithImagePullPolicy(Func<ImagesListResponse, bool> imagePullPolicy)
87+
public TBuilderEntity WithImagePullPolicy(Func<ImageInspectResponse, bool> imagePullPolicy)
8888
{
8989
return Clone(new ContainerConfiguration(imagePullPolicy: imagePullPolicy));
9090
}

‎src/Testcontainers/Builders/IContainerBuilder`2.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public interface IContainerBuilder<out TBuilderEntity, out TContainerEntity> : I
7878
/// <param name="imagePullPolicy">The image pull policy.</param>
7979
/// <returns>A configured instance of <typeparamref name="TBuilderEntity" />.</returns>
8080
[PublicAPI]
81-
TBuilderEntity WithImagePullPolicy(Func<ImagesListResponse, bool> imagePullPolicy);
81+
TBuilderEntity WithImagePullPolicy(Func<ImageInspectResponse, bool> imagePullPolicy);
8282

8383
/// <summary>
8484
/// Sets the name.

‎src/Testcontainers/Builders/IImageFromDockerfileBuilder`1.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public interface IImageFromDockerfileBuilder<out TBuilderEntity>
5959
/// <param name="imageBuildPolicy">The image build policy.</param>
6060
/// <returns>A configured instance of <typeparamref name="TBuilderEntity" />.</returns>
6161
[PublicAPI]
62-
TBuilderEntity WithImageBuildPolicy(Func<ImagesListResponse, bool> imageBuildPolicy);
62+
TBuilderEntity WithImageBuildPolicy(Func<ImageInspectResponse, bool> imageBuildPolicy);
6363

6464
/// <summary>
6565
/// Removes an existing image before building it again.

‎src/Testcontainers/Builders/ImageFromDockerfileBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public ImageFromDockerfileBuilder WithDockerfileDirectory(CommonDirectoryPath co
8181
}
8282

8383
/// <inheritdoc />
84-
public ImageFromDockerfileBuilder WithImageBuildPolicy(Func<ImagesListResponse, bool> imageBuildPolicy)
84+
public ImageFromDockerfileBuilder WithImageBuildPolicy(Func<ImageInspectResponse, bool> imageBuildPolicy)
8585
{
8686
return Merge(DockerResourceConfiguration, new ImageFromDockerfileConfiguration(imageBuildPolicy: imageBuildPolicy));
8787
}

‎src/Testcontainers/Clients/DockerContainerOperations.cs

+29-18
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ namespace DotNet.Testcontainers.Clients
44
using System.Collections.Generic;
55
using System.Globalization;
66
using System.IO;
7-
using System.Linq;
87
using System.Threading;
98
using System.Threading.Tasks;
9+
using Docker.DotNet;
1010
using Docker.DotNet.Models;
1111
using DotNet.Testcontainers.Configurations;
1212
using DotNet.Testcontainers.Containers;
@@ -24,37 +24,53 @@ public DockerContainerOperations(Guid sessionId, IDockerEndpointAuthenticationCo
2424

2525
public async Task<IEnumerable<ContainerListResponse>> GetAllAsync(CancellationToken ct = default)
2626
{
27-
return (await Docker.Containers.ListContainersAsync(new ContainersListParameters { All = true }, ct)
28-
.ConfigureAwait(false)).ToArray();
27+
return await Docker.Containers.ListContainersAsync(new ContainersListParameters { All = true }, ct)
28+
.ConfigureAwait(false);
29+
}
30+
31+
public async Task<IEnumerable<ContainerListResponse>> GetAllAsync(FilterByProperty filters, CancellationToken ct = default)
32+
{
33+
return await Docker.Containers.ListContainersAsync(new ContainersListParameters { All = true, Filters = filters }, ct)
34+
.ConfigureAwait(false);
2935
}
3036

31-
public Task<ContainerListResponse> ByIdAsync(string id, CancellationToken ct = default)
37+
public Task<ContainerInspectResponse> ByIdAsync(string id, CancellationToken ct = default)
3238
{
3339
return ByPropertyAsync("id", id, ct);
3440
}
3541

36-
public Task<ContainerListResponse> ByNameAsync(string name, CancellationToken ct = default)
42+
public Task<ContainerInspectResponse> ByNameAsync(string name, CancellationToken ct = default)
3743
{
3844
return ByPropertyAsync("name", name, ct);
3945
}
4046

41-
public async Task<ContainerListResponse> ByPropertyAsync(string property, string value, CancellationToken ct = default)
47+
public async Task<ContainerInspectResponse> ByPropertyAsync(string property, string value, CancellationToken ct = default)
4248
{
43-
var filters = new FilterByProperty { { property, value } };
44-
return (await Docker.Containers.ListContainersAsync(new ContainersListParameters { All = true, Filters = filters }, ct)
45-
.ConfigureAwait(false)).FirstOrDefault();
49+
try
50+
{
51+
return await Docker.Containers.InspectContainerAsync(value, ct)
52+
.ConfigureAwait(false);
53+
}
54+
catch (DockerApiException)
55+
{
56+
return null;
57+
}
4658
}
4759

4860
public async Task<bool> ExistsWithIdAsync(string id, CancellationToken ct = default)
4961
{
50-
return await ByIdAsync(id, ct)
51-
.ConfigureAwait(false) != null;
62+
var response = await ByIdAsync(id, ct)
63+
.ConfigureAwait(false);
64+
65+
return response != null;
5266
}
5367

5468
public async Task<bool> ExistsWithNameAsync(string name, CancellationToken ct = default)
5569
{
56-
return await ByNameAsync(name, ct)
57-
.ConfigureAwait(false) != null;
70+
var response = await ByNameAsync(name, ct)
71+
.ConfigureAwait(false);
72+
73+
return response != null;
5874
}
5975

6076
public async Task<long> GetExitCodeAsync(string id, CancellationToken ct = default)
@@ -214,10 +230,5 @@ public async Task<string> RunAsync(IContainerConfiguration configuration, Cancel
214230
_logger.DockerContainerCreated(createContainerResponse.ID);
215231
return createContainerResponse.ID;
216232
}
217-
218-
public Task<ContainerInspectResponse> InspectAsync(string id, CancellationToken ct = default)
219-
{
220-
return Docker.Containers.InspectContainerAsync(id, ct);
221-
}
222233
}
223234
}

‎src/Testcontainers/Clients/DockerImageOperations.cs

+30-14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace DotNet.Testcontainers.Clients
66
using System.Linq;
77
using System.Threading;
88
using System.Threading.Tasks;
9+
using Docker.DotNet;
910
using Docker.DotNet.Models;
1011
using DotNet.Testcontainers.Configurations;
1112
using DotNet.Testcontainers.Images;
@@ -26,38 +27,53 @@ public DockerImageOperations(Guid sessionId, IDockerEndpointAuthenticationConfig
2627

2728
public async Task<IEnumerable<ImagesListResponse>> GetAllAsync(CancellationToken ct = default)
2829
{
29-
return (await Docker.Images.ListImagesAsync(new ImagesListParameters { All = true }, ct)
30-
.ConfigureAwait(false)).ToArray();
30+
return await Docker.Images.ListImagesAsync(new ImagesListParameters { All = true }, ct)
31+
.ConfigureAwait(false);
32+
}
33+
34+
public async Task<IEnumerable<ImagesListResponse>> GetAllAsync(FilterByProperty filters, CancellationToken ct = default)
35+
{
36+
return await Docker.Images.ListImagesAsync(new ImagesListParameters { All = true, Filters = filters }, ct)
37+
.ConfigureAwait(false);
3138
}
3239

33-
public async Task<ImagesListResponse> ByIdAsync(string id, CancellationToken ct = default)
40+
public Task<ImageInspectResponse> ByIdAsync(string id, CancellationToken ct = default)
3441
{
35-
return (await GetAllAsync(ct)
36-
.ConfigureAwait(false)).FirstOrDefault(image => image.ID.Equals(id, StringComparison.OrdinalIgnoreCase));
42+
return ByPropertyAsync("id", id, ct);
3743
}
3844

39-
public Task<ImagesListResponse> ByNameAsync(string name, CancellationToken ct = default)
45+
public Task<ImageInspectResponse> ByNameAsync(string name, CancellationToken ct = default)
4046
{
4147
return ByPropertyAsync("reference", name, ct);
4248
}
4349

44-
public async Task<ImagesListResponse> ByPropertyAsync(string property, string value, CancellationToken ct = default)
50+
public async Task<ImageInspectResponse> ByPropertyAsync(string property, string value, CancellationToken ct = default)
4551
{
46-
var filters = new FilterByProperty { { property, value } };
47-
return (await Docker.Images.ListImagesAsync(new ImagesListParameters { All = true, Filters = filters }, ct)
48-
.ConfigureAwait(false)).FirstOrDefault();
52+
try
53+
{
54+
return await Docker.Images.InspectImageAsync(value, ct)
55+
.ConfigureAwait(false);
56+
}
57+
catch (DockerApiException)
58+
{
59+
return null;
60+
}
4961
}
5062

5163
public async Task<bool> ExistsWithIdAsync(string id, CancellationToken ct = default)
5264
{
53-
return await ByIdAsync(id, ct)
54-
.ConfigureAwait(false) != null;
65+
var response = await ByIdAsync(id, ct)
66+
.ConfigureAwait(false);
67+
68+
return response != null;
5569
}
5670

5771
public async Task<bool> ExistsWithNameAsync(string name, CancellationToken ct = default)
5872
{
59-
return await ByNameAsync(name, ct)
60-
.ConfigureAwait(false) != null;
73+
var response = await ByNameAsync(name, ct)
74+
.ConfigureAwait(false);
75+
76+
return response != null;
6177
}
6278

6379
public async Task CreateAsync(IImage image, IDockerRegistryAuthenticationConfiguration dockerRegistryAuthConfig, CancellationToken ct = default)

‎src/Testcontainers/Clients/DockerNetworkOperations.cs

+28-12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace DotNet.Testcontainers.Clients
55
using System.Linq;
66
using System.Threading;
77
using System.Threading.Tasks;
8+
using Docker.DotNet;
89
using Docker.DotNet.Models;
910
using DotNet.Testcontainers.Configurations;
1011
using Microsoft.Extensions.Logging;
@@ -21,14 +22,19 @@ public DockerNetworkOperations(Guid sessionId, IDockerEndpointAuthenticationConf
2122

2223
public async Task<IEnumerable<NetworkResponse>> GetAllAsync(CancellationToken ct = default)
2324
{
24-
return (await Docker.Networks.ListNetworksAsync(new NetworksListParameters(), ct)
25-
.ConfigureAwait(false)).ToArray();
25+
return await Docker.Networks.ListNetworksAsync(new NetworksListParameters(), ct)
26+
.ConfigureAwait(false);
2627
}
2728

28-
public async Task<NetworkResponse> ByIdAsync(string id, CancellationToken ct = default)
29+
public async Task<IEnumerable<NetworkResponse>> GetAllAsync(FilterByProperty filters, CancellationToken ct = default)
2930
{
30-
return (await GetAllAsync(ct)
31-
.ConfigureAwait(false)).FirstOrDefault(image => image.ID.Equals(id, StringComparison.OrdinalIgnoreCase));
31+
return await Docker.Networks.ListNetworksAsync(new NetworksListParameters { Filters = filters }, ct)
32+
.ConfigureAwait(false);
33+
}
34+
35+
public Task<NetworkResponse> ByIdAsync(string id, CancellationToken ct = default)
36+
{
37+
return ByPropertyAsync("id", id, ct);
3238
}
3339

3440
public Task<NetworkResponse> ByNameAsync(string name, CancellationToken ct = default)
@@ -38,21 +44,31 @@ public Task<NetworkResponse> ByNameAsync(string name, CancellationToken ct = def
3844

3945
public async Task<NetworkResponse> ByPropertyAsync(string property, string value, CancellationToken ct = default)
4046
{
41-
var filters = new FilterByProperty { { property, value } };
42-
return (await Docker.Networks.ListNetworksAsync(new NetworksListParameters { Filters = filters }, ct)
43-
.ConfigureAwait(false)).FirstOrDefault();
47+
try
48+
{
49+
return await Docker.Networks.InspectNetworkAsync(value, ct)
50+
.ConfigureAwait(false);
51+
}
52+
catch (DockerApiException)
53+
{
54+
return null;
55+
}
4456
}
4557

4658
public async Task<bool> ExistsWithIdAsync(string id, CancellationToken ct = default)
4759
{
48-
return await ByIdAsync(id, ct)
49-
.ConfigureAwait(false) != null;
60+
var response = await ByIdAsync(id, ct)
61+
.ConfigureAwait(false);
62+
63+
return response != null;
5064
}
5165

5266
public async Task<bool> ExistsWithNameAsync(string name, CancellationToken ct = default)
5367
{
54-
return await ByNameAsync(name, ct)
55-
.ConfigureAwait(false) != null;
68+
var response = await ByNameAsync(name, ct)
69+
.ConfigureAwait(false);
70+
71+
return response != null;
5672
}
5773

5874
public async Task<string> CreateAsync(INetworkConfiguration configuration, CancellationToken ct = default)

‎src/Testcontainers/Clients/DockerVolumeOperations.cs

+31-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace DotNet.Testcontainers.Clients
55
using System.Linq;
66
using System.Threading;
77
using System.Threading.Tasks;
8+
using Docker.DotNet;
89
using Docker.DotNet.Models;
910
using DotNet.Testcontainers.Configurations;
1011
using Microsoft.Extensions.Logging;
@@ -21,13 +22,23 @@ public DockerVolumeOperations(Guid sessionId, IDockerEndpointAuthenticationConfi
2122

2223
public async Task<IEnumerable<VolumeResponse>> GetAllAsync(CancellationToken ct = default)
2324
{
24-
return (await Docker.Volumes.ListAsync(ct)
25-
.ConfigureAwait(false)).Volumes.ToArray();
25+
var response = await Docker.Volumes.ListAsync(ct)
26+
.ConfigureAwait(false);
27+
28+
return response.Volumes;
29+
}
30+
31+
public async Task<IEnumerable<VolumeResponse>> GetAllAsync(FilterByProperty filters, CancellationToken ct = default)
32+
{
33+
var response = await Docker.Volumes.ListAsync(new VolumesListParameters { Filters = filters }, ct)
34+
.ConfigureAwait(false);
35+
36+
return response.Volumes;
2637
}
2738

2839
public Task<VolumeResponse> ByIdAsync(string id, CancellationToken ct = default)
2940
{
30-
return Task.FromResult<VolumeResponse>(null);
41+
return ByPropertyAsync("id", id, ct);
3142
}
3243

3344
public Task<VolumeResponse> ByNameAsync(string name, CancellationToken ct = default)
@@ -37,21 +48,31 @@ public Task<VolumeResponse> ByNameAsync(string name, CancellationToken ct = defa
3748

3849
public async Task<VolumeResponse> ByPropertyAsync(string property, string value, CancellationToken ct = default)
3950
{
40-
var filters = new FilterByProperty { { property, value } };
41-
return (await Docker.Volumes.ListAsync(new VolumesListParameters { Filters = filters }, ct)
42-
.ConfigureAwait(false)).Volumes.FirstOrDefault();
51+
try
52+
{
53+
return await Docker.Volumes.InspectAsync(value, ct)
54+
.ConfigureAwait(false);
55+
}
56+
catch (DockerApiException)
57+
{
58+
return null;
59+
}
4360
}
4461

4562
public async Task<bool> ExistsWithIdAsync(string id, CancellationToken ct = default)
4663
{
47-
return await ByIdAsync(id, ct)
48-
.ConfigureAwait(false) != null;
64+
var response = await ByIdAsync(id, ct)
65+
.ConfigureAwait(false);
66+
67+
return response != null;
4968
}
5069

5170
public async Task<bool> ExistsWithNameAsync(string name, CancellationToken ct = default)
5271
{
53-
return await ByNameAsync(name, ct)
54-
.ConfigureAwait(false) != null;
72+
var response = await ByNameAsync(name, ct)
73+
.ConfigureAwait(false);
74+
75+
return response != null;
5576
}
5677

5778
public async Task<string> CreateAsync(IVolumeConfiguration configuration, CancellationToken ct = default)

‎src/Testcontainers/Clients/IDockerContainerOperations.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace DotNet.Testcontainers.Clients
99
using DotNet.Testcontainers.Configurations;
1010
using DotNet.Testcontainers.Containers;
1111

12-
internal interface IDockerContainerOperations : IHasListOperations<ContainerListResponse>
12+
internal interface IDockerContainerOperations : IHasListOperations<ContainerListResponse, ContainerInspectResponse>
1313
{
1414
Task<long> GetExitCodeAsync(string id, CancellationToken ct = default);
1515

@@ -30,7 +30,5 @@ internal interface IDockerContainerOperations : IHasListOperations<ContainerList
3030
Task<ExecResult> ExecAsync(string id, IList<string> command, CancellationToken ct = default);
3131

3232
Task<string> RunAsync(IContainerConfiguration configuration, CancellationToken ct = default);
33-
34-
Task<ContainerInspectResponse> InspectAsync(string id, CancellationToken ct = default);
3533
}
3634
}

‎src/Testcontainers/Clients/IDockerImageOperations.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace DotNet.Testcontainers.Clients
66
using DotNet.Testcontainers.Configurations;
77
using DotNet.Testcontainers.Images;
88

9-
internal interface IDockerImageOperations : IHasListOperations<ImagesListResponse>
9+
internal interface IDockerImageOperations : IHasListOperations<ImagesListResponse, ImageInspectResponse>
1010
{
1111
Task CreateAsync(IImage image, IDockerRegistryAuthenticationConfiguration dockerRegistryAuthConfig, CancellationToken ct = default);
1212

‎src/Testcontainers/Clients/IDockerNetworkOperations.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace DotNet.Testcontainers.Clients
55
using Docker.DotNet.Models;
66
using DotNet.Testcontainers.Configurations;
77

8-
internal interface IDockerNetworkOperations : IHasListOperations<NetworkResponse>
8+
internal interface IDockerNetworkOperations : IHasListOperations<NetworkResponse, NetworkResponse>
99
{
1010
Task<string> CreateAsync(INetworkConfiguration configuration, CancellationToken ct = default);
1111

‎src/Testcontainers/Clients/IDockerVolumeOperations.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace DotNet.Testcontainers.Clients
55
using Docker.DotNet.Models;
66
using DotNet.Testcontainers.Configurations;
77

8-
internal interface IDockerVolumeOperations : IHasListOperations<VolumeResponse>
8+
internal interface IDockerVolumeOperations : IHasListOperations<VolumeResponse, VolumeResponse>
99
{
1010
Task<string> CreateAsync(IVolumeConfiguration configuration, CancellationToken ct = default);
1111

‎src/Testcontainers/Clients/IHasListOperations.cs

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ namespace DotNet.Testcontainers.Clients
44
using System.Threading;
55
using System.Threading.Tasks;
66

7-
internal interface IHasListOperations<T>
7+
internal interface IHasListOperations<TListEntity, TInspectEntity>
88
{
9-
Task<IEnumerable<T>> GetAllAsync(CancellationToken ct = default);
9+
Task<IEnumerable<TListEntity>> GetAllAsync(CancellationToken ct = default);
1010

11-
Task<T> ByIdAsync(string id, CancellationToken ct = default);
11+
Task<IEnumerable<TListEntity>> GetAllAsync(FilterByProperty filters, CancellationToken ct = default);
1212

13-
Task<T> ByNameAsync(string name, CancellationToken ct = default);
13+
Task<TInspectEntity> ByIdAsync(string id, CancellationToken ct = default);
1414

15-
Task<T> ByPropertyAsync(string property, string value, CancellationToken ct = default);
15+
Task<TInspectEntity> ByNameAsync(string name, CancellationToken ct = default);
16+
17+
Task<TInspectEntity> ByPropertyAsync(string property, string value, CancellationToken ct = default);
1618

1719
Task<bool> ExistsWithIdAsync(string id, CancellationToken ct = default);
1820

‎src/Testcontainers/Clients/ITestcontainersClient.cs

-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace DotNet.Testcontainers.Clients
55
using System.IO;
66
using System.Threading;
77
using System.Threading.Tasks;
8-
using Docker.DotNet.Models;
98
using DotNet.Testcontainers.Configurations;
109
using DotNet.Testcontainers.Containers;
1110

@@ -63,14 +62,6 @@ internal interface ITestcontainersClient
6362
/// <returns>Task that gets the container logs.</returns>
6463
Task<(string Stdout, string Stderr)> GetContainerLogsAsync(string id, DateTime since = default, DateTime until = default, bool timestampsEnabled = true, CancellationToken ct = default);
6564

66-
/// <summary>
67-
/// Gets the container low-level information object.
68-
/// </summary>
69-
/// <param name="id">The container id.</param>
70-
/// <param name="ct">Cancellation token.</param>
71-
/// <returns>Task that gets the container low-level information object.</returns>
72-
Task<ContainerInspectResponse> InspectContainerAsync(string id, CancellationToken ct = default);
73-
7465
/// <summary>
7566
/// Starts the container.
7667
/// </summary>

‎src/Testcontainers/Clients/TestcontainersClient.cs

-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace DotNet.Testcontainers.Clients
99
using System.Threading;
1010
using System.Threading.Tasks;
1111
using Docker.DotNet;
12-
using Docker.DotNet.Models;
1312
using DotNet.Testcontainers.Builders;
1413
using DotNet.Testcontainers.Configurations;
1514
using DotNet.Testcontainers.Containers;
@@ -118,12 +117,6 @@ public Task<long> GetContainerExitCodeAsync(string id, CancellationToken ct = de
118117
return Container.GetLogsAsync(id, since.ToUniversalTime().Subtract(unixEpoch), until.ToUniversalTime().Subtract(unixEpoch), timestampsEnabled, ct);
119118
}
120119

121-
/// <inheritdoc />
122-
public Task<ContainerInspectResponse> InspectContainerAsync(string id, CancellationToken ct = default)
123-
{
124-
return Container.InspectAsync(id, ct);
125-
}
126-
127120
/// <inheritdoc />
128121
public async Task StartAsync(string id, CancellationToken ct = default)
129122
{

‎src/Testcontainers/Configurations/Containers/ContainerConfiguration.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class ContainerConfiguration : ResourceConfiguration<CreateContainerParam
4242
/// <param name="privileged">A value indicating whether the privileged flag is set or not.</param>
4343
public ContainerConfiguration(
4444
IImage image = null,
45-
Func<ImagesListResponse, bool> imagePullPolicy = null,
45+
Func<ImageInspectResponse, bool> imagePullPolicy = null,
4646
string name = null,
4747
string hostname = null,
4848
string macAddress = null,
@@ -148,7 +148,7 @@ public ContainerConfiguration(IContainerConfiguration oldValue, IContainerConfig
148148
public IImage Image { get; }
149149

150150
/// <inheritdoc />
151-
public Func<ImagesListResponse, bool> ImagePullPolicy { get; }
151+
public Func<ImageInspectResponse, bool> ImagePullPolicy { get; }
152152

153153
/// <inheritdoc />
154154
public string Name { get; }

‎src/Testcontainers/Configurations/Containers/IContainerConfiguration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public interface IContainerConfiguration : IResourceConfiguration<CreateContaine
3434
/// <summary>
3535
/// Gets the image pull policy.
3636
/// </summary>
37-
Func<ImagesListResponse, bool> ImagePullPolicy { get; }
37+
Func<ImageInspectResponse, bool> ImagePullPolicy { get; }
3838

3939
/// <summary>
4040
/// Gets the name.

‎src/Testcontainers/Configurations/Images/IImageFromDockerfileConfiguration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public interface IImageFromDockerfileConfiguration : IResourceConfiguration<Imag
3535
/// <summary>
3636
/// Gets the image build policy.
3737
/// </summary>
38-
Func<ImagesListResponse, bool> ImageBuildPolicy { get; }
38+
Func<ImageInspectResponse, bool> ImageBuildPolicy { get; }
3939

4040
/// <summary>
4141
/// Gets a list of build arguments.

‎src/Testcontainers/Configurations/Images/ImageFromDockerfileConfiguration.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public ImageFromDockerfileConfiguration(
2424
string dockerfile = null,
2525
string dockerfileDirectory = null,
2626
IImage image = null,
27-
Func<ImagesListResponse, bool> imageBuildPolicy = null,
27+
Func<ImageInspectResponse, bool> imageBuildPolicy = null,
2828
IReadOnlyDictionary<string, string> buildArguments = null,
2929
bool? deleteIfExists = null)
3030
{
@@ -83,7 +83,7 @@ public ImageFromDockerfileConfiguration(IImageFromDockerfileConfiguration oldVal
8383
public IImage Image { get; }
8484

8585
/// <inheritdoc />
86-
public Func<ImagesListResponse, bool> ImageBuildPolicy { get; }
86+
public Func<ImageInspectResponse, bool> ImageBuildPolicy { get; }
8787

8888
/// <inheritdoc />
8989
public IReadOnlyDictionary<string, string> BuildArguments { get; }

‎src/Testcontainers/Containers/DockerContainer.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ protected override async Task UnsafeCreateAsync(CancellationToken ct = default)
368368
var id = await _client.RunAsync(_configuration, ct)
369369
.ConfigureAwait(false);
370370

371-
_container = await _client.InspectContainerAsync(id, ct)
371+
_container = await _client.Container.ByIdAsync(id, ct)
372372
.ConfigureAwait(false);
373373

374374
Created?.Invoke(this, EventArgs.Empty);
@@ -407,7 +407,7 @@ protected virtual async Task UnsafeStartAsync(CancellationToken ct = default)
407407

408408
async Task<bool> CheckPortBindingsAsync()
409409
{
410-
_container = await _client.InspectContainerAsync(_container.ID, ct)
410+
_container = await _client.Container.ByIdAsync(_container.ID, ct)
411411
.ConfigureAwait(false);
412412

413413
var boundPorts = _container.NetworkSettings.Ports.Values.Where(portBindings => portBindings != null).SelectMany(portBinding => portBinding).Count(portBinding => !string.IsNullOrEmpty(portBinding.HostPort));
@@ -416,7 +416,7 @@ async Task<bool> CheckPortBindingsAsync()
416416

417417
async Task<bool> CheckWaitStrategyAsync(IWaitUntil wait)
418418
{
419-
_container = await _client.InspectContainerAsync(_container.ID, ct)
419+
_container = await _client.Container.ByIdAsync(_container.ID, ct)
420420
.ConfigureAwait(false);
421421

422422
return await wait.UntilAsync(this)
@@ -474,7 +474,7 @@ await _client.StopAsync(_container.ID, ct)
474474

475475
try
476476
{
477-
_container = await _client.InspectContainerAsync(_container.ID, ct)
477+
_container = await _client.Container.ByIdAsync(_container.ID, ct)
478478
.ConfigureAwait(false);
479479
}
480480
catch (DockerApiException)

‎src/Testcontainers/Images/FutureDockerImage.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal sealed class FutureDockerImage : Resource, IFutureDockerImage
1616

1717
private readonly IImageFromDockerfileConfiguration _configuration;
1818

19-
private ImagesListResponse _image = new ImagesListResponse();
19+
private ImageInspectResponse _image = new ImageInspectResponse();
2020

2121
/// <summary>
2222
/// Initializes a new instance of the <see cref="FutureDockerImage" /> class.
@@ -132,7 +132,7 @@ protected override async Task UnsafeDeleteAsync(CancellationToken ct = default)
132132
await _client.Image.DeleteAsync(_configuration.Image, ct)
133133
.ConfigureAwait(false);
134134

135-
_image = new ImagesListResponse();
135+
_image = new ImageInspectResponse();
136136
}
137137
}
138138
}

‎src/Testcontainers/Images/PullPolicy.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static class PullPolicy
1313
/// <summary>
1414
/// Gets the policy that never pulls images.
1515
/// </summary>
16-
public static Func<ImagesListResponse, bool> Never
16+
public static Func<ImageInspectResponse, bool> Never
1717
{
1818
get
1919
{
@@ -24,7 +24,7 @@ public static Func<ImagesListResponse, bool> Never
2424
/// <summary>
2525
/// Gets the policy that pulls missing images (not cached).
2626
/// </summary>
27-
public static Func<ImagesListResponse, bool> Missing
27+
public static Func<ImageInspectResponse, bool> Missing
2828
{
2929
get
3030
{
@@ -35,7 +35,7 @@ public static Func<ImagesListResponse, bool> Missing
3535
/// <summary>
3636
/// Gets the policy that always pulls images.
3737
/// </summary>
38-
public static Func<ImagesListResponse, bool> Always
38+
public static Func<ImageInspectResponse, bool> Always
3939
{
4040
get
4141
{

‎src/Testcontainers/Volumes/DockerVolume.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ protected override async Task UnsafeCreateAsync(CancellationToken ct = default)
9494
return;
9595
}
9696

97-
var name = await _client.Volume.CreateAsync(_configuration, ct)
97+
var id = await _client.Volume.CreateAsync(_configuration, ct)
9898
.ConfigureAwait(false);
9999

100-
_volume = await _client.Volume.ByNameAsync(name, ct)
100+
_volume = await _client.Volume.ByIdAsync(id, ct)
101101
.ConfigureAwait(false);
102102
}
103103

0 commit comments

Comments
 (0)
Please sign in to comment.