diff --git a/.gitignore b/.gitignore
index 13b9ed1052..5c4a9946c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,5 @@ target/
#prevent license accepting file to get accidentially commited to git
container-license-acceptance.txt
+spring-data-jdbc/src/test/java/org/springframework/data/ProxyImageNameSubstitutor.java
+spring-data-r2dbc/src/test/java/org/springframework/data/ProxyImageNameSubstitutor.java
\ No newline at end of file
diff --git a/Jenkinsfile b/Jenkinsfile
index 58097e6bf7..295fe11509 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -33,6 +33,7 @@ pipeline {
environment {
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
+ TESTCONTAINERS_IMAGE_SUBSTITUTOR = 'org.springframework.data.ProxyImageNameSubstitutor'
}
steps {
@@ -49,7 +50,7 @@ pipeline {
when {
beforeAgent(true)
allOf {
- branch(pattern: "main|(\\d\\.\\d\\.x)", comparator: "REGEXP")
+ branch(pattern: "issue/proxy|main|(\\d\\.\\d\\.x)", comparator: "REGEXP") // TODO
not { triggeredBy 'UpstreamCause' }
}
}
@@ -61,6 +62,7 @@ pipeline {
options { timeout(time: 30, unit: 'MINUTES') }
environment {
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
+ TESTCONTAINERS_IMAGE_SUBSTITUTOR = 'org.springframework.data.ProxyImageNameSubstitutor'
}
steps {
script {
diff --git a/ci/accept-third-party-license.sh b/ci/accept-third-party-license.sh
index 7b895f3c77..b584deb847 100755
--- a/ci/accept-third-party-license.sh
+++ b/ci/accept-third-party-license.sh
@@ -3,9 +3,11 @@
{
echo "mcr.microsoft.com/mssql/server:2019-CU16-ubuntu-20.04"
echo "ibmcom/db2:11.5.7.0a"
+ 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/dockerhub-proxy-cache/ibmcom/db2:11.5.7.0a"
} > spring-data-r2dbc/src/test/resources/container-license-acceptance.txt
diff --git a/ci/test.sh b/ci/test.sh
index b2421a6963..4eb82eda35 100755
--- a/ci/test.sh
+++ b/ci/test.sh
@@ -3,6 +3,11 @@
set -euo pipefail
ci/accept-third-party-license.sh
+
+echo "Copying ProxyImageNameSubstitutor into JDBC and R2DBC..."
+cp spring-data-relational/src/test/java/org/springframework/data/ProxyImageNameSubstitutor.java spring-data-jdbc/src/test/java/org/springframework/data
+cp spring-data-relational/src/test/java/org/springframework/data/ProxyImageNameSubstitutor.java spring-data-r2dbc/src/test/java/org/springframework/data
+
mkdir -p /tmp/jenkins-home
chown -R 1001:1001 .
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" \
diff --git a/pom.xml b/pom.xml
index 4a5a0c9822..3768902b00 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-relational-parent
- 3.2.0-SNAPSHOT
+ 3.2.0-proxy-SNAPSHOT
pom
Spring Data Relational Parent
diff --git a/spring-data-jdbc-distribution/pom.xml b/spring-data-jdbc-distribution/pom.xml
index d834798834..5ba30c189b 100644
--- a/spring-data-jdbc-distribution/pom.xml
+++ b/spring-data-jdbc-distribution/pom.xml
@@ -14,7 +14,7 @@
org.springframework.data
spring-data-relational-parent
- 3.2.0-SNAPSHOT
+ 3.2.0-proxy-SNAPSHOT
../pom.xml
diff --git a/spring-data-jdbc/pom.xml b/spring-data-jdbc/pom.xml
index ede9f0390f..fe7416598f 100644
--- a/spring-data-jdbc/pom.xml
+++ b/spring-data-jdbc/pom.xml
@@ -6,7 +6,7 @@
4.0.0
spring-data-jdbc
- 3.2.0-SNAPSHOT
+ 3.2.0-proxy-SNAPSHOT
Spring Data JDBC
Spring Data module for JDBC repositories.
@@ -15,7 +15,7 @@
org.springframework.data
spring-data-relational-parent
- 3.2.0-SNAPSHOT
+ 3.2.0-proxy-SNAPSHOT
diff --git a/spring-data-r2dbc/pom.xml b/spring-data-r2dbc/pom.xml
index 98019e0295..c4ac31dc26 100644
--- a/spring-data-r2dbc/pom.xml
+++ b/spring-data-r2dbc/pom.xml
@@ -6,7 +6,7 @@
4.0.0
spring-data-r2dbc
- 3.2.0-SNAPSHOT
+ 3.2.0-proxy-SNAPSHOT
Spring Data R2DBC
Spring Data module for R2DBC
@@ -15,7 +15,7 @@
org.springframework.data
spring-data-relational-parent
- 3.2.0-SNAPSHOT
+ 3.2.0-proxy-SNAPSHOT
diff --git a/spring-data-relational/pom.xml b/spring-data-relational/pom.xml
index 8002bdcf9b..bb0df0030e 100644
--- a/spring-data-relational/pom.xml
+++ b/spring-data-relational/pom.xml
@@ -6,7 +6,7 @@
4.0.0
spring-data-relational
- 3.2.0-SNAPSHOT
+ 3.2.0-proxy-SNAPSHOT
Spring Data Relational
Spring Data Relational support
@@ -14,7 +14,7 @@
org.springframework.data
spring-data-relational-parent
- 3.2.0-SNAPSHOT
+ 3.2.0-proxy-SNAPSHOT
@@ -90,6 +90,13 @@
test
+
+ org.testcontainers
+ testcontainers
+ ${testcontainers}
+ test
+
+
diff --git a/spring-data-relational/src/test/java/org/springframework/data/ProxyImageNameSubstitutor.java b/spring-data-relational/src/test/java/org/springframework/data/ProxyImageNameSubstitutor.java
new file mode 100644
index 0000000000..9cf92153b1
--- /dev/null
+++ b/spring-data-relational/src/test/java/org/springframework/data/ProxyImageNameSubstitutor.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2023 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.utility.DockerImageName;
+import org.testcontainers.utility.ImageNameSubstitutor;
+
+/**
+ * An {@link ImageNameSubstitutor} only used on CI servers to leverage internal proxy solution, that needs to vary the
+ * prefix based on which container image is needed.
+ *
+ * @author Greg Turnquist
+ */
+public class ProxyImageNameSubstitutor extends ImageNameSubstitutor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ProxyImageNameSubstitutor.class);
+
+ private static final List NAMES_TO_PROXY_PREFIX = List.of("ryuk", "arm64v8/mariadb", "ibmcom/db2",
+ "gvenzl/oracle-xe");
+
+ private static final List NAMES_TO_LIBRARY_PROXY_PREFIX = List.of("mariadb", "mysql", "postgres");
+
+ private static final String PROXY_PREFIX = "harbor-repo.vmware.com/dockerhub-proxy-cache/";
+
+ private static final String LIBRARY_PROXY_PREFIX = PROXY_PREFIX + "library/";
+
+ @Override
+ public DockerImageName apply(DockerImageName dockerImageName) {
+
+ if (NAMES_TO_PROXY_PREFIX.stream().anyMatch(s -> dockerImageName.asCanonicalNameString().contains(s))) {
+
+ String transformedName = applyProxyPrefix(dockerImageName.asCanonicalNameString());
+ LOG.info("Converting " + dockerImageName.asCanonicalNameString() + " to " + transformedName);
+ return DockerImageName.parse(transformedName);
+ }
+
+ if (NAMES_TO_LIBRARY_PROXY_PREFIX.stream().anyMatch(s -> dockerImageName.asCanonicalNameString().contains(s))) {
+
+ String transformedName = applyProxyAndLibraryPrefix(dockerImageName.asCanonicalNameString());
+ LOG.info("Converting " + dockerImageName.asCanonicalNameString() + " to " + transformedName);
+ return DockerImageName.parse(transformedName);
+ }
+
+ LOG.info("Not changing " + dockerImageName.asCanonicalNameString() + "...");
+ return dockerImageName;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Spring Data Proxy Image Name Substitutor";
+ }
+
+ /**
+ * Apply a non-library-based prefix.
+ */
+ private static String applyProxyPrefix(String imageName) {
+ return PROXY_PREFIX + imageName;
+ }
+
+ /**
+ * Apply a library based prefix.
+ */
+ private static String applyProxyAndLibraryPrefix(String imageName) {
+ return LIBRARY_PROXY_PREFIX + imageName;
+ }
+}