-
-
Notifications
You must be signed in to change notification settings - Fork 345
Expand file tree
/
Copy pathIImageExtensions.cs
More file actions
33 lines (30 loc) · 1.01 KB
/
IImageExtensions.cs
File metadata and controls
33 lines (30 loc) · 1.01 KB
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
namespace DotNet.Testcontainers.Images
{
using DotNet.Testcontainers.Configurations;
/// <summary>
/// Provides extension methods for the <see cref="IImage" /> interface.
/// </summary>
internal static class IImageExtensions
{
/// <summary>
/// Applies the Docker Hub image name prefix if it is configured.
/// </summary>
/// <param name="image">The original <see cref="IImage" /> instance.</param>
/// <returns>
/// A new <see cref="IImage" /> instance with the Docker Hub image name prefix
/// applied, or the original instance if no prefix is set.
/// </returns>
public static IImage ApplyHubImageNamePrefix(this IImage image)
{
if (string.IsNullOrEmpty(TestcontainersSettings.HubImageNamePrefix))
{
return image;
}
if (!string.IsNullOrEmpty(image.GetHostname()))
{
return image;
}
return new DockerImage(image.Repository, image.Registry, image.Tag, image.Digest, TestcontainersSettings.HubImageNamePrefix);
}
}
}