From 11a59bd04c8806fd906cfd7484ffa1ac2e08e499 Mon Sep 17 00:00:00 2001 From: Brian de Alwis Date: Wed, 3 Jul 2019 13:36:34 -0400 Subject: [PATCH 1/5] Fix check-version integration tests --- .../maven/BuildDockerMojoIntegrationTest.java | 19 ++++++++++-------- .../maven/BuildImageMojoIntegrationTest.java | 20 ++++++++++--------- .../maven/BuildTarMojoIntegrationTest.java | 20 +++++++++++-------- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildDockerMojoIntegrationTest.java b/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildDockerMojoIntegrationTest.java index 5d440069c1..782f9ac3dc 100644 --- a/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildDockerMojoIntegrationTest.java +++ b/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildDockerMojoIntegrationTest.java @@ -239,15 +239,18 @@ public void testExecute_jibRequireVersion_ok() throws VerificationException, IOE } @Test - public void testExecute_jibRequireVersion_fail() throws VerificationException, IOException { + public void testExecute_jibRequireVersion_fail() throws IOException { String targetImage = "simpleimage:maven" + System.nanoTime(); - Instant before = Instant.now(); - Verifier verifier = new Verifier(simpleTestProject.getProjectRoot().toString()); - verifier.setSystemProperty("jib.requiredVersion", "[,1.0]"); - verifier.setSystemProperty("_TARGET_IMAGE", targetImage); - verifier.executeGoals(Arrays.asList("package", "jib:dockerBuild")); - verifier.verifyTextInLog("BUILD FAILURE"); - verifier.verifyTextInLog("but is required to be"); + try { + Verifier verifier = new Verifier(simpleTestProject.getProjectRoot().toString()); + verifier.setSystemProperty("jib.requiredVersion", "[,1.0]"); + verifier.setSystemProperty("_TARGET_IMAGE", targetImage); + verifier.executeGoals(Arrays.asList("package", "jib:dockerBuild")); + Assert.fail(); + } catch (VerificationException ex) { + Assert.assertThat( + ex.getMessage(), CoreMatchers.containsString("but is required to be [,1.0]")); + } } } diff --git a/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildImageMojoIntegrationTest.java b/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildImageMojoIntegrationTest.java index 77bcdb9dff..23028671b9 100644 --- a/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildImageMojoIntegrationTest.java +++ b/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildImageMojoIntegrationTest.java @@ -558,16 +558,18 @@ public void testExecute_jibRequireVersion_ok() throws VerificationException, IOE } @Test - public void testExecute_jibRequireVersion_fail() throws VerificationException, IOException { + public void testExecute_jibRequireVersion_fail() throws IOException { String targetImage = "simpleimage:maven" + System.nanoTime(); - - Instant before = Instant.now(); - Verifier verifier = new Verifier(simpleTestProject.getProjectRoot().toString()); - verifier.setSystemProperty("jib.requiredVersion", "[,1.0]"); - verifier.setSystemProperty("_TARGET_IMAGE", targetImage); - verifier.executeGoals(Arrays.asList("package", "jib:build")); - verifier.verifyTextInLog("BUILD FAILURE"); - verifier.verifyTextInLog("but is required to be"); + try { + Verifier verifier = new Verifier(simpleTestProject.getProjectRoot().toString()); + verifier.setSystemProperty("jib.requiredVersion", "[,1.0]"); + verifier.setSystemProperty("_TARGET_IMAGE", targetImage); + verifier.executeGoals(Arrays.asList("package", "jib:build")); + Assert.fail(); + } catch (VerificationException ex) { + Assert.assertThat( + ex.getMessage(), CoreMatchers.containsString("but is required to be [,1.0]")); + } } @Test diff --git a/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildTarMojoIntegrationTest.java b/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildTarMojoIntegrationTest.java index b43b8df461..12e5616a5e 100644 --- a/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildTarMojoIntegrationTest.java +++ b/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildTarMojoIntegrationTest.java @@ -23,6 +23,7 @@ import java.util.Arrays; import org.apache.maven.it.VerificationException; import org.apache.maven.it.Verifier; +import org.hamcrest.CoreMatchers; import org.junit.Assert; import org.junit.ClassRule; import org.junit.Test; @@ -104,15 +105,18 @@ public void testExecute_jibRequireVersion_ok() throws VerificationException, IOE } @Test - public void testExecute_jibRequireVersion_fail() throws VerificationException, IOException { + public void testExecute_jibRequireVersion_fail() throws IOException { String targetImage = "simpleimage:maven" + System.nanoTime(); - Instant before = Instant.now(); - Verifier verifier = new Verifier(simpleTestProject.getProjectRoot().toString()); - verifier.setSystemProperty("jib.requiredVersion", "[,1.0]"); - verifier.setSystemProperty("_TARGET_IMAGE", targetImage); - verifier.executeGoals(Arrays.asList("package", "jib:buildTar")); - verifier.verifyTextInLog("BUILD FAILURE"); - verifier.verifyTextInLog("but is required to be"); + try { + Verifier verifier = new Verifier(simpleTestProject.getProjectRoot().toString()); + verifier.setSystemProperty("jib.requiredVersion", "[,1.0]"); + verifier.setSystemProperty("_TARGET_IMAGE", targetImage); + verifier.executeGoals(Arrays.asList("package", "jib:buildTar")); + Assert.fail(); + } catch (VerificationException ex) { + Assert.assertThat( + ex.getMessage(), CoreMatchers.containsString("but is required to be [,1.0]")); + } } } From 52a5b0c58055e8f72e86667238ae29662713d15c Mon Sep 17 00:00:00 2001 From: Brian de Alwis Date: Wed, 3 Jul 2019 15:21:09 -0400 Subject: [PATCH 2/5] Allow using local registry for integration test --- .../jib/IntegrationTestingConfiguration.java | 14 +++++-- .../gradle/EmptyProjectIntegrationTest.java | 6 +-- .../cloud/tools/jib/gradle/JibRunHelper.java | 11 +++++ .../gradle/SingleProjectIntegrationTest.java | 6 +-- .../jib/gradle/WarProjectIntegrationTest.java | 2 +- .../maven/BuildImageMojoIntegrationTest.java | 41 +++++++++++++------ 6 files changed, 54 insertions(+), 26 deletions(-) diff --git a/jib-core/src/integration-test/java/com/google/cloud/tools/jib/IntegrationTestingConfiguration.java b/jib-core/src/integration-test/java/com/google/cloud/tools/jib/IntegrationTestingConfiguration.java index f39ef24abc..7c3e0ef844 100644 --- a/jib-core/src/integration-test/java/com/google/cloud/tools/jib/IntegrationTestingConfiguration.java +++ b/jib-core/src/integration-test/java/com/google/cloud/tools/jib/IntegrationTestingConfiguration.java @@ -22,13 +22,19 @@ /** Configuration for integration tests. */ public class IntegrationTestingConfiguration { - public static String getGCPProject() { + public static String getTestRepositoryLocation() { String projectId = System.getenv("JIB_INTEGRATION_TESTING_PROJECT"); - if (Strings.isNullOrEmpty(projectId)) { + if (!Strings.isNullOrEmpty(projectId)) { + return "gcr.io/" + projectId; + } + String location = System.getenv("JIB_INTEGRATION_TESTING_LOCATION"); + if (Strings.isNullOrEmpty(location)) { Assert.fail( - "Must set environment variable JIB_INTEGRATION_TESTING_PROJECT to the GCP project to use for integration testing."); + "Must set environment variable JIB_INTEGRATION_TESTING_PROJECT to the " + + "GCP project to use for integration testing or " + + "JIB_INTEGRATION_TESTING_LOCATION to a suitable registry/repository location."); } - return projectId; + return location; } private IntegrationTestingConfiguration() {} diff --git a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/EmptyProjectIntegrationTest.java b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/EmptyProjectIntegrationTest.java index f382198c46..db839e9e0e 100644 --- a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/EmptyProjectIntegrationTest.java +++ b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/EmptyProjectIntegrationTest.java @@ -62,8 +62,7 @@ private static void assertDockerInspect(String imageReference) @Test public void testBuild_empty() throws IOException, InterruptedException, DigestException { String targetImage = - "gcr.io/" - + IntegrationTestingConfiguration.getGCPProject() + IntegrationTestingConfiguration.getTestRepositoryLocation() + "/emptyimage:gradle" + System.nanoTime(); Assert.assertEquals("", JibRunHelper.buildAndRun(emptyTestProject, targetImage)); @@ -75,8 +74,7 @@ public void testBuild_empty() throws IOException, InterruptedException, DigestEx public void testBuild_multipleTags() throws IOException, InterruptedException, InvalidImageReferenceException, DigestException { String targetImage = - "gcr.io/" - + IntegrationTestingConfiguration.getGCPProject() + IntegrationTestingConfiguration.getTestRepositoryLocation() + "/multitag-image:gradle" + System.nanoTime(); JibRunHelper.buildAndRunAdditionalTag( diff --git a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java index 975483883a..2cb8979fcc 100644 --- a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java +++ b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java @@ -20,6 +20,7 @@ import com.google.cloud.tools.jib.api.DescriptorDigest; import com.google.cloud.tools.jib.api.ImageReference; import com.google.cloud.tools.jib.api.InvalidImageReferenceException; +import com.google.cloud.tools.jib.plugins.common.PropertyNames; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -55,6 +56,7 @@ static String buildAndRun( "-Djib.useOnlyProjectCache=true", "-Djib.console=plain", "-D_TARGET_IMAGE=" + imageReference, + configureInsecureRegistryProperty(imageReference), "-b=" + gradleBuildFile); assertBuildSuccess(buildResult, "jib", "Built and pushed image as "); assertImageDigestAndId(testProject.getProjectRoot()); @@ -73,6 +75,7 @@ static void buildAndRunAdditionalTag( "-Djib.useOnlyProjectCache=true", "-Djib.console=plain", "-D_TARGET_IMAGE=" + imageReference, + configureInsecureRegistryProperty(imageReference), "-D_ADDITIONAL_TAG=" + additionalTag); assertBuildSuccess(buildResult, "jib", "Built and pushed image as "); assertImageDigestAndId(testProject.getProjectRoot()); @@ -99,6 +102,7 @@ static BuildResult buildToDockerDaemon( "-Djib.useOnlyProjectCache=true", "-Djib.console=plain", "-D_TARGET_IMAGE=" + imageReference, + configureInsecureRegistryProperty(imageReference), "-b=" + gradleBuildFile); assertBuildSuccess(buildResult, "jibDockerBuild", "Built image to Docker daemon as "); assertImageDigestAndId(testProject.getProjectRoot()); @@ -117,6 +121,13 @@ static String buildToDockerDaemonAndRun( return new Command("docker", "run", "--rm", imageReference).run(); } + private static String configureInsecureRegistryProperty(String imageReference) { + return "-D" + + PropertyNames.ALLOW_INSECURE_REGISTRIES + + "=" + + (imageReference.startsWith("localhost") ? "true" : "false"); + } + /** * Asserts that the test project build output indicates a success. * diff --git a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/SingleProjectIntegrationTest.java b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/SingleProjectIntegrationTest.java index 4598457ae0..29da90afb2 100644 --- a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/SingleProjectIntegrationTest.java +++ b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/SingleProjectIntegrationTest.java @@ -179,8 +179,7 @@ public void setup() throws IOException, InterruptedException { @Test public void testBuild_simple() throws IOException, InterruptedException, DigestException { String targetImage = - "gcr.io/" - + IntegrationTestingConfiguration.getGCPProject() + IntegrationTestingConfiguration.getTestRepositoryLocation() + "/simpleimage:gradle" + System.nanoTime(); @@ -218,8 +217,7 @@ public void testBuild_simple() throws IOException, InterruptedException, DigestE @Test public void testBuild_failOffline() { String targetImage = - "gcr.io/" - + IntegrationTestingConfiguration.getGCPProject() + IntegrationTestingConfiguration.getTestRepositoryLocation() + "/simpleimageoffline:gradle" + System.nanoTime(); diff --git a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/WarProjectIntegrationTest.java b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/WarProjectIntegrationTest.java index 5a093ee96c..1b161061ce 100644 --- a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/WarProjectIntegrationTest.java +++ b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/WarProjectIntegrationTest.java @@ -74,7 +74,7 @@ public void testBuild_tomcatServlet25() private void verifyBuildAndRun(TestProject project, String label, String gradleBuildFile) throws IOException, InterruptedException, DigestException { - String nameBase = "gcr.io/" + IntegrationTestingConfiguration.getGCPProject() + '/'; + String nameBase = IntegrationTestingConfiguration.getTestRepositoryLocation() + '/'; String targetImage = nameBase + label + System.nanoTime(); String output = JibRunHelper.buildAndRun(project, targetImage, gradleBuildFile, "--detach", "-p8080:8080"); diff --git a/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildImageMojoIntegrationTest.java b/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildImageMojoIntegrationTest.java index 23028671b9..cbf22d792c 100644 --- a/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildImageMojoIntegrationTest.java +++ b/jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/BuildImageMojoIntegrationTest.java @@ -21,6 +21,7 @@ import com.google.cloud.tools.jib.api.DescriptorDigest; import com.google.cloud.tools.jib.api.ImageReference; import com.google.cloud.tools.jib.api.InvalidImageReferenceException; +import com.google.cloud.tools.jib.plugins.common.PropertyNames; import com.google.cloud.tools.jib.registry.LocalRegistry; import com.google.common.base.Splitter; import java.io.IOException; @@ -74,8 +75,8 @@ public class BuildImageMojoIntegrationTest { @ClassRule public static final TestProject servlet25Project = new TestProject(testPlugin, "war_servlet25"); - private static String getGcrImageReference(String label) { - String nameBase = "gcr.io/" + IntegrationTestingConfiguration.getGCPProject() + '/'; + private static String getTestImageReference(String label) { + String nameBase = IntegrationTestingConfiguration.getTestRepositoryLocation() + '/'; return nameBase + label + System.nanoTime(); } @@ -104,6 +105,9 @@ private static Verifier build( Verifier verifier = new Verifier(projectRoot.toString()); verifier.setSystemProperty("jib.useOnlyProjectCache", "true"); verifier.setSystemProperty("_TARGET_IMAGE", imageReference); + if (imageReference.startsWith("localhost")) { + verifier.setSystemProperty(PropertyNames.ALLOW_INSECURE_REGISTRIES, "true"); + } verifier.setAutoclean(false); verifier.addCliOption("-X"); verifier.addCliOption("--file=" + pomXml); @@ -163,6 +167,9 @@ private static String buildAndRunAdditionalTag( verifier.setSystemProperty("jib.useOnlyProjectCache", "true"); verifier.setSystemProperty("_TARGET_IMAGE", imageReference); verifier.setSystemProperty("_ADDITIONAL_TAG", additionalTag); + if (imageReference.startsWith("localhost")) { + verifier.setSystemProperty(PropertyNames.ALLOW_INSECURE_REGISTRIES, "true"); + } verifier.setAutoclean(false); verifier.addCliOption("-X"); verifier.executeGoals(Arrays.asList("clean", "compile", "jib:build")); @@ -324,7 +331,7 @@ public void tearDown() throws IOException, InterruptedException { @Test public void testExecute_simple() throws VerificationException, IOException, InterruptedException, DigestException { - String targetImage = getGcrImageReference("simpleimage:maven"); + String targetImage = getTestImageReference("simpleimage:maven"); // Test empty output error try { @@ -372,7 +379,7 @@ public void testExecute_simple() @Test public void testExecute_failOffline() throws IOException { - String targetImage = getGcrImageReference("simpleimageoffline:maven"); + String targetImage = getTestImageReference("simpleimageoffline:maven"); // Test empty output error try { @@ -395,7 +402,7 @@ public void testExecute_simpleOnJava11() throws DigestException, VerificationException, IOException, InterruptedException { Assume.assumeTrue(isJava11RuntimeOrHigher()); - String targetImage = getGcrImageReference("simpleimage:maven"); + String targetImage = getTestImageReference("simpleimage:maven"); Assert.assertEquals( "Hello, world. An argument.\n", buildAndRun(simpleTestProject.getProjectRoot(), targetImage, "pom-java11.xml", false)); @@ -424,7 +431,7 @@ public void testExecute_simpleWithIncomptiableJava11() @Test public void testExecute_empty() throws InterruptedException, IOException, VerificationException, DigestException { - String targetImage = getGcrImageReference("emptyimage:maven"); + String targetImage = getTestImageReference("emptyimage:maven"); Assert.assertEquals( "", buildAndRun(emptyTestProject.getProjectRoot(), targetImage, "pom.xml", false)); assertCreationTimeEpoch(targetImage); @@ -435,7 +442,7 @@ public void testExecute_empty() public void testExecute_multipleTags() throws IOException, InterruptedException, InvalidImageReferenceException, VerificationException, DigestException { - String targetImage = getGcrImageReference("multitag-image:maven"); + String targetImage = getTestImageReference("multitag-image:maven"); Assert.assertEquals( "", buildAndRunAdditionalTag( @@ -445,7 +452,7 @@ public void testExecute_multipleTags() @Test public void testExecute_multipleExtraDirectories() throws DigestException, VerificationException, IOException, InterruptedException { - String targetImage = getGcrImageReference("simpleimage:maven"); + String targetImage = getTestImageReference("simpleimage:maven"); Assert.assertEquals( "Hello, world. An argument.\nrw-r--r--\nrw-r--r--\nfoo\ncat\nbaz\n", buildAndRun(simpleTestProject.getProjectRoot(), targetImage, "pom-extra-dirs.xml", false)); @@ -469,7 +476,7 @@ public void testExecute_bothDeprecatedAndNewExtraDirectoryConfigUsed() throws IO @Test public void testExecute_deprecatedExtraDirectoryConfigUsed() throws IOException, VerificationException { - String targetImage = getGcrImageReference("simpleimage:maven"); + String targetImage = getTestImageReference("simpleimage:maven"); build(simpleTestProject.getProjectRoot(), targetImage, "pom-deprecated-extra-dir.xml", false) .verifyTextInLog( " is deprecated; use with "); @@ -546,24 +553,29 @@ public void testExecute_jibContainerizeSkips() throws VerificationException, IOE @Test public void testExecute_jibRequireVersion_ok() throws VerificationException, IOException { - String targetImage = "simpleimage:maven" + System.nanoTime(); + String targetImage = getTestImageReference("simpleimage:maven"); - Instant before = Instant.now(); Verifier verifier = new Verifier(simpleTestProject.getProjectRoot().toString()); // this plugin should match 1.0 verifier.setSystemProperty("jib.requiredVersion", "1.0"); verifier.setSystemProperty("_TARGET_IMAGE", targetImage); + if (targetImage.startsWith("localhost")) { + verifier.setSystemProperty(PropertyNames.ALLOW_INSECURE_REGISTRIES, "true"); + } verifier.executeGoals(Arrays.asList("package", "jib:build")); verifier.verifyErrorFreeLog(); } @Test public void testExecute_jibRequireVersion_fail() throws IOException { - String targetImage = "simpleimage:maven" + System.nanoTime(); + String targetImage = getTestImageReference("simpleimage:maven"); try { Verifier verifier = new Verifier(simpleTestProject.getProjectRoot().toString()); verifier.setSystemProperty("jib.requiredVersion", "[,1.0]"); verifier.setSystemProperty("_TARGET_IMAGE", targetImage); + if (targetImage.startsWith("localhost")) { + verifier.setSystemProperty(PropertyNames.ALLOW_INSECURE_REGISTRIES, "true"); + } verifier.executeGoals(Arrays.asList("package", "jib:build")); Assert.fail(); } catch (VerificationException ex) { @@ -588,11 +600,14 @@ public void testExecute_tomcatServlet25() private void buildAndRunWar(String label, String pomXml) throws VerificationException, IOException, InterruptedException { - String targetImage = getGcrImageReference(label); + String targetImage = getTestImageReference(label); Verifier verifier = new Verifier(servlet25Project.getProjectRoot().toString()); verifier.setSystemProperty("jib.useOnlyProjectCache", "true"); verifier.setSystemProperty("_TARGET_IMAGE", targetImage); + if (targetImage.startsWith("localhost")) { + verifier.setSystemProperty(PropertyNames.ALLOW_INSECURE_REGISTRIES, "true"); + } verifier.setAutoclean(false); verifier.addCliOption("-X"); verifier.addCliOption("--file=" + pomXml); From 9febcdf2952bab5e30ab910539fce8cd00df28e3 Mon Sep 17 00:00:00 2001 From: Brian de Alwis Date: Tue, 23 Jul 2019 15:57:16 -0400 Subject: [PATCH 3/5] tweak --- .../java/com/google/cloud/tools/jib/gradle/JibRunHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java index 2cb8979fcc..fd3a67acb6 100644 --- a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java +++ b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java @@ -125,7 +125,7 @@ private static String configureInsecureRegistryProperty(String imageReference) { return "-D" + PropertyNames.ALLOW_INSECURE_REGISTRIES + "=" - + (imageReference.startsWith("localhost") ? "true" : "false"); + + Boolean.toString(imageReference.startsWith("localhost")); } /** From 9ebe237869119bf48a637bddd0262cee291ce43a Mon Sep 17 00:00:00 2001 From: Brian de Alwis Date: Tue, 23 Jul 2019 16:54:31 -0400 Subject: [PATCH 4/5] Review nits --- CONTRIBUTING.md | 2 +- .../com/google/cloud/tools/jib/gradle/JibRunHelper.java | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0f9667ec4d..c2caef8984 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,7 +57,7 @@ following environment variables: `docker run -d -p 9990:5000 registry:2` and use `localhost:9990`. You will also need Docker installed with the daemon running. Note that the -integration tests will create local registries on ports 5000 and 9000. +integration tests will create local registries on ports 5000 and 6000. # Development Tips diff --git a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java index fd3a67acb6..75c243da13 100644 --- a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java +++ b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java @@ -20,7 +20,6 @@ import com.google.cloud.tools.jib.api.DescriptorDigest; import com.google.cloud.tools.jib.api.ImageReference; import com.google.cloud.tools.jib.api.InvalidImageReferenceException; -import com.google.cloud.tools.jib.plugins.common.PropertyNames; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -122,10 +121,7 @@ static String buildToDockerDaemonAndRun( } private static String configureInsecureRegistryProperty(String imageReference) { - return "-D" - + PropertyNames.ALLOW_INSECURE_REGISTRIES - + "=" - + Boolean.toString(imageReference.startsWith("localhost")); + return "-Djib.allowInsecureRegistries=" + imageReference.startsWith("localhost"); } /** From 435b3dc6d1d28ed5f72df5b974bce573e4d969df Mon Sep 17 00:00:00 2001 From: Brian de Alwis Date: Thu, 25 Jul 2019 14:45:53 -0400 Subject: [PATCH 5/5] inline configureInsecureRegistryProperty --- .../google/cloud/tools/jib/gradle/JibRunHelper.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java index 75c243da13..17e909a05f 100644 --- a/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java +++ b/jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java @@ -55,7 +55,7 @@ static String buildAndRun( "-Djib.useOnlyProjectCache=true", "-Djib.console=plain", "-D_TARGET_IMAGE=" + imageReference, - configureInsecureRegistryProperty(imageReference), + "-Djib.allowInsecureRegistries=" + imageReference.startsWith("localhost"), "-b=" + gradleBuildFile); assertBuildSuccess(buildResult, "jib", "Built and pushed image as "); assertImageDigestAndId(testProject.getProjectRoot()); @@ -74,7 +74,7 @@ static void buildAndRunAdditionalTag( "-Djib.useOnlyProjectCache=true", "-Djib.console=plain", "-D_TARGET_IMAGE=" + imageReference, - configureInsecureRegistryProperty(imageReference), + "-Djib.allowInsecureRegistries=" + imageReference.startsWith("localhost"), "-D_ADDITIONAL_TAG=" + additionalTag); assertBuildSuccess(buildResult, "jib", "Built and pushed image as "); assertImageDigestAndId(testProject.getProjectRoot()); @@ -101,7 +101,7 @@ static BuildResult buildToDockerDaemon( "-Djib.useOnlyProjectCache=true", "-Djib.console=plain", "-D_TARGET_IMAGE=" + imageReference, - configureInsecureRegistryProperty(imageReference), + "-Djib.allowInsecureRegistries=" + imageReference.startsWith("localhost"), "-b=" + gradleBuildFile); assertBuildSuccess(buildResult, "jibDockerBuild", "Built image to Docker daemon as "); assertImageDigestAndId(testProject.getProjectRoot()); @@ -120,10 +120,6 @@ static String buildToDockerDaemonAndRun( return new Command("docker", "run", "--rm", imageReference).run(); } - private static String configureInsecureRegistryProperty(String imageReference) { - return "-Djib.allowInsecureRegistries=" + imageReference.startsWith("localhost"); - } - /** * Asserts that the test project build output indicates a success. *