Skip to content

Commit

Permalink
[#470] #BUGFIX 'assemblyName: DotNet.Testcontainers; function: Docker…
Browse files Browse the repository at this point in the history
…Image'

{Consider hostname of Docker Hub image name prefix when configured.}
  • Loading branch information
bohlenc authored and HofmeisterAn committed Jun 8, 2022
1 parent ad6665b commit f3096c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DotNet.Testcontainers/Images/DockerImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public string FullName
/// <inheritdoc />
public string GetHostname()
{
var firstSegmentOfRepository = this.Repository.Split('/').First();
var firstSegmentOfRepository = (string.IsNullOrEmpty(this.hubImageNamePrefix) ? this.Repository : this.hubImageNamePrefix).Split('/').First();
return firstSegmentOfRepository.IndexOfAny(new[] { '.', ':' }) >= 0 ? firstSegmentOfRepository : null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ public void GetHostnameFromDockerImage(string dockerImageName, string hostname)
Assert.Equal(hostname, image.GetHostname());
}

[Theory]
[InlineData("", "docker", "stable")]
[InlineData("fedora", "httpd", "1.0")]
[InlineData("foo/bar", "baz", "1.0.0")]
public void GetHostnameFromHubImageNamePrefix(string repository, string name, string tag)
{
const string hubImageNamePrefix = "myregistry.azurecr.io";
IDockerImage image = new DockerImage(repository, name, tag, hubImageNamePrefix);
Assert.Equal(hubImageNamePrefix, image.GetHostname());
}

[Fact]
public void ShouldGetDefaultDockerRegistryAuthenticationConfiguration()
{
Expand Down

0 comments on commit f3096c0

Please sign in to comment.