diff --git a/Jenkinsfile b/Jenkinsfile
index e345657e1b..c3b3e9846b 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -32,6 +32,7 @@ pipeline {
options { timeout(time: 30, unit: 'MINUTES') }
environment {
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
+ TESTCONTAINERS_IMAGE_SUBSTITUTOR = 'org.springframework.data.jpa.support.ProxyImageNameSubstitutor'
}
steps {
script {
@@ -47,7 +48,7 @@ pipeline {
when {
beforeAgent(true)
allOf {
- branch(pattern: "main|(\\d\\.\\d\\.x)", comparator: "REGEXP")
+ branch(pattern: "issue/testcontainers|main|(\\d\\.\\d\\.x)", comparator: "REGEXP") // TODO: Drop it
not { triggeredBy 'UpstreamCause' }
}
}
@@ -60,6 +61,7 @@ pipeline {
options { timeout(time: 30, unit: 'MINUTES')}
environment {
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
+ TESTCONTAINERS_IMAGE_SUBSTITUTOR = 'org.springframework.data.jpa.support.ProxyImageNameSubstitutor'
}
steps {
script {
@@ -77,6 +79,7 @@ pipeline {
options { timeout(time: 30, unit: 'MINUTES')}
environment {
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
+ TESTCONTAINERS_IMAGE_SUBSTITUTOR = 'org.springframework.data.jpa.support.ProxyImageNameSubstitutor'
}
steps {
script {
@@ -94,6 +97,7 @@ pipeline {
options { timeout(time: 30, unit: 'MINUTES')}
environment {
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
+ TESTCONTAINERS_IMAGE_SUBSTITUTOR = 'org.springframework.data.jpa.support.ProxyImageNameSubstitutor'
}
steps {
script {
diff --git a/pom.xml b/pom.xml
index aa83fb5183..affd6b2175 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-jpa-parent
- 3.0.6-SNAPSHOT
+ 3.0.6-testcontainers-SNAPSHOT
pom
Spring Data JPA Parent
diff --git a/spring-data-envers/pom.xml b/spring-data-envers/pom.xml
index 3f1c0d1695..d0dbf4a747 100755
--- a/spring-data-envers/pom.xml
+++ b/spring-data-envers/pom.xml
@@ -5,12 +5,12 @@
org.springframework.data
spring-data-envers
- 3.0.6-SNAPSHOT
+ 3.0.6-testcontainers-SNAPSHOT
org.springframework.data
spring-data-jpa-parent
- 3.0.6-SNAPSHOT
+ 3.0.6-testcontainers-SNAPSHOT
../pom.xml
diff --git a/spring-data-jpa-distribution/pom.xml b/spring-data-jpa-distribution/pom.xml
index 2980f22111..dafc712ca0 100644
--- a/spring-data-jpa-distribution/pom.xml
+++ b/spring-data-jpa-distribution/pom.xml
@@ -14,7 +14,7 @@
org.springframework.data
spring-data-jpa-parent
- 3.0.6-SNAPSHOT
+ 3.0.6-testcontainers-SNAPSHOT
../pom.xml
diff --git a/spring-data-jpa/pom.xml b/spring-data-jpa/pom.xml
index 9cb7631993..5d280254a0 100644
--- a/spring-data-jpa/pom.xml
+++ b/spring-data-jpa/pom.xml
@@ -6,7 +6,7 @@
org.springframework.data
spring-data-jpa
- 3.0.6-SNAPSHOT
+ 3.0.6-testcontainers-SNAPSHOT
Spring Data JPA
Spring Data module for JPA repositories.
@@ -15,7 +15,7 @@
org.springframework.data
spring-data-jpa-parent
- 3.0.6-SNAPSHOT
+ 3.0.6-testcontainers-SNAPSHOT
../pom.xml
diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/support/ProxyImageNameSubstitutor.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/support/ProxyImageNameSubstitutor.java
new file mode 100644
index 0000000000..7b59fb5242
--- /dev/null
+++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/support/ProxyImageNameSubstitutor.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2015-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.jpa.support;
+
+import java.util.List;
+
+import org.testcontainers.utility.DockerImageName;
+import org.testcontainers.utility.ImageNameSubstitutor;
+
+/**
+ * A {@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 List NAMES_TO_PROXY_PREFIX = List.of("ryuk");
+
+ private static final List NAMES_TO_LIBRARY_PREFIX = List.of("mysql", "postgres");
+ private static final String PROXY_PREFIX = "harbor-repo.vmware.com/dockerhub-proxy-cache/";
+
+ @Override
+ public DockerImageName apply(DockerImageName dockerImageName) {
+
+ if (NAMES_TO_PROXY_PREFIX.stream().anyMatch(s -> dockerImageName.asCanonicalNameString().contains(s))) {
+ return DockerImageName.parse(applyProxyPrefix(dockerImageName.asCanonicalNameString()));
+ }
+
+ if (NAMES_TO_LIBRARY_PREFIX.stream().anyMatch(s -> dockerImageName.asCanonicalNameString().contains(s))) {
+ return DockerImageName.parse(applyProxyAndLibraryPrefix(dockerImageName.asCanonicalNameString()));
+ }
+
+ return dockerImageName;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Spring Data Proxy Image Name Substitutor";
+ }
+
+ /**
+ * Apply a library-based prefix.
+ */
+ private static String applyProxyPrefix(String imageName) {
+ return PROXY_PREFIX + imageName;
+ }
+
+ /**
+ * Apply a non-library based prefix.
+ */
+ private static String applyProxyAndLibraryPrefix(String imageName) {
+ return PROXY_PREFIX + "library/" + imageName;
+ }
+}