Skip to content

Commit

Permalink
Ensure Testcontainers works properly with MS SQL Server on CI.
Browse files Browse the repository at this point in the history
See #1558.
  • Loading branch information
gregturn committed Jul 10, 2023
1 parent 15c1ae8 commit 8d694ca
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ci/accept-third-party-license.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
{
echo "mcr.microsoft.com/mssql/server:2019-CU16-ubuntu-20.04"
echo "ibmcom/db2:11.5.7.0a"
echo "harbor-repo.vmware.com/mcr-proxy-cache/mssql/server:2019-CU16-ubuntu-20.04"
echo "harbor-repo.vmware.com/dockerhub-proxy-cache/ibmcom/db2:11.5.7.0a"
} > spring-data-jdbc/src/test/resources/container-license-acceptance.txt

{
echo "mcr.microsoft.com/mssql/server:2022-latest"
echo "ibmcom/db2:11.5.7.0a"
echo "harbor-repo.vmware.com/mcr-proxy-cache/mssql/server:2022-latest"
echo "harbor-repo.vmware.com/dockerhub-proxy-cache/ibmcom/db2:11.5.7.0a"
} > spring-data-r2dbc/src/test/resources/container-license-acceptance.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ public class ProxyImageNameSubstitutor extends ImageNameSubstitutor {
private static final Logger LOG = LoggerFactory.getLogger(ProxyImageNameSubstitutor.class);

private static final List<String> NAMES_TO_PROXY_PREFIX = List.of("ryuk", "arm64v8/mariadb", "ibmcom/db2",
"gvenzl/oracle-xe");
"gvenzl/oracle-free", "gvenzl/oracle-xe");

private static final List<String> NAMES_TO_LIBRARY_PROXY_PREFIX = List.of("mariadb", "mysql", "postgres");

private static final List<String> NAMES_TO_MCR_PROXY_PREFIX = List.of("mcr.microsoft.com/mssql");

private static final String PROXY_PREFIX = "harbor-repo.vmware.com/dockerhub-proxy-cache/";

private static final String LIBRARY_PROXY_PREFIX = PROXY_PREFIX + "library/";

private static final String MCR_PROXY_PREFIX = "harbor-repo.vmware.com/mcr-proxy-cache/";

@Override
public DockerImageName apply(DockerImageName dockerImageName) {

Expand All @@ -58,6 +62,13 @@ public DockerImageName apply(DockerImageName dockerImageName) {
return DockerImageName.parse(transformedName);
}

if (NAMES_TO_MCR_PROXY_PREFIX.stream().anyMatch(s -> dockerImageName.asCanonicalNameString().contains(s))) {

String transformedName = applyMcrProxyPrefix(dockerImageName.asCanonicalNameString());
LOG.info("Converting " + dockerImageName.asCanonicalNameString() + " to " + transformedName);
return DockerImageName.parse(transformedName);
}

LOG.info("Not changing " + dockerImageName.asCanonicalNameString() + "...");
return dockerImageName;
}
Expand All @@ -80,4 +91,11 @@ private static String applyProxyPrefix(String imageName) {
private static String applyProxyAndLibraryPrefix(String imageName) {
return LIBRARY_PROXY_PREFIX + imageName;
}

/**
* Apply an MCR-based prefix.
*/
private static String applyMcrProxyPrefix(String imageName) {
return MCR_PROXY_PREFIX + imageName.substring("mcr.microsoft.com/".length());
}
}

0 comments on commit 8d694ca

Please # to comment.