before_code
stringlengths
30
149k
reviewer_comment
stringlengths
16
20.6k
after_code
stringlengths
30
163k
diff_context
stringlengths
0
22.4k
file_path
stringlengths
6
155
comment_line
int64
0
26
language
stringclasses
19 values
quality_score
float64
0.07
1
comment_type
stringclasses
9 values
comment_length
int64
16
20.6k
before_lines
int64
2
4.61k
after_lines
int64
2
4.4k
is_negative
bool
2 classes
pr_title
stringlengths
7
140
pr_number
int64
18
61.2k
repo_name
stringclasses
29 values
repo_stars
int64
321
56k
repo_language
stringclasses
14 values
reviewer_username
stringclasses
378 values
author_username
stringclasses
739 values
user
stringlengths
361
200k
assistant
stringlengths
16
20.6k
system
stringclasses
1 value
Assert.assertEquals(2, manifestTemplate.getSchemaVersion()); V22ManifestTemplate v22ManifestTemplate = (V22ManifestTemplate) manifestTemplate; Assert.assertTrue(v22ManifestTemplate.getLayers().size() > 0); } @Test public void testPull_v22ManifestList() throws IOException, RegistryException { Reg...
Can we keep the previous name? Or `manifestListSha256`
Assert.assertEquals(2, manifestTemplate.getSchemaVersion()); V22ManifestTemplate v22ManifestTemplate = (V22ManifestTemplate) manifestTemplate; Assert.assertTrue(v22ManifestTemplate.getLayers().size() > 0); } @Test public void testPull_v22ManifestList() throws IOException, RegistryException { Reg...
@@ -74,38 +75,32 @@ public void testPull_v22() throws IOException, RegistryException { @Test public void testPull_v22ManifestList() throws IOException, RegistryException { RegistryClient registryClient = - RegistryClient.factory( - EventHandlers.NONE, "registry-1.docker.io", "library/op...
jib-core/src/integration-test/java/com/google/cloud/tools/jib/registry/ManifestPullerIntegrationTest.java
26
Java
0.357
question
54
51
51
false
Migrate away from Docker Hub in integration tests
2,910
GoogleContainerTools/jib
11,032
Java
mpeddada1
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/integration-test/java/com/google/cloud/tools/jib/registry/ManifestPullerIntegrationTest.java PR Title: Migrate away from Docker Hub in integration tests BEFORE CODE: Assert.assertEquals(2, manifestTemplate.getSchemaVersion()); V22ManifestTe...
Can we keep the previous name? Or `manifestListSha256`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@Test public void testPull_v22() throws IOException, RegistryException { RegistryClient registryClient = RegistryClient.factory(EventHandlers.NONE, "gcr.io", "distroless/java", httpClient) .newRegistryClient(); ManifestTemplate manifestTemplate = registryClient.pullManifest("latest").get...
Perhaps a more descriptive name- for example, `manifestListLatest`.
@Test public void testPull_v22() throws IOException, RegistryException { RegistryClient registryClient = RegistryClient.factory(EventHandlers.NONE, "gcr.io", "distroless/java", httpClient) .newRegistryClient(); ManifestTemplate manifestTemplate = registryClient.pullManifest("latest").get...
@@ -74,38 +75,32 @@ public void testPull_v22() throws IOException, RegistryException { @Test public void testPull_v22ManifestList() throws IOException, RegistryException { RegistryClient registryClient = - RegistryClient.factory( - EventHandlers.NONE, "registry-1.docker.io", "library/op...
jib-core/src/integration-test/java/com/google/cloud/tools/jib/registry/ManifestPullerIntegrationTest.java
26
Java
0.357
suggestion
67
51
51
false
Migrate away from Docker Hub in integration tests
2,910
GoogleContainerTools/jib
11,032
Java
mpeddada1
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/integration-test/java/com/google/cloud/tools/jib/registry/ManifestPullerIntegrationTest.java PR Title: Migrate away from Docker Hub in integration tests BEFORE CODE: @Test public void testPull_v22() throws IOException, RegistryException { Re...
Perhaps a more descriptive name- for example, `manifestListLatest`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
MatcherAssert.assertThat(dockerConfigEnv, CoreMatchers.containsString("env1=envvalue1")); MatcherAssert.assertThat(dockerConfigEnv, CoreMatchers.containsString("env2=envvalue2")); String history = new Command("docker", "history", imageReference).run(); MatcherAssert.assertThat(history, CoreMatchers.cont...
Do we want to enable caching for the other tests as well?
MatcherAssert.assertThat(dockerConfigEnv, CoreMatchers.containsString("env1=envvalue1")); MatcherAssert.assertThat(dockerConfigEnv, CoreMatchers.containsString("env2=envvalue2")); String history = new Command("docker", "history", imageReference).run(); MatcherAssert.assertThat(history, CoreMatchers.cont...
@@ -149,35 +149,43 @@ private static void assertLayerSize(int expected, String imageReference) @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); - private final ProgressChecker progressChecker = new ProgressChecker(); + private ProgressChecker progressChecker = new ProgressChecker(); ...
jib-core/src/integration-test/java/com/google/cloud/tools/jib/api/ContainerizerIntegrationTest.java
26
Java
0.214
question
57
51
51
false
Improve integration tests
2,912
GoogleContainerTools/jib
11,032
Java
mpeddada1
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/integration-test/java/com/google/cloud/tools/jib/api/ContainerizerIntegrationTest.java PR Title: Improve integration tests BEFORE CODE: MatcherAssert.assertThat(dockerConfigEnv, CoreMatchers.containsString("env1=envvalue1")); MatcherAssert.a...
Do we want to enable caching for the other tests as well?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Collections.emptyList()); String imageReference = "localhost:5000/testimage:testtag"; new Command("docker", "pull", imageReference).run(); Assert.assertEquals( "Hello, world. An argument.\n", new Command("docker", "run", "--rm", imageReference).run()); } @Test public void testBuildTo...
I know these methods were not introduced in this PR but since we are using a helper for the assert statements, could we make the name a bit more detailed? Something along the lines of `assertThatExpectedLayerSizeReturned` or `assertThatExpectedDockerInspectOutputReturned`.
throws InvalidImageReferenceException, IOException, InterruptedException, ExecutionException, RegistryException, CacheDirectoryCreationException { buildImage( ImageReference.parse("openjdk:8-jre-slim"), Containerizer.to(RegistryImage.named("localhost:5000/testimage:testtag")), ...
@@ -283,54 +288,38 @@ public void testBuildToDockerRegistry_dockerHubBaseImage() } @Test - public void testBuildToDockerDaemon() + public void testBuildToDockerDaemon_multipleTags() throws IOException, InterruptedException, ExecutionException, RegistryException, - CacheDirectoryCreationExcepti...
jib-core/src/integration-test/java/com/google/cloud/tools/jib/api/ContainerizerIntegrationTest.java
26
Java
0.643
refactor
273
51
51
false
Improve integration tests
2,912
GoogleContainerTools/jib
11,032
Java
mpeddada1
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/integration-test/java/com/google/cloud/tools/jib/api/ContainerizerIntegrationTest.java PR Title: Improve integration tests BEFORE CODE: Collections.emptyList()); String imageReference = "localhost:5000/testimage:testtag"; new Comman...
I know these methods were not introduced in this PR but since we are using a helper for the assert statements, could we make the name a bit more detailed? Something along the lines of `assertThatExpectedLayerSizeReturned` or `assertThatExpectedDockerInspectOutputReturned`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Assert.fail( "jib.skipExistingImages was enabled and digest was already pushed, " + "hence new_testtag shouldn't have been pushed."); } catch (RuntimeException ex) { MatcherAssert.assertThat( ex.getMessage(), CoreMatchers.containsString( "manifes...
Nice, I'm guessing this fixes the compatibility issue and also results in a smaller image:)
Collections.emptyList()); // Test that the pull request throws an exception, indicating that the new tag was not pushed. try { localRegistry.pull("localhost:5000/testimagerepo:new_testtag"); Assert.fail( "jib.skipExistingImages was enabled and digest was already pushed, " ...
@@ -271,9 +276,9 @@ public void testSteps_forBuildToDockerRegistry_skipExistingDigest() public void testBuildToDockerRegistry_dockerHubBaseImage() throws InvalidImageReferenceException, IOException, InterruptedException, ExecutionException, RegistryException, CacheDirectoryCreationException { - ...
jib-core/src/integration-test/java/com/google/cloud/tools/jib/api/ContainerizerIntegrationTest.java
26
Java
0.214
suggestion
91
51
51
false
Improve integration tests
2,912
GoogleContainerTools/jib
11,032
Java
mpeddada1
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/integration-test/java/com/google/cloud/tools/jib/api/ContainerizerIntegrationTest.java PR Title: Improve integration tests BEFORE CODE: Assert.fail( "jib.skipExistingImages was enabled and digest was already pushed, " +...
Nice, I'm guessing this fixes the compatibility issue and also results in a smaller image:)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} @Test public void testBuildTarball() throws IOException, InterruptedException, ExecutionException, RegistryException, CacheDirectoryCreationException { Path outputPath = temporaryFolder.newFolder().toPath().resolve("test.tar"); buildTarImage( ImageReference.of("gcr.io", "distrol...
so now we're just using the system default cache?
Collections.emptyList()); progressChecker.checkCompletion(); new Command("docker", "load", "--input", outputPath.toString()).run(); assertLayerSize(7, "testtar"); Assert.assertEquals( "Hello, world. An argument.\n", new Command("docker", "run", "--rm", "testtar").run()); } private...
@@ -383,10 +345,7 @@ private JibContainer buildImage( .setLabels(ImmutableMap.of("key1", "value1", "key2", "value2")) .setFileEntriesLayers(fakeLayerConfigurations); - Path cacheDirectory = temporaryFolder.newFolder().toPath(); containerizer
jib-core/src/integration-test/java/com/google/cloud/tools/jib/api/ContainerizerIntegrationTest.java
26
Java
0.071
performance
49
51
35
false
Improve integration tests
2,912
GoogleContainerTools/jib
11,032
Java
loosebazooka
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/integration-test/java/com/google/cloud/tools/jib/api/ContainerizerIntegrationTest.java PR Title: Improve integration tests BEFORE CODE: } @Test public void testBuildTarball() throws IOException, InterruptedException, ExecutionException,...
so now we're just using the system default cache?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Image.Builder imageBuilder = Image.builder(buildContext.getTargetFormat()); imageBuilder.setArchitecture(platform.getArchitecture()).setOs(platform.getOs()); images.add(imageBuilder.build()); } return new ImagesAndRegistryClient(images.build(), null); } eventHa...
minor formatting: need to move `line 136` up.
Image.Builder imageBuilder = Image.builder(buildContext.getTargetFormat()); imageBuilder.setArchitecture(platform.getArchitecture()).setOs(platform.getOs()); images.add(imageBuilder.build()); } return new ImagesAndRegistryClient(images.build(), null); } eventHa...
@@ -95,47 +95,48 @@ public ImagesAndRegistryClient call() LayerCountMismatchException, BadContainerConfigurationFormatException, CacheCorruptedException, CredentialRetrievalException { EventHandlers eventHandlers = buildContext.getEventHandlers(); - // Skip this step if this is a scratch i...
jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStep.java
26
Java
0.286
nitpick
46
51
51
false
Fix incomplete progress dispatching in PullBaseImageStep
2,914
GoogleContainerTools/jib
11,032
Java
mpeddada1
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStep.java PR Title: Fix incomplete progress dispatching in PullBaseImageStep BEFORE CODE: Image.Builder imageBuilder = Image.builder(buildContext.getTargetFormat()); ...
minor formatting: need to move `line 136` up.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
throws IOException, InterruptedException, URISyntaxException { Path jarPath = Paths.get(Resources.getResource("jarTest/standard/noDependencyJar.jar").toURI()); Integer exitCode = new CommandLine(new JibCli()) .execute( "jar", "--target", ...
How are these spring boot jars constructed? They don't seem like an actual jar built from a Spring Boot project. (Usually it runs a server listening on port 8080).
@Test public void testStandardJar_packagedMode_toDocker() throws IOException, InterruptedException, URISyntaxException { Path jarPath = Paths.get(Resources.getResource("jarTest/standard/jarWithCp.jar").toURI()); Integer exitCode = new CommandLine(new JibCli()) .execute( ...
@@ -142,6 +142,39 @@ public void testNoDependencyJar_packagedMode_toDocker() } } + @Test + public void testSpringbootLayeredJar_explodedMode_toDocker() + throws IOException, InterruptedException, URISyntaxException { + Path jarPath = + Paths.get(Resources.getResource("jarTest/springboot/sprin...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java
26
Java
0.357
question
163
51
51
false
Add integration tests for explode mode of spring boot jar
2,926
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java PR Title: Add integration tests for explode mode of spring boot jar BEFORE CODE: throws IOException, InterruptedException, URISyntaxException { Path jarPath = Pat...
How are these spring boot jars constructed? They don't seem like an actual jar built from a Spring Boot project. (Usually it runs a server listening on port 8080).
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assertThat(classPath).isNull(); assertThat(exitCode).isEqualTo(0); assertThat(output).isEqualTo("Hello World"); } } @Test public void testJar_unknownMode() { StringWriter stringWriter = new StringWriter(); CommandLine jibCli = new CommandLine(new JibCli()).setErr(new PrintWriter(str...
Hmm... I'm curious. Does it not work without `toAbsolutePath()`?
"jar", "--target", "docker://packaged-no-dep-jar", jarPath.toString(), "--mode=packaged"); String output = new Command("docker", "run", "--rm", "packaged-no-dep-jar").run(); try (JarFile jarFile = new JarFile(jarPath.toFile())) { ...
@@ -154,4 +167,71 @@ public void testJar_unknownMode() { .contains( "Invalid value for option '--mode': expected one of [exploded, packaged] (case-sensitive) but was 'unknown'"); } + + @Test + public void testSpringBootLayeredJar_explodedMode() throws IOException, InterruptedException { + ...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java
26
Java
0.357
question
64
51
51
false
Add integration tests for explode mode of spring boot jar
2,926
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java PR Title: Add integration tests for explode mode of spring boot jar BEFORE CODE: assertThat(classPath).isNull(); assertThat(exitCode).isEqualTo(0); assert...
Hmm... I'm curious. Does it not work without `toAbsolutePath()`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assertThat(exitCode).isEqualTo(2); assertThat(stringWriter.toString()) .contains( "Invalid value for option '--mode': expected one of [exploded, packaged] (case-sensitive) but was 'unknown'"); } @Test public void testSpringBootLayeredJar_explodedMode() throws IOException, InterruptedE...
This will not run if one of the assertions above fail or some code throws an exception. Put it in `finally`, or `@After public tearDown()` as done in other tests.
@Test public void testJar_unknownMode() { StringWriter stringWriter = new StringWriter(); CommandLine jibCli = new CommandLine(new JibCli()).setErr(new PrintWriter(stringWriter)); Integer exitCode = jibCli.execute( "jar", "--target", "docker://jib-cli-image", "ignored.jar", "--mode...
@@ -154,4 +167,71 @@ public void testJar_unknownMode() { .contains( "Invalid value for option '--mode': expected one of [exploded, packaged] (case-sensitive) but was 'unknown'"); } + + @Test + public void testSpringBootLayeredJar_explodedMode() throws IOException, InterruptedException { + ...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java
26
Java
0.643
bug
162
51
51
false
Add integration tests for explode mode of spring boot jar
2,926
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java PR Title: Add integration tests for explode mode of spring boot jar BEFORE CODE: assertThat(exitCode).isEqualTo(2); assertThat(stringWriter.toString()) .con...
This will not run if one of the assertions above fail or some code throws an exception. Put it in `finally`, or `@After public tearDown()` as done in other tests.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
"jar", "--target", "docker://jib-cli-image", "ignored.jar", "--mode=unknown"); assertThat(exitCode).isEqualTo(2); assertThat(stringWriter.toString()) .contains( "Invalid value for option '--mode': expected one of [exploded, packaged] (case-sensitive) but was 'unknown'"); } ...
Nit: I'd put this before `docker run` so that you don't run `docker run` if `jib jar` fails for some reason.
} } @Test public void testJar_unknownMode() { StringWriter stringWriter = new StringWriter(); CommandLine jibCli = new CommandLine(new JibCli()).setErr(new PrintWriter(stringWriter)); Integer exitCode = jibCli.execute( "jar", "--target", "docker://jib-cli-image", "ignored.jar...
@@ -154,4 +167,71 @@ public void testJar_unknownMode() { .contains( "Invalid value for option '--mode': expected one of [exploded, packaged] (case-sensitive) but was 'unknown'"); } + + @Test + public void testSpringBootLayeredJar_explodedMode() throws IOException, InterruptedException { + ...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java
26
Java
0.5
bug
108
51
51
false
Add integration tests for explode mode of spring boot jar
2,926
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java PR Title: Add integration tests for explode mode of spring boot jar BEFORE CODE: "jar", "--target", "docker://jib-cli-image", "ignored.jar", "--mode=unknown"); ...
Nit: I'd put this before `docker run` so that you don't run `docker run` if `jib jar` fails for some reason.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* * http://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 go...
I wish we had a way to share test utility classes across all projects. But let's not try to resolve this in this PR. @loosebazooka
* * http://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 go...
@@ -0,0 +1,92 @@ +/* + * Copyright 2020 Google LLC. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by ...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/TestProject.java
26
Java
0.357
refactor
133
51
51
false
Add integration tests for explode mode of spring boot jar
2,926
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/TestProject.java PR Title: Add integration tests for explode mode of spring boot jar BEFORE CODE: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law ...
I wish we had a way to share test utility classes across all projects. But let's not try to resolve this in this PR. @loosebazooka
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
if (mainClass == null) { throw new IllegalArgumentException( "`Main-Class:` attribute for an application main class not defined in the input JAR's " + "manifest (`META-INF/MANIFEST.MF` in the JAR)."); } return ImmutableList.of("java", "-jar", APP_ROOT + "/" + jarPat...
```suggestion static ImmutableList<String> computeEntrypointForPackagedSpringBoot(Path jarPath) { ```
if (mainClass == null) { throw new IllegalArgumentException( "`Main-Class:` attribute for an application main class not defined in the input JAR's " + "manifest (`META-INF/MANIFEST.MF` in the JAR)."); } return ImmutableList.of("java", "-jar", APP_ROOT + "/" + jarPat...
@@ -265,6 +282,16 @@ static JarType determineJarType(Path jarPath) throws IOException { "java", "-cp", APP_ROOT.toString(), "org.springframework.boot.loader.JarLauncher"); } + /** + * Computes the entrypoint for a spring boot jar in packaged mode. + * + * @param jarPath path to jar file + * @retu...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.714
suggestion
105
51
51
false
Implement packaged mode for spring boot jar
2,927
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Implement packaged mode for spring boot jar BEFORE CODE: if (mainClass == null) { throw new IllegalArgumentException( "`Main-Class:` attribute for...
```suggestion static ImmutableList<String> computeEntrypointForPackagedSpringBoot(Path jarPath) { ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
.containsExactly( AbsoluteUnixPath.get("/app/org/springframework/boot/loader/data/data1.class"), AbsoluteUnixPath.get("/app/org/springframework/boot/loader/launcher1.class")); assertThat(snapshotLayer.getName()).isEqualTo("snapshot dependencies"); assertThat(snapshotLayer.getEnt...
```suggestion public void testCreateLayersForPackagedSpringBoot() throws IOException, URISyntaxException { ``` And probably `IOException` is unnecessary?
.containsExactly( AbsoluteUnixPath.get("/app/org/springframework/boot/loader/data/data1.class"), AbsoluteUnixPath.get("/app/org/springframework/boot/loader/launcher1.class")); assertThat(snapshotLayer.getName()).isEqualTo("snapshot dependencies"); assertThat(snapshotLayer.getEnt...
@@ -578,4 +578,20 @@ public void testCreateLayersForExplodedNonLayeredSpringBoot() AbsoluteUnixPath.get("/app/BOOT-INF/classes/class1.class"), AbsoluteUnixPath.get("/app/BOOT-INF/classes/classDirectory/class2.class")); } + + @Test + public void testCreateLayersForPackagedSpringboot() thro...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessorTest.java
26
Java
0.857
question
160
41
41
false
Implement packaged mode for spring boot jar
2,927
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessorTest.java PR Title: Implement packaged mode for spring boot jar BEFORE CODE: .containsExactly( AbsoluteUnixPath.get("/app/org/springframework/boot/loader/data/data1.cla...
```suggestion public void testCreateLayersForPackagedSpringBoot() throws IOException, URISyntaxException { ``` And probably `IOException` is unnecessary?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assertThat(snapshotLayer.getName()).isEqualTo("snapshot dependencies"); assertThat(snapshotLayer.getEntries().get(0).getExtractionPath()) .isEqualTo(AbsoluteUnixPath.get("/app/BOOT-INF/lib/dependency3-SNAPSHOT.jar")); assertThat(resourcesLayer.getName()).isEqualTo("resources"); assertThat(reso...
```suggestion JarModeProcessor.createLayerForPackagedSpringBoot(springBootJar); ```
assertThat(snapshotLayer.getName()).isEqualTo("snapshot dependencies"); assertThat(snapshotLayer.getEntries().get(0).getExtractionPath()) .isEqualTo(AbsoluteUnixPath.get("/app/BOOT-INF/lib/dependency3-SNAPSHOT.jar")); assertThat(resourcesLayer.getName()).isEqualTo("resources"); assertThat(reso...
@@ -578,4 +578,20 @@ public void testCreateLayersForExplodedNonLayeredSpringBoot() AbsoluteUnixPath.get("/app/BOOT-INF/classes/class1.class"), AbsoluteUnixPath.get("/app/BOOT-INF/classes/classDirectory/class2.class")); } + + @Test + public void testCreateLayersForPackagedSpringboot() thro...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessorTest.java
26
Java
0.571
suggestion
93
38
38
false
Implement packaged mode for spring boot jar
2,927
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessorTest.java PR Title: Implement packaged mode for spring boot jar BEFORE CODE: assertThat(snapshotLayer.getName()).isEqualTo("snapshot dependencies"); assertThat(snapshotLayer.getEn...
```suggestion JarModeProcessor.createLayerForPackagedSpringBoot(springBootJar); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
XdgDirectories.getCacheHome() .resolve("cli") .resolve("projects") .resolve(CacheDirectories.hashPath(Paths.get("some-context")))); } @Test public void testCacheDirectories_configuredValuesIgnoresBuildContext() { CommonCliOptions commonCliOptions = ...
Sorry missed this last time, we could make the naming a little more specific for these two variables?
XdgDirectories.getCacheHome() .resolve("cli") .resolve("projects") .resolve( CacheDirectories.getProjectCacheDirectoryFromProject( Paths.get("some-context")))); } @Test public void testCacheDirectories_configu...
@@ -0,0 +1,84 @@ +/* + * Copyright 2020 Google LLC. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by ...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/cli2/CacheDirectoriesTest.java
26
Java
0.429
question
101
40
44
false
Add new Utility to determine cache location
2,929
GoogleContainerTools/jib
11,032
Java
mpeddada1
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/cli2/CacheDirectoriesTest.java PR Title: Add new Utility to determine cache location BEFORE CODE: XdgDirectories.getCacheHome() .resolve("cli") .resolve("projects") ...
Sorry missed this last time, we could make the naming a little more specific for these two variables?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
package com.google.cloud.tools.jib.cli.cli2; import com.google.cloud.tools.jib.filesystem.XdgDirectories; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Charsets; import java.io.IOException; import java.nio.file.Path; import java.security.MessageDigest; import java.security.NoSu...
```suggestion * @return an instance of CacheDirectories with cli specific cache locations ```
package com.google.cloud.tools.jib.cli.cli2; import com.google.cloud.tools.jib.filesystem.XdgDirectories; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Charsets; import java.io.IOException; import java.nio.file.Path; import java.security.MessageDigest; import java.security.NoSu...
@@ -0,0 +1,90 @@ +/* + * Copyright 2020 Google LLC. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by ...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/CacheDirectories.java
26
Java
0.571
performance
98
51
51
false
Add new Utility to determine cache location
2,929
GoogleContainerTools/jib
11,032
Java
mpeddada1
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/CacheDirectories.java PR Title: Add new Utility to determine cache location BEFORE CODE: package com.google.cloud.tools.jib.cli.cli2; import com.google.cloud.tools.jib.filesystem.XdgDirectories; import ...
```suggestion * @return an instance of CacheDirectories with cli specific cache locations ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
CheckVersion ${VERSION} if [ -n "$2" ]; then POST_RELEASE_VERSION=$2 CheckVersion ${POST_RELEASE_VERSION} fi if [[ $(git status -uno --porcelain) ]]; then Die 'There are uncommitted changes.' fi # Runs checks and integration tests. ./gradlew :jib-plugins-extension-common:check :jib-plugins-extension-common:inte...
is this message still "correct" ?
CheckVersion ${VERSION} if [ -n "$2" ]; then POST_RELEASE_VERSION=$2 CheckVersion ${POST_RELEASE_VERSION} fi if [[ $(git status -uno --porcelain) ]]; then Die 'There are uncommitted changes.' fi # Runs checks and integration tests. ./gradlew :jib-plugins-extension-common:check :jib-plugins-extension-common:inte...
@@ -52,10 +52,6 @@ git checkout -b ${BRANCH} -Prelease.releaseVersion=${VERSION} \ ${POST_RELEASE_VERSION:+"-Prelease.newVersion=${POST_RELEASE_VERSION}"} -# Pushes the release branch and tag to Github. -git push origin ${BRANCH} -git push origin v${VERSION}-extension-common - # File a PR on Github for the new...
jib-plugins-extension-common/scripts/prepare_release.sh
26
Shell
0.071
question
33
30
29
false
Use `-Prelease.useAutomaticVersion=true` for non-interactive release and remove unnecessary branch and tag pushes
2,936
GoogleContainerTools/jib
11,032
Java
loosebazooka
chanseokoh
Review this pull request change. Language: Shell File: jib-plugins-extension-common/scripts/prepare_release.sh PR Title: Use `-Prelease.useAutomaticVersion=true` for non-interactive release and remove unnecessary branch and tag pushes BEFORE CODE: CheckVersion ${VERSION} if [ -n "$2" ]; then POST_RELEASE_VERSION=...
is this message still "correct" ?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assertThat(cacheDirectories.getProjectCache()) .isEqualTo( XdgDirectories.getCacheHome() .resolve("cli") .resolve("projects") .resolve(CacheDirectories.getProjectCacheDirectoryFromProject(buildContext))); } @Test public void testCacheDirecto...
Not a big deal, but `temporaryFolder.newFile().toPath()` will work too. And use the new exception assertion style in jib-cli (using a lambda).
.resolve("jib-cli-cache") .resolve("projects") .resolve(CacheDirectories.getProjectCacheDirectoryFromProject(buildContext)); assertThat(cacheDirectories.getBaseImageCache()).isEmpty(); assertThat(cacheDirectories.getProjectCache()).isEqualTo(expectedProjectCache); assertT...
@@ -46,26 +47,38 @@ public void testCacheDirectories_defaults() { XdgDirectories.getCacheHome() .resolve("cli") .resolve("projects") - .resolve( - CacheDirectories.getProjectCacheDirectoryFromProject( - Paths.get("so...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/cli2/CacheDirectoriesTest.java
26
Java
0.714
style
145
51
51
false
Use cacheDirectories in cli commands
2,938
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/cli2/CacheDirectoriesTest.java PR Title: Use cacheDirectories in cli commands BEFORE CODE: assertThat(cacheDirectories.getProjectCache()) .isEqualTo( XdgDirectories.getCacheHome() ...
Not a big deal, but `temporaryFolder.newFile().toPath()` will work too. And use the new exception assertion style in jib-cli (using a lambda).
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
commonCliOptions.validate(); SingleThreadedExecutor executor = new SingleThreadedExecutor(); try (TempDirectoryProvider tempDirectoryProvider = new TempDirectoryProvider()) { ConsoleLogger logger = CliLogger.newLogger( commonCliOptions.getVerbosity(), commonCliOp...
Technically I think the `jarFile` path (not the parent) can still work. The difference is whether JARs in the same directory will use the same hash directory and share the app cache. Is there a specific reason to use a parent directory? One thing matters is when that `jarFile` doesn't have a parent directory, which ...
commonCliOptions.validate(); SingleThreadedExecutor executor = new SingleThreadedExecutor(); try (TempDirectoryProvider tempDirectoryProvider = new TempDirectoryProvider()) { ConsoleLogger logger = CliLogger.newLogger( commonCliOptions.getVerbosity(), commonCliOp...
@@ -84,7 +84,9 @@ public Integer call() { return 1; } - Containerizer containerizer = Containerizers.from(commonCliOptions, logger); + CacheDirectories cacheDirectories = + CacheDirectories.from(commonCliOptions, jarFile.getParent());
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java
26
Java
0.786
bug
756
45
45
false
Use cacheDirectories in cli commands
2,938
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java PR Title: Use cacheDirectories in cli commands BEFORE CODE: commonCliOptions.validate(); SingleThreadedExecutor executor = new SingleThreadedExecutor(); try (TempDirectoryProvider tem...
Technically I think the `jarFile` path (not the parent) can still work. The difference is whether JARs in the same directory will use the same hash directory and share the app cache. Is there a specific reason to use a parent directory? One thing matters is when that `jarFile` doesn't have a parent directory, which ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import java.nio.file.Path; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Optional; import javax.annotation.Nullable; /** A class to determine cache locations for any cli commands. */ public class CacheDirectories { @Nullable private final Path baseImageCache; ...
Just to confirm again: even if `Path` is a relative path (for example, `.`), `path.toFile().getCanonicalPath()` is always a full absolute path based on the current working directory?
import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Optional; import javax.annotation.Nullable; /** A class to determine cache locations for any cli commands. */ public class CacheDirectories { private static final String APPLICATION_LAYER_...
@@ -35,12 +37,15 @@ /** * Create a caches helper for cli cache locations. * - * @param commonCliOptions cli options - * @param contextRoot the context root, if a single file, use the parent directory, this context + * @param commonCliOptions cli options for user configured cache directories + * @para...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/CacheDirectories.java
26
Java
0.5
question
182
51
51
false
Use cacheDirectories in cli commands
2,938
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/CacheDirectories.java PR Title: Use cacheDirectories in cli commands BEFORE CODE: import java.nio.file.Path; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java....
Just to confirm again: even if `Path` is a relative path (for example, `.`), `path.toFile().getCanonicalPath()` is always a full absolute path based on the current working directory?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
CommandLine.populateCommand( new CommonCliOptions(), "-t=ignored", "--base-image-cache=test-base-image-cache", "--project-cache=test-project-cache"); Path ignoredContext = temporaryFolder.newFolder("ignored").toPath(); CacheDirectories cacheDirectories = C...
nit: `assertThat().hasMessageThat().isEqualTo()`
CommandLine.populateCommand( new CommonCliOptions(), "-t=ignored", "--base-image-cache=test-base-image-cache", "--project-cache=test-project-cache"); Path ignoredContext = temporaryFolder.newFolder("ignored").toPath(); CacheDirectories cacheDirectories = C...
@@ -34,36 +34,52 @@ @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); @Test - public void testCacheDirectories_defaults() { + public void testCacheDirectories_defaults() throws IOException { CommonCliOptions commonCliOptions = CommandLine.populateCommand(new CommonCliOptions(...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/cli2/CacheDirectoriesTest.java
26
Java
0.214
nitpick
48
49
50
false
Use cacheDirectories in cli commands
2,938
GoogleContainerTools/jib
11,032
Java
mpeddada1
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/cli2/CacheDirectoriesTest.java PR Title: Use cacheDirectories in cli commands BEFORE CODE: CommandLine.populateCommand( new CommonCliOptions(), "-t=ignored", "--base...
nit: `assertThat().hasMessageThat().isEqualTo()`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} @Test public void testCacheDirectories_configuredValuesIgnoresBuildContext() throws IOException { CommonCliOptions commonCliOptions = CommandLine.populateCommand( new CommonCliOptions(), "-t=ignored", "--base-image-cache=test-base-image-cache", "--pro...
maybe `exception` instead of an abbreviation?
} @Test public void testCacheDirectories_configuredValuesIgnoresBuildContext() throws IOException { CommonCliOptions commonCliOptions = CommandLine.populateCommand( new CommonCliOptions(), "-t=ignored", "--base-image-cache=test-base-image-cache", "--pro...
@@ -34,36 +34,52 @@ @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); @Test - public void testCacheDirectories_defaults() { + public void testCacheDirectories_defaults() throws IOException { CommonCliOptions commonCliOptions = CommandLine.populateCommand(new CommonCliOptions(...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/cli2/CacheDirectoriesTest.java
26
Java
0.429
question
45
51
51
false
Use cacheDirectories in cli commands
2,938
GoogleContainerTools/jib
11,032
Java
mpeddada1
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/cli2/CacheDirectoriesTest.java PR Title: Use cacheDirectories in cli commands BEFORE CODE: } @Test public void testCacheDirectories_configuredValuesIgnoresBuildContext() throws IOException { CommonC...
maybe `exception` instead of an abbreviation?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
commonCliOptions.validate(); SingleThreadedExecutor executor = new SingleThreadedExecutor(); try (TempDirectoryProvider tempDirectoryProvider = new TempDirectoryProvider()) { ConsoleLogger logger = CliLogger.newLogger( commonCliOptions.getVerbosity(), commonCliOp...
I don't think this will work. @mpeddada1 can you check what `jarFile.toAbsolutePath()` evaluates to when running `jib jar app.jar` (i.e., `jarFile` is simply `app.jar`)?
commonCliOptions.validate(); SingleThreadedExecutor executor = new SingleThreadedExecutor(); try (TempDirectoryProvider tempDirectoryProvider = new TempDirectoryProvider()) { ConsoleLogger logger = CliLogger.newLogger( commonCliOptions.getVerbosity(), commonCliOp...
@@ -84,7 +84,9 @@ public Integer call() { return 1; } - Containerizer containerizer = Containerizers.from(commonCliOptions, logger); + CacheDirectories cacheDirectories = + CacheDirectories.from(commonCliOptions, jarFile.toAbsolutePath().getParent());
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java
26
Java
0.5
question
169
43
45
false
Use cacheDirectories in cli commands
2,938
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java PR Title: Use cacheDirectories in cli commands BEFORE CODE: commonCliOptions.validate(); SingleThreadedExecutor executor = new SingleThreadedExecutor(); try (TempDirectoryProvider tem...
I don't think this will work. @mpeddada1 can you check what `jarFile.toAbsolutePath()` evaluates to when running `jib jar app.jar` (i.e., `jarFile` is simply `app.jar`)?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} Path getBaseImageLayersCacheDirectory() { return baseImageLayersCacheDirectory; } Path getApplicationLayersCacheDirectory() throws CacheDirectoryCreationException { return getApplicationLayersCacheDirectory( () -> Paths.get(System.getProperty("java.io.tmpdir"))); } @VisibleForTesting ...
Actually think I can clean up all this logic and just use Files.createDirectories ? Or just lets the cache writer handle this?
Path getBaseImageLayersCacheDirectory() { return baseImageLayersCacheDirectory; } Path getApplicationLayersCacheDirectory() throws CacheDirectoryCreationException { if (applicationLayersCacheDirectory == null) { // Create a directory in temp if application layers cache directory is not set. t...
@@ -312,11 +318,27 @@ Path getBaseImageLayersCacheDirectory() { } Path getApplicationLayersCacheDirectory() throws CacheDirectoryCreationException { + return getApplicationLayersCacheDirectory( + () -> Paths.get(System.getProperty("java.io.tmpdir"))); + } + + @VisibleForTesting + Path getApplicatio...
jib-core/src/main/java/com/google/cloud/tools/jib/api/Containerizer.java
26
Java
0.571
performance
126
51
51
false
Update jib-core default application cache dir
2,945
GoogleContainerTools/jib
11,032
Java
loosebazooka
loosebazooka
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/api/Containerizer.java PR Title: Update jib-core default application cache dir BEFORE CODE: } Path getBaseImageLayersCacheDirectory() { return baseImageLayersCacheDirectory; } Path getApplicationLay...
Actually think I can clean up all this logic and just use Files.createDirectories ? Or just lets the cache writer handle this?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
public void testGetImageConfiguration_dockerDaemonImage() throws InvalidImageReferenceException { Containerizer containerizer = Containerizer.to(DockerDaemonImage.named("docker/deamon/image")); ImageConfiguration imageConfiguration = containerizer.getImageConfiguration(); Assert.assertEquals("docker/deam...
How about verifying the name in the test? ```suggestion .resolve("jib-core-application-layers-cache"); ```
Assert.assertEquals("docker/deamon/image", imageConfiguration.getImage().toString()); Assert.assertEquals(0, imageConfiguration.getCredentialRetrievers().size()); } @Test public void testGetImageConfiguration_tarImage() throws InvalidImageReferenceException { Containerizer containerizer = Con...
@@ -121,4 +128,15 @@ public void testGetImageConfiguration_tarImage() throws InvalidImageReferenceExc Assert.assertEquals("tar/image", imageConfiguration.getImage().toString()); Assert.assertEquals(0, imageConfiguration.getCredentialRetrievers().size()); } + + @Test + public void testGetApplicationLayers...
jib-core/src/test/java/com/google/cloud/tools/jib/api/ContainerizerTest.java
26
Java
0.714
performance
121
30
26
false
Update jib-core default application cache dir
2,945
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-core/src/test/java/com/google/cloud/tools/jib/api/ContainerizerTest.java PR Title: Update jib-core default application cache dir BEFORE CODE: public void testGetImageConfiguration_dockerDaemonImage() throws InvalidImageReferenceException { Containerize...
How about verifying the name in the test? ```suggestion .resolve("jib-core-application-layers-cache"); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* Copyright 2018 Google LLC. * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in...
actually this change is now unnecessary
* Copyright 2018 Google LLC. * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in...
@@ -24,4 +24,8 @@ public CacheDirectoryCreationException(Throwable cause) { super(MESSAGE, cause); } +
jib-core/src/main/java/com/google/cloud/tools/jib/api/CacheDirectoryCreationException.java
26
Java
0.143
suggestion
39
31
27
false
Update jib-core default application cache dir
2,945
GoogleContainerTools/jib
11,032
Java
loosebazooka
loosebazooka
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/api/CacheDirectoryCreationException.java PR Title: Update jib-core default application cache dir BEFORE CODE: * Copyright 2018 Google LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); yo...
actually this change is now unnecessary
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@Test public void testEntrypoint_warningOnMainclass() throws InvalidImageReferenceException, IOException, CacheDirectoryCreationException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, ...
```suggestion public void testEntrypoint_warningOnExpandClasspathDependencies() ```
@Test public void testEntrypoint_warningOnMainclass() throws InvalidImageReferenceException, IOException, CacheDirectoryCreationException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, ...
@@ -451,7 +452,32 @@ public void testEntrypoint_warningOnMainclass() Mockito.verify(projectProperties) .log( LogEvent.warn( - "mainClass, extraClasspath, and jvmFlags are ignored when entrypoint is specified")); + "mainClass, extraClasspath, jvmFlags, and expandC...
jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessorTest.java
26
Java
0.571
suggestion
87
51
51
false
Add doc for expandClasspathDependencies and update warning message
2,949
GoogleContainerTools/jib
11,032
Java
mpeddada1
chanseokoh
Review this pull request change. Language: Java File: jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessorTest.java PR Title: Add doc for expandClasspathDependencies and update warning message BEFORE CODE: @Test public void testEntrypoint_warningOnMainclass() ...
```suggestion public void testEntrypoint_warningOnExpandClasspathDependencies() ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assertThat(buildPlan.getPlatforms()).isEqualTo(ImmutableSet.of(new Platform("amd64", "linux"))); assertThat(buildPlan.getCreationTime()).isEqualTo(Instant.EPOCH); assertThat(buildPlan.getFormat()).isEqualTo(ImageFormat.Docker); assertThat(buildPlan.getEnvironment()).isEmpty(); assertThat(buildPlan.g...
Currently, I can't think of a good way to test for the tar base image without accessing the build context (similar to what's being done in PluginConfigurationProcessorTest)
/* * Copyright 2020 Google LLC. * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to...
@@ -217,4 +237,34 @@ public void testToJibContainerBuilder_packagedSpringBoot_basicInfo() .build() .getEntries()); } + + @Test + public void testToJibContainerBuilder_dockerBaseImage() + throws IOException, InvalidImageReferenceException {
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarFilesTest.java
26
Java
0.357
style
172
51
240
false
Add option to specify base image for cli jar command
2,972
GoogleContainerTools/jib
11,032
Java
mpeddada1
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarFilesTest.java PR Title: Add option to specify base image for cli jar command BEFORE CODE: assertThat(buildPlan.getPlatforms()).isEqualTo(ImmutableSet.of(new Platform("amd64", "linux"))); assert...
Currently, I can't think of a good way to test for the tar base image without accessing the build context (similar to what's being done in PluginConfigurationProcessorTest)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
CacheDirectories cacheDirectories = CacheDirectories.from(commonCliOptions, jarFile.toAbsolutePath().getParent()); Containerizer containerizer = Containerizers.from(commonCliOptions, logger, cacheDirectories); containerBuilder.containerize(containerizer); } catch (Exception ex) { i...
`return Optional.ofNullable(from);`
CacheDirectories cacheDirectories = CacheDirectories.from(commonCliOptions, jarFile.toAbsolutePath().getParent()); Containerizer containerizer = Containerizers.from(commonCliOptions, logger, cacheDirectories); containerBuilder.containerize(containerizer); } catch (Exception ex) { i...
@@ -114,4 +123,16 @@ public Integer call() { } return 0; } + + /** + * Returns the user specified base image. + * + * @return an optional base image + */ + public Optional<String> getFrom() { + if (from != null) { + return Optional.of(from); + } + return Optional.empty();
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java
26
Java
0.357
suggestion
35
29
26
false
Add option to specify base image for cli jar command
2,972
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java PR Title: Add option to specify base image for cli jar command BEFORE CODE: CacheDirectories cacheDirectories = CacheDirectories.from(commonCliOptions, jarFile.toAbsolutePath().getPare...
`return Optional.ofNullable(from);`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* provided doesn't exist * @throws InvalidImageReferenceException if the base image reference is invalid */ public static JibContainerBuilder toJibContainerBuilder( JarProcessor processor, Jar jarOptions, CommonCliOptions commonCliOptions, ConsoleLogger logger) throws IOExce...
It's unfortunate that the code is duplicated here and in `BuildFiles`. @loosebazooka thoughts?
/* * Copyright 2020 Google LLC. * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to...
@@ -30,20 +46,55 @@ * Generates a {@link JibContainerBuilder} from contents of a jar file. * * @param processor jar processor + * @param jarOptions jar cli options + * @param commonCliOptions common cli options + * @param logger console logger * @return JibContainerBuilder * @throws IOExceptio...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java
26
Java
0.357
refactor
94
48
66
false
Add option to specify base image for cli jar command
2,972
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java PR Title: Add option to specify base image for cli jar command BEFORE CODE: * provided doesn't exist * @throws InvalidImageReferenceException if the base image reference is invalid ...
It's unfortunate that the code is duplicated here and in `BuildFiles`. @loosebazooka thoughts?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
? createJibContainerBuilder(baseImageSpec.get(), commonCliOptions, logger) : Jib.fromScratch(); buildFile.getCreationTime().ifPresent(containerBuilder::setCreationTime); buildFile.getFormat().ifPresent(containerBuilder::setFormat); containerBuilder.setEnvironment(buildFile.getEnviro...
This `if (...)` probably isn't necessary. For an empty list, stream will return an empty collection. So just `List<Platform> platforms = baseImageSpec.getPlatforms().stream().map().collect()`.
: Jib.fromScratch(); buildFile.getCreationTime().ifPresent(containerBuilder::setCreationTime); buildFile.getFormat().ifPresent(containerBuilder::setFormat); containerBuilder.setEnvironment(buildFile.getEnvironment()); containerBuilder.setLabels(buildFile.getLabels()); containerBuilder.s...
@@ -111,40 +102,20 @@ public static JibContainerBuilder toJibContainerBuilder( return containerBuilder; } - // TODO: add testing, need to do via intergration tests as there's no good way to extract out that - // the base image was populated as the user intended currently. - static JibContainerBuilder cre...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java
26
Java
0.5
suggestion
192
39
33
false
Add option to specify base image for cli jar command
2,972
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java PR Title: Add option to specify base image for cli jar command BEFORE CODE: ? createJibContainerBuilder(baseImageSpec.get(), commonCliOptions, logger) : Jib.fr...
This `if (...)` probably isn't necessary. For an empty list, stream will return an empty collection. So just `List<Platform> platforms = baseImageSpec.getPlatforms().stream().map().collect()`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
String baseImageReference, List<Platform> platforms, CommonCliOptions commonCliOptions, ConsoleLogger logger) throws InvalidImageReferenceException, FileNotFoundException { if (baseImageReference.startsWith(DOCKER_DAEMON_IMAGE_PREFIX)) { return Jib.from( DockerDaemonIma...
If you make `create()` accept `Set<Platform>`, it won't need `stream().collect()`. BTW, [this link](https://stackoverflow.com/q/27611896/1701388) says `toSet()` doesn't preserve the order. The order of platforms is important, so that's why the original code used `Collectors.toCollection(LinkedHashSet::new))`.
Set<Platform> platforms, CommonCliOptions commonCliOptions, ConsoleLogger logger) throws InvalidImageReferenceException, FileNotFoundException { if (baseImageReference.startsWith(DOCKER_DAEMON_IMAGE_PREFIX)) { return Jib.from( DockerDaemonImage.named(baseImageReference.replac...
@@ -0,0 +1,83 @@ +/* + * Copyright 2021 Google LLC. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by ...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/ContainerBuilders.java
26
Java
0.786
bug
313
31
30
false
Add option to specify base image for cli jar command
2,972
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/ContainerBuilders.java PR Title: Add option to specify base image for cli jar command BEFORE CODE: String baseImageReference, List<Platform> platforms, CommonCliOptions commonCliOptions, ...
If you make `create()` accept `Set<Platform>`, it won't need `stream().collect()`. BTW, [this link](https://stackoverflow.com/q/27611896/1701388) says `toSet()` doesn't preserve the order. The order of platforms is important, so that's why the original code used `Collectors.toCollection(LinkedHashSet::new))`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import static com.google.cloud.tools.jib.api.Jib.TAR_IMAGE_PREFIX; import com.google.cloud.tools.jib.api.DockerDaemonImage; import com.google.cloud.tools.jib.api.ImageReference; import com.google.cloud.tools.jib.api.InvalidImageReferenceException; import com.google.cloud.tools.jib.api.Jib; import com.google.cloud.tool...
nit: ```suggestion * @param platforms platforms for multi-platform support in build command ```
import static com.google.cloud.tools.jib.api.Jib.TAR_IMAGE_PREFIX; import com.google.cloud.tools.jib.api.DockerDaemonImage; import com.google.cloud.tools.jib.api.ImageReference; import com.google.cloud.tools.jib.api.InvalidImageReferenceException; import com.google.cloud.tools.jib.api.Jib; import com.google.cloud.tool...
@@ -0,0 +1,83 @@ +/* + * Copyright 2021 Google LLC. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by ...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/ContainerBuilders.java
26
Java
0.714
suggestion
103
51
51
false
Add option to specify base image for cli jar command
2,972
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/ContainerBuilders.java PR Title: Add option to specify base image for cli jar command BEFORE CODE: import static com.google.cloud.tools.jib.api.Jib.TAR_IMAGE_PREFIX; import com.google.cloud.tools.jib.api.Dock...
nit: ```suggestion * @param platforms platforms for multi-platform support in build command ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
"--target", "docker://packaged-spring-boot", jarPath.toString(), "--mode=packaged"); assertThat(exitCode).isEqualTo(0); String output = new Command("docker", "run", "--rm", "--detach", "-p8080:8080", "packaged-spring-boot") .ru...
nit: how about this? ```suggestion "jar", "--target=docker://cli-gcr-base", "--from=gcr.io/google-appengine/openjdk:8", ```
"--target", "docker://packaged-spring-boot", jarPath.toString(), "--mode=packaged"); assertThat(exitCode).isEqualTo(0); String output = new Command("docker", "run", "--rm", "--detach", "-p8080:8080", "packaged-spring-boot") .ru...
@@ -239,6 +239,24 @@ public void testSpringBootJar_packagedMode() throws IOException, InterruptedExce assertThat(getContent(new URL("http://localhost:8080"))).isEqualTo("Hello world"); } + @Test + public void testJar_baseImageSpecified() + throws IOException, URISyntaxException, InterruptedException { ...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/JarCommandTest.java
26
Java
0.714
suggestion
178
51
49
false
Add option to specify base image for cli jar command
2,972
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/JarCommandTest.java PR Title: Add option to specify base image for cli jar command BEFORE CODE: "--target", "docker://packaged-spring-boot", jarPath....
nit: how about this? ```suggestion "jar", "--target=docker://cli-gcr-base", "--from=gcr.io/google-appengine/openjdk:8", ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
containerBuilder.setExposedPorts(buildFile.getExposedPorts()); buildFile.getUser().ifPresent(containerBuilder::setUser); buildFile.getWorkingDirectory().ifPresent(containerBuilder::setWorkingDirectory); buildFile.getEntrypoint().ifPresent(containerBuilder::setEntrypoint); buildFile.getCmd().ifPresen...
`collect(toCollection(LinkedHashSet::new))`?
/* * Copyright 2020 Google LLC. * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to...
@@ -111,40 +102,20 @@ public static JibContainerBuilder toJibContainerBuilder( return containerBuilder; } - // TODO: add testing, need to do via intergration tests as there's no good way to extract out that - // the base image was populated as the user intended currently. - static JibContainerBuilder cre...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java
26
Java
0.214
question
44
31
116
false
Add option to specify base image for cli jar command
2,972
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java PR Title: Add option to specify base image for cli jar command BEFORE CODE: containerBuilder.setExposedPorts(buildFile.getExposedPorts()); buildFile.getUser().ifPresent(contai...
`collect(toCollection(LinkedHashSet::new))`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import com.google.cloud.tools.jib.configuration.ImageConfiguration; import com.google.cloud.tools.jib.plugins.common.logging.ConsoleLogger; import com.google.common.collect.ImmutableSet; import java.io.IOException; import java.nio.file.Paths; import java.util.Collections; import java.util.Optional; import org.junit.Tes...
Sorry, missed this. Let's use `Collections.emptyList()` and `.emptySet()`. https://stackoverflow.com/q/14870819/1701388
import com.google.cloud.tools.jib.configuration.ImageConfiguration; import com.google.cloud.tools.jib.plugins.common.logging.ConsoleLogger; import com.google.common.collect.ImmutableSet; import java.io.IOException; import java.nio.file.Paths; import java.util.Collections; import java.util.Optional; import org.junit.Tes...
@@ -0,0 +1,111 @@ +/* + * Copyright 2021 Google LLC. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/ContainerBuildersTest.java
26
Java
0.714
bug
119
51
51
false
Add option to specify base image for cli jar command
2,972
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/ContainerBuildersTest.java PR Title: Add option to specify base image for cli jar command BEFORE CODE: import com.google.cloud.tools.jib.configuration.ImageConfiguration; import com.google.cloud.tools.jib.plug...
Sorry, missed this. Let's use `Collections.emptyList()` and `.emptySet()`. https://stackoverflow.com/q/14870819/1701388
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2020 Google LLC. * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to...
I think here we should try to check if the jar is java8 or java11 and chose the right distroless? (perhaps in a followup PR)
import java.util.Collections; import java.util.List; /** Class to build a container representation from the contents of a jar file. */ public class JarFiles { /** * Generates a {@link JibContainerBuilder} from contents of a jar file. * * @param processor jar processor * @param jarOptions jar cli options...
@@ -30,16 +35,27 @@ * Generates a {@link JibContainerBuilder} from contents of a jar file. * * @param processor jar processor + * @param jarOptions jar cli options + * @param commonCliOptions common cli options + * @param logger console logger * @return JibContainerBuilder * @throws IOExceptio...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java
26
Java
0.429
suggestion
124
50
39
false
Add option to specify base image for cli jar command
2,972
GoogleContainerTools/jib
11,032
Java
loosebazooka
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java PR Title: Add option to specify base image for cli jar command BEFORE CODE: /* * Copyright 2020 Google LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not ...
I think here we should try to check if the jar is java8 or java11 and chose the right distroless? (perhaps in a followup PR)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@CommandLine.Parameters(description = "The path to the jar file (ex: path/to/my-jar.jar)") @SuppressWarnings("NullAway.Init") // initialized by picocli private Path jarFile; @CommandLine.Option( names = "--mode", defaultValue = "exploded", paramLabel = "<mode>", description = ...
I think it's worth adding a comma-separated usage example. `-Dmy.property=value,-Xshare:off`.
@CommandLine.Parameters(description = "The path to the jar file (ex: path/to/my-jar.jar)") @SuppressWarnings("NullAway.Init") // initialized by picocli private Path jarFile; @CommandLine.Option( names = "--mode", defaultValue = "exploded", paramLabel = "<mode>", description = ...
@@ -67,11 +78,71 @@ @CommandLine.Option( names = "--from", - paramLabel = "<from>", + paramLabel = "<base-image>", description = "The base image to use.") @SuppressWarnings("NullAway.Init") // initialized by picocli private String from; + @CommandLine.Option( + names = "--jvm-...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java
26
Java
0.357
suggestion
93
51
51
false
Add more options to cli jar command
2,975
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java PR Title: Add more options to cli jar command BEFORE CODE: @CommandLine.Parameters(description = "The path to the jar file (ex: path/to/my-jar.jar)") @SuppressWarnings("NullAway.Init") // initia...
I think it's worth adding a comma-separated usage example. `-Dmy.property=value,-Xshare:off`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
defaultValue = "exploded", paramLabel = "<mode>", description = "The jar processing mode, candidates: ${COMPLETION-CANDIDATES}, default: ${DEFAULT-VALUE}") @SuppressWarnings("NullAway.Init") // initialized by picocli private ProcessingMode mode; @CommandLine.Option( names = "--f...
Example like `5000,7/dup`. I believe my example works but needs to confirm.
paramLabel = "<mode>", description = "The jar processing mode, candidates: ${COMPLETION-CANDIDATES}, default: ${DEFAULT-VALUE}") @SuppressWarnings("NullAway.Init") // initialized by picocli private ProcessingMode mode; @CommandLine.Option( names = "--from", paramLabel = "<base-i...
@@ -67,11 +78,71 @@ @CommandLine.Option( names = "--from", - paramLabel = "<from>", + paramLabel = "<base-image>", description = "The base image to use.") @SuppressWarnings("NullAway.Init") // initialized by picocli private String from; + @CommandLine.Option( + names = "--jvm-...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java
26
Java
0.357
suggestion
75
51
51
false
Add more options to cli jar command
2,975
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java PR Title: Add more options to cli jar command BEFORE CODE: defaultValue = "exploded", paramLabel = "<mode>", description = "The jar processing mode, candidates: ${COMPLETI...
Example like `5000,7/dup`. I believe my example works but needs to confirm.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@CommandLine.Option( names = "--from", paramLabel = "<base-image>", description = "The base image to use.") @SuppressWarnings("NullAway.Init") // initialized by picocli private String from; @CommandLine.Option( names = "--jvm-flags", paramLabel = "<jvm-flags>", split = ",", ...
Example, but I forgot the exact format required.
names = "--from", paramLabel = "<base-image>", description = "The base image to use.") @SuppressWarnings("NullAway.Init") // initialized by picocli private String from; @CommandLine.Option( names = "--jvm-flags", paramLabel = "<jvm-flags>", split = ",", description = "JV...
@@ -67,11 +78,71 @@ @CommandLine.Option( names = "--from", - paramLabel = "<from>", + paramLabel = "<base-image>", description = "The base image to use.") @SuppressWarnings("NullAway.Init") // initialized by picocli private String from; + @CommandLine.Option( + names = "--jvm-...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java
26
Java
0.071
style
48
51
51
false
Add more options to cli jar command
2,975
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java PR Title: Add more options to cli jar command BEFORE CODE: @CommandLine.Option( names = "--from", paramLabel = "<base-image>", description = "The base image to use.") @SuppressW...
Example, but I forgot the exact format required.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// Classes layer. Predicate<Path> isClass = path -> path.getFileName().toString().endsWith(".class"); Predicate<Path> isInBootInfClasses = path -> path.startsWith(localExplodedJarRoot.resolve("BOOT-INF").resolve("classes")); Predicate<Path> classesPredicate = isInBootInfClasses.and(isC...
nit: how about `ImmutableList.builder()`?
// Classes layer. Predicate<Path> isClass = path -> path.getFileName().toString().endsWith(".class"); Predicate<Path> isInBootInfClasses = path -> path.startsWith(localExplodedJarRoot.resolve("BOOT-INF").resolve("classes")); Predicate<Path> classesPredicate = isInBootInfClasses.and(isC...
@@ -117,12 +117,14 @@ public SpringBootExplodedProcessor(Path jarPath, Path tempDirectoryPath) { } @Override - public ImmutableList<String> computeEntrypoint() { - return ImmutableList.of( - "java", - "-cp", - JarLayers.APP_ROOT.toString(), - "org.springframework.boot.loader.JarL...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/SpringBootExplodedProcessor.java
26
Java
0.214
question
41
51
51
false
Add more options to cli jar command
2,975
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/SpringBootExplodedProcessor.java PR Title: Add more options to cli jar command BEFORE CODE: // Classes layer. Predicate<Path> isClass = path -> path.getFileName().toString().endsWith(".class")...
nit: how about `ImmutableList.builder()`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* provided doesn't exist * @throws InvalidImageReferenceException if the base image reference is invalid */ public static JibContainerBuilder toJibContainerBuilder( JarProcessor processor, Jar jarOptions, CommonCliOptions commonCliOptions, ConsoleLogger logger) throws IOExce...
nit: chain these? `.setExposedPorts(...).setVolumes(...).setEnvironment(...)`
* provided doesn't exist * @throws InvalidImageReferenceException if the base image reference is invalid */ public static JibContainerBuilder toJibContainerBuilder( JarProcessor processor, Jar jarOptions, CommonCliOptions commonCliOptions, ConsoleLogger logger) throws IOExce...
@@ -58,8 +58,17 @@ public static JibContainerBuilder toJibContainerBuilder( : Jib.from("gcr.io/distroless/java-debian10:11"); List<FileEntriesLayer> layers = processor.createLayers(); - List<String> entrypoint = processor.computeEntrypoint(); + List<String> entrypoint = processor.computeEntryp...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java
26
Java
0.357
nitpick
77
33
35
false
Add more options to cli jar command
2,975
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java PR Title: Add more options to cli jar command BEFORE CODE: * provided doesn't exist * @throws InvalidImageReferenceException if the base image reference is invalid */ public s...
nit: chain these? `.setExposedPorts(...).setVolumes(...).setEnvironment(...)`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
split = ",", description = "JVM arguments, example: --jvm-flags=-Dmy.property=value,-Xshare:off") private List<String> jvmFlags = Collections.emptyList(); @CommandLine.Option( names = "--expose", paramLabel = "<exposed-ports>", split = ",", description = "Ports to expose on cont...
Perhaps for consistency, `Collections.emptyMap()`. If `Collections.emptyList()` worked for others, `emptyMap()` should work. It's certain that no one is modifying the initially assigned collection, because `Collections.empty???()` are immutable. (They throw an exception if someone tries to modify it.)
description = "JVM arguments, example: --jvm-flags=-Dmy.property=value,-Xshare:off") private List<String> jvmFlags = Collections.emptyList(); @CommandLine.Option( names = "--expose", paramLabel = "<exposed-ports>", split = ",", description = "Ports to expose on container, example: --e...
@@ -67,11 +78,72 @@ @CommandLine.Option( names = "--from", - paramLabel = "<from>", + paramLabel = "<base-image>", description = "The base image to use.") @SuppressWarnings("NullAway.Init") // initialized by picocli private String from; + @CommandLine.Option( + names = "--jvm-...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java
26
Java
0.786
style
302
51
51
false
Add more options to cli jar command
2,975
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java PR Title: Add more options to cli jar command BEFORE CODE: split = ",", description = "JVM arguments, example: --jvm-flags=-Dmy.property=value,-Xshare:off") private List<String> jvmFlag...
Perhaps for consistency, `Collections.emptyMap()`. If `Collections.emptyList()` worked for others, `emptyMap()` should work. It's certain that no one is modifying the initially assigned collection, because `Collections.empty???()` are immutable. (They throw an exception if someone tries to modify it.)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import java.util.jar.JarEntry; import java.util.jar.JarFile; /** Class to create a {@link JarProcessor} instance depending on jar type and processing mode. */ public class JarProcessors { private static String SPRING_BOOT = "spring-boot"; private static String STANDARD = "standard"; private static Integer VERSIO...
In build plugins, we catch this exception at a higher stack and provide a detailed error message with an action item. Maybe we can throw an `IllegalStateException`? The message should report the app version, what the problem is, and how to fix.
import java.util.jar.JarFile; /** Class to create a {@link JarProcessor} instance depending on jar type and processing mode. */ public class JarProcessors { private static String SPRING_BOOT = "spring-boot"; private static String STANDARD = "standard"; private static Integer VERSION_NOT_FOUND = 0; /** * Cr...
@@ -34,10 +42,17 @@ * @param mode processing mode * @return JarProcessor * @throws IOException if I/O error occurs when opening the jar file + * @throws IncompatibleBaseImageJavaVersionException if the base image java version cannot support + * this build */ public static JarProcessor from( ...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java
26
Java
0.786
suggestion
244
51
51
false
Build Failure if JAR requires Java >11
2,988
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java PR Title: Build Failure if JAR requires Java >11 BEFORE CODE: import java.util.jar.JarEntry; import java.util.jar.JarFile; /** Class to create a {@link JarProcessor} instance depending...
In build plugins, we catch this exception at a higher stack and provide a detailed error message with an action item. Maybe we can throw an `IllegalStateException`? The message should report the app version, what the problem is, and how to fix.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
private static String determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { if (jarFile.getEntry("BOOT-INF") != null) { return SPRING_BOOT; } return STANDARD; } } /** * Determines the java version of JAR. Derives the versi...
Can we do this? ```suggestion try (InputStream classFileInfo = loader.getResourceAsStream(jarEntry); DataInputStream data = new DataInputStream(classFileInfo)) { ``` And why is it called classFile*Info*? Isn't it really a class file? Or, in most cases, I believe this is OK: ```java t...
* @throws IOException if I/O error occurs when opening the file */ private static String determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { if (jarFile.getEntry("BOOT-INF") != null) { return SPRING_BOOT; } return STANDARD; ...
@@ -65,4 +80,40 @@ private static String determineJarType(Path jarPath) throws IOException { return STANDARD; } } + + /** + * Determines the java version of JAR. Derives the version from the first .class file it finds in + * the JAR. + * + * @param jarPath path to the jar + * @return java vers...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java
26
Java
0.786
question
408
46
49
false
Build Failure if JAR requires Java >11
2,988
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java PR Title: Build Failure if JAR requires Java >11 BEFORE CODE: private static String determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath....
Can we do this? ```suggestion try (InputStream classFileInfo = loader.getResourceAsStream(jarEntry); DataInputStream data = new DataInputStream(classFileInfo)) { ``` And why is it called classFile*Info*? Isn't it really a class file? Or, in most cases, I believe this is OK: ```java t...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} return STANDARD; } } /** * Determines the java version of JAR. Derives the version from the first .class file it finds in * the JAR. * * @param jarPath path to the jar * @return java version * @throws IOException if I/O exception thrown when opening the jar file */ private ...
I guess this should work with the Java 9+ [`module-info.class`](https://stackoverflow.com/q/57358750/1701388), but it's worth testing. I found a [simple example](https://github.com/tfij/Java-9-modules---the-simplest-example), where running `compile.sh` generates `build/pl.tfij.java9modules.app/module-info.class` and...
if (jarFile.getEntry("BOOT-INF") != null) { return SPRING_BOOT; } return STANDARD; } } /** * Determines the java version of JAR. Derives the version from the first .class file it finds in * the JAR. * * @param jarPath path to the jar * @return java version * @throws ...
@@ -65,4 +80,40 @@ private static String determineJarType(Path jarPath) throws IOException { return STANDARD; } } + + /** + * Determines the java version of JAR. Derives the version from the first .class file it finds in + * the JAR. + * + * @param jarPath path to the jar + * @return java vers...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java
26
Java
0.786
bug
454
42
45
false
Build Failure if JAR requires Java >11
2,988
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java PR Title: Build Failure if JAR requires Java >11 BEFORE CODE: } return STANDARD; } } /** * Determines the java version of JAR. Derives the version from the first...
I guess this should work with the Java 9+ [`module-info.class`](https://stackoverflow.com/q/57358750/1701388), but it's worth testing. I found a [simple example](https://github.com/tfij/Java-9-modules---the-simplest-example), where running `compile.sh` generates `build/pl.tfij.java9modules.app/module-info.class` and...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/** * Generates a {@link JibContainerBuilder} from contents of a jar file. * * @param processor jar processor * @param jarOptions jar cli options * @param commonCliOptions common cli options * @param logger console logger * @return JibContainerBuilder * @throws IOException if I/O error occurs...
Just curious: is this the debian10 one?
/** * Generates a {@link JibContainerBuilder} from contents of a jar file. * * @param processor jar processor * @param jarOptions jar cli options * @param commonCliOptions common cli options * @param logger console logger * @return JibContainerBuilder * @throws IOException if I/O error occurs...
@@ -55,7 +55,7 @@ public static JibContainerBuilder toJibContainerBuilder( jarOptions.getFrom().isPresent() ? ContainerBuilders.create( jarOptions.getFrom().get(), Collections.emptySet(), commonCliOptions, logger) - : Jib.from("gcr.io/distroless/java"); + : J...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java
26
Java
0.071
question
45
34
34
false
Build Failure if JAR requires Java >11
2,988
GoogleContainerTools/jib
11,032
Java
loosebazooka
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java PR Title: Build Failure if JAR requires Java >11 BEFORE CODE: /** * Generates a {@link JibContainerBuilder} from contents of a jar file. * * @param processor jar processor * @...
Just curious: is this the debian10 one?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* @return the jar type * @throws IOException if I/O error occurs when opening the file */ private static String determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { if (jarFile.getEntry("BOOT-INF") != null) { return SPRING_BOOT; }...
Is `jarEntry` a filename without path? If not, maybe it should be `!jarEntry.endsWith("module-info.class")`.
* * @param jarPath path to the jar * @return the jar type * @throws IOException if I/O error occurs when opening the file */ private static String determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { if (jarFile.getEntry("BOOT-INF") != nu...
@@ -65,4 +80,40 @@ private static String determineJarType(Path jarPath) throws IOException { return STANDARD; } } + + /** + * Determines the java version of JAR. Derives the version from the first .class file it finds in + * the JAR. + * + * @param jarPath path to the jar + * @return java vers...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java
26
Java
0.571
suggestion
108
49
51
false
Build Failure if JAR requires Java >11
2,988
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java PR Title: Build Failure if JAR requires Java >11 BEFORE CODE: * @return the jar type * @throws IOException if I/O error occurs when opening the file */ private static String ...
Is `jarEntry` a filename without path? If not, maybe it should be `!jarEntry.endsWith("module-info.class")`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/** Class to create a {@link JarProcessor} instance depending on jar type and processing mode. */ public class JarProcessors { private static String SPRING_BOOT = "spring-boot"; private static String STANDARD = "standard"; private static Integer VERSION_NOT_FOUND = 0; /** * Creates a {@link JarProcessor} i...
How about this? The input JAR (jarPath) is compiled with Java x, but the default base image only supports versions up to Java 11. Specify a custom base image with `--base-image` (if this is the right option).
import java.util.jar.JarFile; /** Class to create a {@link JarProcessor} instance depending on jar type and processing mode. */ public class JarProcessors { private static String SPRING_BOOT = "spring-boot"; private static String STANDARD = "standard"; private static Integer VERSION_NOT_FOUND = 0; /** * Cr...
@@ -38,6 +44,15 @@ public static JarProcessor from( Path jarPath, TempDirectoryProvider temporaryDirectoryProvider, ProcessingMode mode) throws IOException { + Integer jarJavaVersion = getJavaMajorVersion(jarPath); + if (jarJavaVersion > 11) { + throw new IllegalStateException( + "T...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java
26
Java
0.571
question
211
51
51
false
Build Failure if JAR requires Java >11
2,988
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java PR Title: Build Failure if JAR requires Java >11 BEFORE CODE: /** Class to create a {@link JarProcessor} instance depending on jar type and processing mode. */ public class JarProcesso...
How about this? The input JAR (jarPath) is compiled with Java x, but the default base image only supports versions up to Java 11. Specify a custom base image with `--base-image` (if this is the right option).
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* @param jarPath path to the jar * @return the jar type * @throws IOException if I/O error occurs when opening the file */ private static String determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { if (jarFile.getEntry("BOOT-INF") != null) {...
I realized that using .nextElement() results in a `NoSuchElementException` if there are no more elements - this would cause an issue if an empty jar was passed in.
* @throws IOException if I/O error occurs when opening the file */ private static String determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { if (jarFile.getEntry("BOOT-INF") != null) { return SPRING_BOOT; } return STANDARD; ...
@@ -65,4 +84,41 @@ private static String determineJarType(Path jarPath) throws IOException { return STANDARD; } } + + /** + * Determines the java version of JAR. Derives the version from the first .class file it finds in + * the JAR. + * + * @param jarPath path to the jar + * @return java vers...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java
26
Java
0.714
suggestion
163
51
49
false
Build Failure if JAR requires Java >11
2,988
GoogleContainerTools/jib
11,032
Java
mpeddada1
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java PR Title: Build Failure if JAR requires Java >11 BEFORE CODE: * @param jarPath path to the jar * @return the jar type * @throws IOException if I/O error occurs when opening the...
I realized that using .nextElement() results in a `NoSuchElementException` if there are no more elements - this would cause an issue if an empty jar was passed in.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* 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 com.google.cloud.tools.jib.cli.jar; import com.google.cl...
I'm fine just using the number 0 in the test. Actually, the test can verify the literal (`assertThat(version).isEqualTo(0)`).
* 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 com.google.cloud.tools.jib.cli.jar; import com.google.cl...
@@ -17,20 +17,23 @@ package com.google.cloud.tools.jib.cli.jar; import com.google.cloud.tools.jib.filesystem.TempDirectoryProvider; +import com.google.common.annotations.VisibleForTesting; import java.io.DataInputStream; import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; import ja...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java
26
Java
0.5
suggestion
125
51
51
false
Build Failure if JAR requires Java >11
2,988
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java PR Title: Build Failure if JAR requires Java >11 BEFORE CODE: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, eithe...
I'm fine just using the number 0 in the test. Actually, the test can verify the literal (`assertThat(version).isEqualTo(0)`).
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
JarProcessors.from(jarPath, mockTemporaryDirectoryProvider, ProcessingMode.packaged); Mockito.verifyNoInteractions(mockTemporaryDirectoryProvider); assertThat(processor).isInstanceOf(SpringBootPackagedProcessor.class); } @Test public void testFrom_springBootExploded() throws IOException, URISynta...
```suggestion .startsWith("The input JAR (" + jarPath + ") is compiled with Java 14"); ```
JarProcessors.from(jarPath, mockTemporaryDirectoryProvider, ProcessingMode.packaged); Mockito.verifyNoInteractions(mockTemporaryDirectoryProvider); assertThat(processor).isInstanceOf(SpringBootPackagedProcessor.class); } @Test public void testFrom_springBootExploded() throws IOException, URISynta...
@@ -74,4 +76,25 @@ public void testFrom_springBootExploded() throws IOException, URISyntaxException Mockito.verify(mockTemporaryDirectoryProvider).newDirectory(); assertThat(processor).isInstanceOf(SpringBootExplodedProcessor.class); } + + @Test + public void testFrom_incompatibleBaseImage() throws URISy...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorsTest.java
26
Java
0.714
suggestion
100
36
36
false
Build Failure if JAR requires Java >11
2,988
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorsTest.java PR Title: Build Failure if JAR requires Java >11 BEFORE CODE: JarProcessors.from(jarPath, mockTemporaryDirectoryProvider, ProcessingMode.packaged); Mockito.verifyNoInter...
```suggestion .startsWith("The input JAR (" + jarPath + ") is compiled with Java 14"); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@Test public void testFrom_springBootExploded() throws IOException, URISyntaxException { Path jarPath = Paths.get(Resources.getResource(SPRING_BOOT).toURI()); JarProcessor processor = JarProcessors.from(jarPath, mockTemporaryDirectoryProvider, ProcessingMode.exploded); Mockito.verify(mockTempor...
```suggestion public void testGetJavaMajorVersion_versionNotFound() throws URISyntaxException, IOException { ```
@Test public void testFrom_springBootExploded() throws IOException, URISyntaxException { Path jarPath = Paths.get(Resources.getResource(SPRING_BOOT).toURI()); JarProcessor processor = JarProcessors.from(jarPath, mockTemporaryDirectoryProvider, ProcessingMode.exploded); Mockito.verify(mockTempor...
@@ -74,4 +76,25 @@ public void testFrom_springBootExploded() throws IOException, URISyntaxException Mockito.verify(mockTemporaryDirectoryProvider).newDirectory(); assertThat(processor).isInstanceOf(SpringBootExplodedProcessor.class); } + + @Test + public void testFrom_incompatibleBaseImage() throws URISy...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorsTest.java
26
Java
0.857
suggestion
116
32
32
false
Build Failure if JAR requires Java >11
2,988
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorsTest.java PR Title: Build Failure if JAR requires Java >11 BEFORE CODE: @Test public void testFrom_springBootExploded() throws IOException, URISyntaxException { Path jarPath = Paths....
```suggestion public void testGetJavaMajorVersion_versionNotFound() throws URISyntaxException, IOException { ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} /** * Gets whether or not to force caching the base images. * * @return {@code true} if the user wants to force the build to always pull the image layers. */ public boolean getAlwaysCacheBaseImage() { return alwaysCacheBaseImage; } /** * Gets the configurations for building the layers. ...
How about using `ImmutableListMultimap` instead of `ImmutableMap<String, ImmutableList<String>>` here?
* * @return {@code true} if the user wants to force the build to always pull the image layers. */ public boolean getAlwaysCacheBaseImage() { return alwaysCacheBaseImage; } /** * Gets the configurations for building the layers. * * @return the list of layer configurations */ public Immu...
@@ -498,6 +520,15 @@ public boolean getAlwaysCacheBaseImage() { return layerConfigurations; } + /** + * Gets the registry mirrors. + * + * @return the registry mirrors + */ + public ImmutableMap<String, ImmutableList<String>> getRegistryMirrors() {
jib-core/src/main/java/com/google/cloud/tools/jib/configuration/BuildContext.java
26
Java
0.571
question
104
51
51
false
Add registry mirror config to jib-core API and Jib global config
2,999
GoogleContainerTools/jib
11,032
Java
mpeddada1
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/configuration/BuildContext.java PR Title: Add registry mirror config to jib-core API and Jib global config BEFORE CODE: } /** * Gets whether or not to force caching the base images. * * @return {@c...
How about using `ImmutableListMultimap` instead of `ImmutableMap<String, ImmutableList<String>>` here?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
ImageConfiguration.builder(Mockito.mock(ImageReference.class)).build()) .setTargetImageConfiguration( ImageConfiguration.builder(Mockito.mock(ImageReference.class)).build()) .setContainerConfiguration(ContainerConfiguration.builder().build()) .setBaseImageLayersCacheDirec...
```suggestion ImmutableSet<Port> expectedExposedPorts = ImmutableSet.of(Port.tcp(1000), Port.tcp(2000)); ```
.setBaseImageConfiguration( ImageConfiguration.builder(Mockito.mock(ImageReference.class)).build()) .setTargetImageConfiguration( ImageConfiguration.builder(Mockito.mock(ImageReference.class)).build()) .setContainerConfiguration(ContainerConfiguration.builder().build()) ...
@@ -83,7 +84,7 @@ public void testBuilder() throws Exception { List<String> expectedEntrypoint = Arrays.asList("some", "entrypoint"); List<String> expectedProgramArguments = Arrays.asList("arg1", "arg2"); Map<String, String> expectedEnvironment = ImmutableMap.of("key", "value"); - ImmutableSet<Port> e...
jib-core/src/test/java/com/google/cloud/tools/jib/configuration/BuildContextTest.java
26
Java
0.714
suggestion
114
51
51
false
Add registry mirror config to jib-core API and Jib global config
2,999
GoogleContainerTools/jib
11,032
Java
mpeddada1
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/test/java/com/google/cloud/tools/jib/configuration/BuildContextTest.java PR Title: Add registry mirror config to jib-core API and Jib global config BEFORE CODE: ImageConfiguration.builder(Mockito.mock(ImageReference.class)).build()) ...
```suggestion ImmutableSet<Port> expectedExposedPorts = ImmutableSet.of(Port.tcp(1000), Port.tcp(2000)); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return this; } /** * Controls the optimization which skips downloading base image layers that exist in a target * registry. If the user does not set this property, then read as false. * * @param alwaysCacheBaseImage if {@code true}, base image layers are always pulled and cached. If * {@code...
Naming wise, isn't this more "addRegistryMirrors" rather than "withRegistryMirrors"?
return this; } /** * Controls the optimization which skips downloading base image layers that exist in a target * registry. If the user does not set this property, then read as false. * * @param alwaysCacheBaseImage if {@code true}, base image layers are always pulled and cached. If * {@code...
@@ -303,8 +309,25 @@ public Containerizer setAlwaysCacheBaseImage(boolean alwaysCacheBaseImage) { return this; } + /** + * Sets mirrors for a base image registry. Jib will try its mirrors in the given order before + * finally trying the registry. + * + * @param registry base image registry for which ...
jib-core/src/main/java/com/google/cloud/tools/jib/api/Containerizer.java
26
Java
0.214
question
84
51
51
false
Add registry mirror config to jib-core API and Jib global config
2,999
GoogleContainerTools/jib
11,032
Java
loosebazooka
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/api/Containerizer.java PR Title: Add registry mirror config to jib-core API and Jib global config BEFORE CODE: return this; } /** * Controls the optimization which skips downloading base image layers...
Naming wise, isn't this more "addRegistryMirrors" rather than "withRegistryMirrors"?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@Option(option = "image", description = "The image reference for the target image") public void setTargetImage(String targetImage) { Preconditions.checkNotNull(jibExtension).getTo().setImage(targetImage); } /** * Task Action, builds an image to remote registry. * * @throws IOException if an error ...
Should this change be rebased in?
public void setTargetImage(String targetImage) { Preconditions.checkNotNull(jibExtension).getTo().setImage(targetImage); } /** * Task Action, builds an image to remote registry. * * @throws IOException if an error occurs creating the jib runner * @throws BuildStepsExecutionException if an error o...
@@ -81,21 +83,24 @@ public void setTargetImage(String targetImage) { * @throws BuildStepsExecutionException if an error occurs while executing build steps * @throws CacheDirectoryCreationException if a new cache directory could not be created * @throws MainClassInferenceException if a main class could not b...
jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/BuildImageTask.java
26
Java
0.143
question
33
51
51
false
Add registry mirror config to jib-core API and Jib global config
2,999
GoogleContainerTools/jib
11,032
Java
loosebazooka
chanseokoh
Review this pull request change. Language: Java File: jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/BuildImageTask.java PR Title: Add registry mirror config to jib-core API and Jib global config BEFORE CODE: @Option(option = "image", description = "The image reference for the target image") ...
Should this change be rebased in?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Assume.assumeTrue(System.getProperty("os.name").startsWith("Windows")); Path archive = Paths.get(Resources.getResource("plugins-common/test-archives/zip-slip-win.zip").toURI()); verifyZipSlipSafe(archive); } @Test public void testZipSlipVulnerability_unix() throws URISyntaxException { As...
I think, in this case, we should just have these values as constants that we know. Manually look in the zip and grab the values, and use those here. That will help us determine if some other part of the machinery breaks (like getLastModifiedTime).
public void testZipSlipVulnerability_windows() throws URISyntaxException { Assume.assumeTrue(System.getProperty("os.name").startsWith("Windows")); Path archive = Paths.get(Resources.getResource("plugins-common/test-archives/zip-slip-win.zip").toURI()); verifyZipSlipSafe(archive); } @Test p...
@@ -66,6 +70,28 @@ public void testZipSlipVulnerability_unix() throws URISyntaxException { verifyZipSlipSafe(archive); } + @Test + public void testUnzip_modificationTimePreserved() throws URISyntaxException, IOException { + Path destination = tempFolder.getRoot().toPath(); + Path archive = + Pa...
jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/ZipUtilTest.java
26
Java
0.5
suggestion
247
51
51
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
loosebazooka
mpeddada1
Review this pull request change. Language: Java File: jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/ZipUtilTest.java PR Title: Preserve modification time after unzipping file BEFORE CODE: Assume.assumeTrue(System.getProperty("os.name").startsWith("Windows")); Path archive = ...
I think, in this case, we should just have these values as constants that we know. Manually look in the zip and grab the values, and use those here. That will help us determine if some other part of the machinery breaks (like getLastModifiedTime).
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
public static void unzip(Path archive, Path destination) throws IOException { String canonicalDestination = destination.toFile().getCanonicalPath(); try (InputStream fileIn = new BufferedInputStream(Files.newInputStream(archive)); ZipInputStream zipIn = new ZipInputStream(fileIn)) { for (ZipEn...
Maybe we can even set the time when calling `createDirectories()` or `newOutputStream()` through `FileAttribute`? If that's possible, we can reduce two IO operations into one. Actually, it is necessary if `createDirectories()` creates multiple directories?
* @param archive zip archive to unzip * @param destination target root for unzipping * @throws IOException when I/O error occurs */ public static void unzip(Path archive, Path destination) throws IOException { unzip(archive, destination, false); } /** * Unzips {@code archive} into {@code desti...
@@ -63,6 +63,7 @@ public static void unzip(Path archive, Path destination) throws IOException { ByteStreams.copy(zipIn, out); } } + Files.setLastModifiedTime(entryPath, entry.getLastModifiedTime());
jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/ZipUtil.java
26
Java
0.571
question
256
31
51
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/ZipUtil.java PR Title: Preserve modification time after unzipping file BEFORE CODE: public static void unzip(Path archive, Path destination) throws IOException { String canonicalDes...
Maybe we can even set the time when calling `createDirectories()` or `newOutputStream()` through `FileAttribute`? If that's possible, we can reduce two IO operations into one. Actually, it is necessary if `createDirectories()` creates multiple directories?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} if (entry.isDirectory()) { Files.createDirectories(entryPath); } else { if (entryPath.getParent() != null) { Files.createDirectories(entryPath.getParent()); } if (entry.isSymbolicLink()) { Files.createSymbolicLink(entryPath, Path...
I don't have confidence if this computation guarantees reconstructing the original path. (Path computation is difficult and depends on many factors. Honestly I don't know what `toRealPath()` does honestly, its Javadoc also says "the precise definition of this method is implementation dependent.") I also don't really li...
public static void extract(Path source, Path destination, boolean enableReproducibleTimestamps) throws IOException { if (enableReproducibleTimestamps && Files.isDirectory(destination) && destination.toFile().list().length != 0) { throw new IllegalStateException( "Cannot enabl...
@@ -72,6 +74,18 @@ public static void extract(Path source, Path destination) throws IOException { } } } + + // Preserve source modification timestamps of files. If the entry is a symbolic link then set + // it's modification time to that of the target file. + for (TarArchiveEnt...
jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java
26
Java
0.571
question
409
33
51
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java PR Title: Preserve modification time after unzipping file BEFORE CODE: } if (entry.isDirectory()) { Files.createDirectories(entryPath); } else { i...
I don't have confidence if this computation guarantees reconstructing the original path. (Path computation is difficult and depends on many factors. Honestly I don't know what `toRealPath()` does honestly, its Javadoc also says "the precise definition of this method is implementation dependent.") I also don't really li...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import java.io.InputStream; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.FileTime; import java.util.HashMap; import java.util.Map; import org.apache.commons.compress.archivers.tar.TarArchiveEntry; import org.apache.commons...
This gives me a warning. ```suggestion Map<TarArchiveEntry, FileTime> modificationTimeMap = new HashMap<>(); ```
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.FileTime; import java.util.ArrayList; import java.util.List; import org.apache.commons.compress.archivers.tar.TarArchiveE...
@@ -41,21 +44,20 @@ */ public static void extract(Path source, Path destination) throws IOException { String canonicalDestination = destination.toFile().getCanonicalPath(); - try (InputStream in = new BufferedInputStream(Files.newInputStream(source)); TarArchiveInputStream tarArchiveInputStrea...
jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java
26
Java
0.714
suggestion
123
51
51
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java PR Title: Preserve modification time after unzipping file BEFORE CODE: import java.io.InputStream; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; import ...
This gives me a warning. ```suggestion Map<TarArchiveEntry, FileTime> modificationTimeMap = new HashMap<>(); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} if (entry.isDirectory()) { Files.createDirectories(entryPath); } else { if (entryPath.getParent() != null) { Files.createDirectories(entryPath.getParent()); } if (entry.isSymbolicLink()) { Files.createSymbolicLink(entryPath, Path...
`modificationTimeMap.get(targetRelativePath)` doesn't make sense. The key should be of type `TarArchiveEntry` but here it's `Path`. How can this even work?
public static void extract(Path source, Path destination, boolean enableReproducibleTimestamps) throws IOException { if (enableReproducibleTimestamps && Files.isDirectory(destination) && destination.toFile().list().length != 0) { throw new IllegalStateException( "Cannot enabl...
@@ -72,6 +74,18 @@ public static void extract(Path source, Path destination) throws IOException { } } } + + // Preserve source modification timestamps of files. If the entry is a symbolic link then set + // it's modification time to that of the target file. + for (TarArchiveEnt...
jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java
26
Java
0.714
question
155
33
51
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java PR Title: Preserve modification time after unzipping file BEFORE CODE: } if (entry.isDirectory()) { Files.createDirectories(entryPath); } else { i...
`modificationTimeMap.get(targetRelativePath)` doesn't make sense. The key should be of type `TarArchiveEntry` but here it's `Path`. How can this even work?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Path source = Paths.get(Resources.getResource("core/extract.tar").toURI()); Path destination = temporaryFolder.getRoot().toPath(); TarExtractor.extract(source, destination); assertThat(Files.getLastModifiedTime(destination.resolve("file A"))) .isEqualTo(FileTime.from(Instant.parse("2019-08-01T...
This seems weird. The timestamp of a symlink should be different from that of its target.
assertThat(Files.getLastModifiedTime(destination.resolve("file A"))) .isEqualTo(FileTime.from(Instant.parse("2019-08-01T16:13:09Z"))); assertThat(Files.getLastModifiedTime(destination.resolve("file B"))) .isEqualTo(FileTime.from(Instant.parse("2019-08-01T16:12:00Z"))); assertThat(Files.getLa...
@@ -79,4 +89,64 @@ public void testExtract_symlinks() throws URISyntaxException, IOException { Assert.assertTrue(Files.isSymbolicLink(destination.resolve("directory-symlink"))); Assert.assertTrue(Files.isSymbolicLink(destination.resolve("directory1/file-symlink"))); } + + @Test + public void testExtract_...
jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarExtractorTest.java
26
Java
0.286
suggestion
89
51
44
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarExtractorTest.java PR Title: Preserve modification time after unzipping file BEFORE CODE: Path source = Paths.get(Resources.getResource("core/extract.tar").toURI()); Path destination = temporaryFol...
This seems weird. The timestamp of a symlink should be different from that of its target.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
entry = tarArchiveInputStream.getNextTarEntry()) { entries.add(entry); Path entryPath = destination.resolve(entry.getName()); String canonicalTarget = entryPath.toFile().getCanonicalPath(); if (!canonicalTarget.startsWith(canonicalDestination + File.separator)) { Str...
Can we move this out of the `try` block?
* @param destination the output directory * @param enableReproducibleTimestamps whether or not reproducible timestamps should be used * @throws IOException if extraction fails * @throws IllegalStateException when reproducible timestamps are enabled but the target root used * for extracting the tar co...
@@ -72,6 +76,18 @@ public static void extract(Path source, Path destination) throws IOException { } } } + preserveModificationTimes(destination, entries);
jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java
26
Java
0.286
refactor
40
41
51
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java PR Title: Preserve modification time after unzipping file BEFORE CODE: entry = tarArchiveInputStream.getNextTarEntry()) { entries.add(entry); Path entryPath = desti...
Can we move this out of the `try` block?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} if (entry.isDirectory()) { Files.createDirectories(entryPath); } else { if (entryPath.getParent() != null) { Files.createDirectories(entryPath.getParent()); } if (entry.isSymbolicLink()) { Files.createSymbolicLink(entryPath, Path...
As this is an unconventional behavior, I think we should apply this only when enabled. `TarExtractor` and `ZipUtil` are deemed general and isolated. And maybe we can create an instance of `FileTime.fromMillis(1000L)` (I think it's equivalent) at the start of the method and avoid re-creating the instance everytime.
if (enableReproducibleTimestamps && Files.isDirectory(destination) && destination.toFile().list().length != 0) { throw new IllegalStateException( "Cannot enable reproducible timestamps. They can only be enabled when the target root doesn't exist or is an empty directory"); } ...
@@ -72,6 +76,18 @@ public static void extract(Path source, Path destination) throws IOException { } } } + preserveModificationTimes(destination, entries); + } + } + + private static void preserveModificationTimes(Path destination, List<TarArchiveEntry> entries) + throws IOExcep...
jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java
26
Java
0.643
refactor
318
33
51
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java PR Title: Preserve modification time after unzipping file BEFORE CODE: } if (entry.isDirectory()) { Files.createDirectories(entryPath); } else { i...
As this is an unconventional behavior, I think we should apply this only when enabled. `TarExtractor` and `ZipUtil` are deemed general and isolated. And maybe we can create an instance of `FileTime.fromMillis(1000L)` (I think it's equivalent) at the start of the method and avoid re-creating the instance everytime.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
package com.google.cloud.tools.jib.plugins.common; import static com.google.common.truth.Truth.assertThat; import com.google.api.client.testing.http.FixedClock; import com.google.common.io.Resources; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path;...
I don't think this is used? And not sure if `FixedCLock` from `com.google.api.client.testing.http` is a public API.
package com.google.cloud.tools.jib.plugins.common; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertThrows; import com.google.common.io.Resources; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; import j...
@@ -34,6 +39,7 @@ public class ZipUtilTest { @Rule public final TemporaryFolder tempFolder = new TemporaryFolder(); + public final FixedClock clock = new FixedClock();
jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/ZipUtilTest.java
26
Java
0.571
suggestion
115
51
51
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/ZipUtilTest.java PR Title: Preserve modification time after unzipping file BEFORE CODE: package com.google.cloud.tools.jib.plugins.common; import static com.google.common.truth.Truth.ass...
I don't think this is used? And not sure if `FixedCLock` from `com.google.api.client.testing.http` is a public API.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
String canonicalDestination = destination.toFile().getCanonicalPath(); try (InputStream fileIn = new BufferedInputStream(Files.newInputStream(archive)); ZipInputStream zipIn = new ZipInputStream(fileIn)) { List<ZipEntry> entries = new ArrayList<>(); for (ZipEntry entry = zipIn.getNextEntry(...
This line should be removed, right?
} /** * Unzips {@code archive} into {@code destination}. * * @param archive zip archive to unzip * @param destination target root for unzipping * @param enableReproducibleTimestamps whether or not reproducible timestamps should be used * @throws IOException when I/O error occurs * @throws Ille...
@@ -63,7 +69,19 @@ public static void unzip(Path archive, Path destination) throws IOException { ByteStreams.copy(zipIn, out); } } + Files.setLastModifiedTime(entryPath, entry.getLastModifiedTime());
jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/ZipUtil.java
26
Java
0.143
question
35
42
51
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/ZipUtil.java PR Title: Preserve modification time after unzipping file BEFORE CODE: String canonicalDestination = destination.toFile().getCanonicalPath(); try (InputStream fileIn...
This line should be removed, right?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Assert.assertTrue(Files.isDirectory(destination.resolve("directory1"))); Assert.assertTrue(Files.isDirectory(destination.resolve("directory2"))); Assert.assertTrue(Files.isRegularFile(destination.resolve("directory2/regular"))); Assert.assertTrue(Files.isSymbolicLink(destination.resolve("directory-syml...
Just FYI, no need to change: in *tests*, we're tolerant in writing `destination.resolve("folder/nested folder/file C"`) if it can simplify code or improve readability.
TarExtractor.extract(source, destination); Assert.assertTrue(Files.isDirectory(destination.resolve("directory1"))); Assert.assertTrue(Files.isDirectory(destination.resolve("directory2"))); Assert.assertTrue(Files.isRegularFile(destination.resolve("directory2/regular"))); Assert.assertTrue(Files.isS...
@@ -79,4 +83,53 @@ public void testExtract_symlinks() throws URISyntaxException, IOException { Assert.assertTrue(Files.isSymbolicLink(destination.resolve("directory-symlink"))); Assert.assertTrue(Files.isSymbolicLink(destination.resolve("directory1/file-symlink"))); } + + @Test + public void testExtract_...
jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarExtractorTest.java
26
Java
0.571
refactor
167
51
51
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarExtractorTest.java PR Title: Preserve modification time after unzipping file BEFORE CODE: Assert.assertTrue(Files.isDirectory(destination.resolve("directory1"))); Assert.assertTrue(Files.isDirecto...
Just FYI, no need to change: in *tests*, we're tolerant in writing `destination.resolve("folder/nested folder/file C"`) if it can simplify code or improve readability.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
try (OutputStream out = new BufferedOutputStream(Files.newOutputStream(entryPath))) { ByteStreams.copy(tarArchiveInputStream, out); } } } } } preserveModificationTimes(destination, entries, enableReproducibleTimestamps); } /** * Preserve modi...
This can never be true. We already extracted files into `destination`. And the check we talked about was only for when `enableReproducibleTimestamps` is true. That is, if it's enabled, we should proceed only when either 1) `destination` doesn't exist; or 2) `destination` exists but it's empty. (Or, I'm fine with the...
} else { if (entryPath.getParent() != null) { Files.createDirectories(entryPath.getParent()); } if (entry.isSymbolicLink()) { Files.createSymbolicLink(entryPath, Paths.get(entry.getLinkName())); } else { try (OutputStream out = new Buf...
@@ -73,5 +89,34 @@ public static void extract(Path source, Path destination) throws IOException { } } } + preserveModificationTimes(destination, entries, enableReproducibleTimestamps); + } + + /** + * Preserve modification time of files and directories in a tar file. If a directory is not an...
jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java
26
Java
0.643
bug
598
39
50
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java PR Title: Preserve modification time after unzipping file BEFORE CODE: try (OutputStream out = new BufferedOutputStream(Files.newOutputStream(entryPath))) { ByteStr...
This can never be true. We already extracted files into `destination`. And the check we talked about was only for when `enableReproducibleTimestamps` is true. That is, if it's enabled, we should proceed only when either 1) `destination` doesn't exist; or 2) `destination` exists but it's empty. (Or, I'm fine with the...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/** * Extracts a tarball to the specified destination. * * @param source the tarball to extract * @param destination the output directory * @throws IOException if extraction fails */ public static void extract(Path source, Path destination) throws IOException { extract(source, destination, fa...
Let's do this computation only when necessary. That is, doing this inside the `if` statement. Perhaps ```java if (enableReproducibleTimestamps && Files.isDirectory(destination) && destination.toFile().list.length() != 0) { throw new ... } ``` (`isDirectory()` implies `exists()`.)
/** * Extracts a tarball to the specified destination. * * @param source the tarball to extract * @param destination the output directory * @throws IOException if extraction fails */ public static void extract(Path source, Path destination) throws IOException { extract(source, destination, fa...
@@ -40,22 +44,42 @@ * @throws IOException if extraction fails */ public static void extract(Path source, Path destination) throws IOException { - String canonicalDestination = destination.toFile().getCanonicalPath(); + extract(source, destination, false); + } + /** + * Extracts a tarball to the s...
jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java
26
Java
0.786
suggestion
288
51
51
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java PR Title: Preserve modification time after unzipping file BEFORE CODE: /** * Extracts a tarball to the specified destination. * * @param source the tarball to extract * @param...
Let's do this computation only when necessary. That is, doing this inside the `if` statement. Perhaps ```java if (enableReproducibleTimestamps && Files.isDirectory(destination) && destination.toFile().list.length() != 0) { throw new ... } ``` (`isDirectory()` implies `exists()`.)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* * @param source the tarball to extract * @param destination the output directory * @throws IOException if extraction fails */ public static void extract(Path source, Path destination) throws IOException { extract(source, destination, false); } /** * Extracts a tarball to the specified des...
the target root does not exist or is an empty directory
* * @param source the tarball to extract * @param destination the output directory * @throws IOException if extraction fails */ public static void extract(Path source, Path destination) throws IOException { extract(source, destination, false); } /** * Extracts a tarball to the specified des...
@@ -40,22 +44,42 @@ * @throws IOException if extraction fails */ public static void extract(Path source, Path destination) throws IOException { - String canonicalDestination = destination.toFile().getCanonicalPath(); + extract(source, destination, false); + } + /** + * Extracts a tarball to the s...
jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java
26
Java
0.214
suggestion
55
51
51
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java PR Title: Preserve modification time after unzipping file BEFORE CODE: * * @param source the tarball to extract * @param destination the output directory * @throws IOException if...
the target root does not exist or is an empty directory
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
String offender = entry.getName() + " from " + source; throw new IOException("Blocked unzipping files outside destination: " + offender); } if (entry.isDirectory()) { Files.createDirectories(entryPath); } else { if (entryPath.getParent() != null) { ...
```suggestion * entry in the tar file and reproducible timestamps are enabled then its modification timestamp ```
String offender = entry.getName() + " from " + source; throw new IOException("Blocked unzipping files outside destination: " + offender); } if (entry.isDirectory()) { Files.createDirectories(entryPath); } else { if (entryPath.getParent() != null) { ...
@@ -73,5 +97,31 @@ public static void extract(Path source, Path destination) throws IOException { } } } + preserveModificationTimes(destination, entries, enableReproducibleTimestamps); + } + + /** + * Preserve modification time of files and directories in a tar file. If a directory is not an...
jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java
26
Java
0.714
suggestion
118
49
51
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java PR Title: Preserve modification time after unzipping file BEFORE CODE: String offender = entry.getName() + " from " + source; throw new IOException("Blocked unzipping fil...
```suggestion * entry in the tar file and reproducible timestamps are enabled then its modification timestamp ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
ByteStreams.copy(tarArchiveInputStream, out); } } } } } preserveModificationTimes(destination, entries, enableReproducibleTimestamps); } /** * Preserve modification time of files and directories in a tar file. If a directory is not an * entry in the t...
nit ```suggestion .filter(Files::isDirectory) ```
ByteStreams.copy(tarArchiveInputStream, out); } } } } } preserveModificationTimes(destination, entries, enableReproducibleTimestamps); } /** * Preserve modification timestamps of files and directories in a tar file. If a directory is not * an entry in...
@@ -73,5 +97,31 @@ public static void extract(Path source, Path destination) throws IOException { } } } + preserveModificationTimes(destination, entries, enableReproducibleTimestamps); + } + + /** + * Preserve modification time of files and directories in a tar file. If a directory is not an...
jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java
26
Java
0.571
suggestion
62
35
41
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java PR Title: Preserve modification time after unzipping file BEFORE CODE: ByteStreams.copy(tarArchiveInputStream, out); } } } } } prese...
nit ```suggestion .filter(Files::isDirectory) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Path destination = temporaryFolder.getRoot().toPath(); TarExtractor.extract(source, destination, true); assertThat(Files.getLastModifiedTime(destination.resolve("level-1"))) .isEqualTo(FileTime.fromMillis(1000L)); assertThat(Files.getLastModifiedTime(destination.resolve("level-1/level-2"))) ...
Let's assert the exception message too, since anyone can throw the very common `IllegalStateException`.
Path destination = temporaryFolder.getRoot().toPath(); TarExtractor.extract(source, destination, true); assertThat(Files.getLastModifiedTime(destination.resolve("level-1"))) .isEqualTo(FileTime.fromMillis(1000L)); assertThat(Files.getLastModifiedTime(destination.resolve("level-1/level-2"))) ...
@@ -79,4 +84,52 @@ public void testExtract_symlinks() throws URISyntaxException, IOException { Assert.assertTrue(Files.isSymbolicLink(destination.resolve("directory-symlink"))); Assert.assertTrue(Files.isSymbolicLink(destination.resolve("directory1/file-symlink"))); } + + @Test + public void testExtract_...
jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarExtractorTest.java
26
Java
0.643
suggestion
103
26
28
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarExtractorTest.java PR Title: Preserve modification time after unzipping file BEFORE CODE: Path destination = temporaryFolder.getRoot().toPath(); TarExtractor.extract(source, destination, true); ...
Let's assert the exception message too, since anyone can throw the very common `IllegalStateException`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
.isEqualTo(FileTime.from(Instant.parse("2019-08-01T16:13:30Z"))); assertThat(Files.getLastModifiedTime(destination.resolve("folder/nested folder/file C"))) .isEqualTo(FileTime.from(Instant.parse("2019-08-01T16:12:21Z"))); } @Test public void testExtract_reproducibleTimestampsEnabled() throws ...
```suggestion public void testExtract_reproducibleTimestampsEnabled_destinationNotEmpty() throws IOException { ```
.isEqualTo(FileTime.from(Instant.parse("2019-08-01T16:13:30Z"))); assertThat(Files.getLastModifiedTime(destination.resolve("folder/nested folder/file C"))) .isEqualTo(FileTime.from(Instant.parse("2019-08-01T16:12:21Z"))); } @Test public void testExtract_reproducibleTimestampsEnabled() throws ...
@@ -79,4 +84,52 @@ public void testExtract_symlinks() throws URISyntaxException, IOException { Assert.assertTrue(Files.isSymbolicLink(destination.resolve("directory-symlink"))); Assert.assertTrue(Files.isSymbolicLink(destination.resolve("directory1/file-symlink"))); } + + @Test + public void testExtract_...
jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarExtractorTest.java
26
Java
0.929
refactor
118
35
37
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarExtractorTest.java PR Title: Preserve modification time after unzipping file BEFORE CODE: .isEqualTo(FileTime.from(Instant.parse("2019-08-01T16:13:30Z"))); assertThat(Files.getLastModifiedTime(...
```suggestion public void testExtract_reproducibleTimestampsEnabled_destinationNotEmpty() throws IOException { ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
.isEqualTo(FileTime.from(Instant.parse("2019-08-01T16:12:21Z"))); } @Test public void testExtract_reproducibleTimestampsEnabled() throws URISyntaxException, IOException { // The tarfile has only level1/level2/level3/file.txt packaged Path source = Paths.get(Resources.getResource("core/tarfile-onl...
FYI, `temporaryFolder.newFile()` should also work.
.isEqualTo(FileTime.from(Instant.parse("2019-08-01T16:12:21Z"))); } @Test public void testExtract_reproducibleTimestampsEnabled() throws URISyntaxException, IOException { // The tarfile has only level1/level2/level3/file.txt packaged Path source = Paths.get(Resources.getResource("core/tarfile-onl...
@@ -79,4 +84,52 @@ public void testExtract_symlinks() throws URISyntaxException, IOException { Assert.assertTrue(Files.isSymbolicLink(destination.resolve("directory-symlink"))); Assert.assertTrue(Files.isSymbolicLink(destination.resolve("directory1/file-symlink"))); } + + @Test + public void testExtract_...
jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarExtractorTest.java
26
Java
0.429
suggestion
50
33
35
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarExtractorTest.java PR Title: Preserve modification time after unzipping file BEFORE CODE: .isEqualTo(FileTime.from(Instant.parse("2019-08-01T16:12:21Z"))); } @Test public void testExtract_re...
FYI, `temporaryFolder.newFile()` should also work.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} } preserveModificationTimes(destination, entries, enableReproducibleTimestamps); } /** * Preserve modification time of files and directories in a tar file. If a directory is not an * entry in the tar file and reproducible timestamps are enabled then its modification timestamp * is set to a...
Oh, shouldn't we check `entry` is not a symlink? I remember setting a timestamp throws an error if it's a symlink?
} } preserveModificationTimes(destination, entries, enableReproducibleTimestamps); } /** * Preserve modification timestamps of files and directories in a tar file. If a directory is not * an entry in the tar file and reproducible timestamps are enabled then its modification * timestamp is se...
@@ -73,5 +97,31 @@ public static void extract(Path source, Path destination) throws IOException { } } } + preserveModificationTimes(destination, entries, enableReproducibleTimestamps); + } + + /** + * Preserve modification time of files and directories in a tar file. If a directory is not an...
jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java
26
Java
0.714
question
114
31
37
false
Preserve modification time after unzipping file
3,008
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarExtractor.java PR Title: Preserve modification time after unzipping file BEFORE CODE: } } preserveModificationTimes(destination, entries, enableReproducibleTimestamps); } /** * Preser...
Oh, shouldn't we check `entry` is not a symlink? I remember setting a timestamp throws an error if it's a symlink?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* @param processor jar processor * @param jarOptions jar cli options * @param commonCliOptions common cli options * @param logger console logger * @return JibContainerBuilder * @throws IOException if I/O error occurs when opening the jar file or if temporary directory * provided doesn't exist ...
I think there might be some value in adding a warning when both entrypoint and jvmflags are set.
* @param processor jar processor * @param jarOptions jar cli options * @param commonCliOptions common cli options * @param logger console logger * @return JibContainerBuilder * @throws IOException if I/O error occurs when opening the jar file or if temporary directory * provided doesn't exist ...
@@ -58,8 +58,22 @@ public static JibContainerBuilder toJibContainerBuilder( : Jib.from("gcr.io/distroless/java-debian10:11"); List<FileEntriesLayer> layers = processor.createLayers(); - List<String> entrypoint = processor.computeEntrypoint(); - containerBuilder.setEntrypoint(entrypoint).setFil...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java
26
Java
0.214
suggestion
96
44
45
false
Add option to specify entrypoint
3,009
GoogleContainerTools/jib
11,032
Java
loosebazooka
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java PR Title: Add option to specify entrypoint BEFORE CODE: * @param processor jar processor * @param jarOptions jar cli options * @param commonCliOptions common cli options * @param...
I think there might be some value in adding a warning when both entrypoint and jvmflags are set.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@CommandLine.Option( names = {"-u", "--user"}, paramLabel = "<user>", description = "The user to run the container as, example: --user=myuser:mygroup.") @SuppressWarnings("NullAway.Init") // initialized by picocli private String user; @CommandLine.Option( names = {"--image-format"}, ...
Q: does picoCLI automatically take care of escaping for the split characters? For example, for `--program-args`, is there a way to include `,` in an argument?
names = {"-u", "--user"}, paramLabel = "<user>", description = "The user to run the container as, example: --user=myuser:mygroup.") @SuppressWarnings("NullAway.Init") // initialized by picocli private String user; @CommandLine.Option( names = {"--image-format"}, defaultValue = "Dock...
@@ -67,11 +78,80 @@ @CommandLine.Option( names = "--from", - paramLabel = "<from>", + paramLabel = "<base-image>", description = "The base image to use.") @SuppressWarnings("NullAway.Init") // initialized by picocli private String from; + @CommandLine.Option( + names = "--jvm-...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java
26
Java
0.5
question
159
51
51
false
Add option to specify entrypoint
3,009
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java PR Title: Add option to specify entrypoint BEFORE CODE: @CommandLine.Option( names = {"-u", "--user"}, paramLabel = "<user>", description = "The user to run the container as, exam...
Q: does picoCLI automatically take care of escaping for the split characters? For example, for `--program-args`, is there a way to include `,` in an argument?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
commonCliOptions.validate(); SingleThreadedExecutor executor = new SingleThreadedExecutor(); try (TempDirectoryProvider tempDirectoryProvider = new TempDirectoryProvider()) { ConsoleLogger logger = CliLogger.newLogger( commonCliOptions.getVerbosity(), commonCliO...
```suggestion logger.log(LogEvent.Level.WARN, "--jvm-flags is ignored when --entrypoint is specified"); ```
commonCliOptions.validate(); SingleThreadedExecutor executor = new SingleThreadedExecutor(); try (TempDirectoryProvider tempDirectoryProvider = new TempDirectoryProvider()) { ConsoleLogger logger = CliLogger.newLogger( commonCliOptions.getVerbosity(), commonCliO...
@@ -175,6 +183,9 @@ public Integer call() { + jarFile); return 1; } + if (!entrypoint.isEmpty() && !jvmFlags.isEmpty()) { + logger.log(LogEvent.Level.WARN, "--jvm-flag is ignored when --entrypoint is specified");
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java
26
Java
0.714
suggestion
117
51
51
false
Add option to specify entrypoint
3,009
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java PR Title: Add option to specify entrypoint BEFORE CODE: commonCliOptions.validate(); SingleThreadedExecutor executor = new SingleThreadedExecutor(); try (TempDirectoryProvider tempDirect...
```suggestion logger.log(LogEvent.Level.WARN, "--jvm-flags is ignored when --entrypoint is specified"); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
if (buildContext.isOffline()) { List<Image> images = getCachedBaseImages(); if (!images.isEmpty()) { return new ImagesAndRegistryClient(images, null); } throw new IOException( "Cannot run Jib in offline mode; " + imageReference + " not found in local Jib cache...
does this need to be in the try?
if (buildContext.isOffline()) { List<Image> images = getCachedBaseImages(); if (!images.isEmpty()) { return new ImagesAndRegistryClient(images, null); } throw new IOException( "Cannot run Jib in offline mode; " + imageReference + " not found in local Jib cache...
@@ -138,15 +138,16 @@ public ImagesAndRegistryClient call() } } - // First, try with no credentials. This works with public GCR images (but not Docker Hub). - // TODO: investigate if we should just pass credentials up front. However, this involves - // some risk. https://github.com/Goog...
jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStep.java
26
Java
0.071
question
36
51
51
false
Improve progress reporting in PullBaseImageStep
3,010
GoogleContainerTools/jib
11,032
Java
loosebazooka
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStep.java PR Title: Improve progress reporting in PullBaseImageStep BEFORE CODE: if (buildContext.isOffline()) { List<Image> images = getCachedBaseImages(); if (!i...
does this need to be in the try?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/** * Gets the configurations for building the layers. * * @return the list of layer configurations */ public ImmutableList<FileEntriesLayer> getLayerConfigurations() { return layerConfigurations; } /** * Gets the registry mirrors. * * @return the registry mirrors */ public Immuta...
should this javadoc now indicate that the serverUrl is derived from the baseimage configuration?
/** * Gets the configurations for building the layers. * * @return the list of layer configurations */ public ImmutableList<FileEntriesLayer> getLayerConfigurations() { return layerConfigurations; } /** * Gets the registry mirrors. * * @return the registry mirrors */ public Immuta...
@@ -532,7 +532,21 @@ public boolean getAlwaysCacheBaseImage() { * @return a new {@link RegistryClient.Factory} */ public RegistryClient.Factory newBaseImageRegistryClientFactory() { - return newRegistryClientFactory(baseImageConfiguration); + return newBaseImageRegistryClientFactory(baseImageConfigurat...
jib-core/src/main/java/com/google/cloud/tools/jib/configuration/BuildContext.java
26
Java
0.286
question
96
51
51
false
Add registry mirror support in Jib build plugins
3,011
GoogleContainerTools/jib
11,032
Java
loosebazooka
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/configuration/BuildContext.java PR Title: Add registry mirror support in Jib build plugins BEFORE CODE: /** * Gets the configurations for building the layers. * * @return the list of layer configuratio...
should this javadoc now indicate that the serverUrl is derived from the baseimage configuration?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2019 Google LLC. * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to...
if this is the expected log output ordering, I think it's a little confusing? I would expect it to be ``` trying quay.. failed to get from quay... trying gcr.. ```
BadContainerConfigurationFormatException, CacheCorruptedException, CredentialRetrievalException { Mockito.when(imageConfiguration.getImage()).thenReturn(ImageReference.parse("registry/repo")); Mockito.when(imageConfiguration.getImageRegistry()).thenReturn("registry"); Mockito.when(buildC...
@@ -409,4 +418,95 @@ public void testGetCachedBaseImages_v22ManifestListCached_onlyPlatforms() Assert.assertEquals(1, images.size()); Assert.assertEquals("target-user", images.get(0).getUser()); } + + @Test + public void testTryMirrors_noMatchingMirrors() + throws LayerCountMismatchException, BadCon...
jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStepTest.java
26
Java
0.714
bug
171
513
51
false
Add registry mirror support in Jib build plugins
3,011
GoogleContainerTools/jib
11,032
Java
loosebazooka
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStepTest.java PR Title: Add registry mirror support in Jib build plugins BEFORE CODE: /* * Copyright 2019 Google LLC. * * Licensed under the Apache License, Version 2.0 (the "License...
if this is the expected log output ordering, I think it's a little confusing? I would expect it to be ``` trying quay.. failed to get from quay... trying gcr.. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import com.google.cloud.tools.jib.image.json.V22ManifestListTemplate; import com.google.cloud.tools.jib.image.json.V22ManifestTemplate; import com.google.cloud.tools.jib.json.JsonTemplateMapper; import com.google.cloud.tools.jib.registry.ManifestAndDigest; import com.google.cloud.tools.jib.registry.RegistryClient; impo...
should there be a test for all registry mirrors failing and last resort is to use the original registry url?
import com.google.cloud.tools.jib.image.json.V22ManifestListTemplate; import com.google.cloud.tools.jib.image.json.V22ManifestTemplate; import com.google.cloud.tools.jib.json.JsonTemplateMapper; import com.google.cloud.tools.jib.registry.ManifestAndDigest; import com.google.cloud.tools.jib.registry.RegistryClient; impo...
@@ -62,8 +67,10 @@ public class PullBaseImageStepTest {
jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStepTest.java
26
Java
0.429
bug
108
51
51
false
Add registry mirror support in Jib build plugins
3,011
GoogleContainerTools/jib
11,032
Java
loosebazooka
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStepTest.java PR Title: Add registry mirror support in Jib build plugins BEFORE CODE: import com.google.cloud.tools.jib.image.json.V22ManifestListTemplate; import com.google.cloud.tools...
should there be a test for all registry mirrors failing and last resort is to use the original registry url?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
eventHandlers.dispatch( LogEvent.progress("Getting manifest for base image " + imageReference + "...")); if (buildContext.isOffline()) { List<Image> images = getCachedBaseImages(); if (!images.isEmpty()) { return new ImagesAndRegistryClient(images, null); } ...
could this message go in tryMirrors? with the name of the mirror that was successful?
eventHandlers.dispatch( LogEvent.progress("Getting manifest for base image " + imageReference + "...")); if (buildContext.isOffline()) { List<Image> images = getCachedBaseImages(); if (!images.isEmpty()) { return new ImagesAndRegistryClient(images, null); } ...
@@ -138,6 +140,13 @@ public ImagesAndRegistryClient call() } } + Optional<ImagesAndRegistryClient> mirrorPull = + tryMirrors(buildContext, progressDispatcher.newChildProducer()); + if (mirrorPull.isPresent()) {
jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStep.java
26
Java
0.286
question
85
51
51
false
Add registry mirror support in Jib build plugins
3,011
GoogleContainerTools/jib
11,032
Java
loosebazooka
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStep.java PR Title: Add registry mirror support in Jib build plugins BEFORE CODE: eventHandlers.dispatch( LogEvent.progress("Getting manifest for base image " + imageRef...
could this message go in tryMirrors? with the name of the mirror that was successful?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
description = "The context root directory of the build (ex: path/to/my/build/things)") @SuppressWarnings("NullAway.Init") // initialized by picocli Path contextRoot; @VisibleForTesting @CommandLine.Option( names = {"-b", "--build-file"}, paramLabel = "<build-file>", description = "The p...
Doesn't seem like it needs to be `public`. `@VisibleForTesting`?
description = "The context root directory of the build (ex: path/to/my/build/things)") @SuppressWarnings("NullAway.Init") // initialized by picocli Path contextRoot; @VisibleForTesting @CommandLine.Option( names = {"-b", "--build-file"}, paramLabel = "<build-file>", description = "The p...
@@ -71,21 +72,17 @@ "templating parameter to inject into build file, replace $${<name>} with <value> (repeatable)") private Map<String, String> templateParameters = Collections.emptyMap(); - public Path getContextRoot() { - return Verify.verifyNotNull(contextRoot); - } - /** * Returns a user...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Build.java
26
Java
0.357
question
64
51
51
false
Use correctly processed options in build command
3,019
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Build.java PR Title: Use correctly processed options in build command BEFORE CODE: description = "The context root directory of the build (ex: path/to/my/build/things)") @SuppressWarnings("NullAway.Ini...
Doesn't seem like it needs to be `public`. `@VisibleForTesting`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@Input boolean getAllowInsecureRegistries() { if (System.getProperty(PropertyNames.ALLOW_INSECURE_REGISTRIES) != null) { return Boolean.getBoolean(PropertyNames.ALLOW_INSECURE_REGISTRIES); } return allowInsecureRegistries.get(); } @Input @Optional public String getContainerizingMode() { ...
Thanks for your work! To make this consistent with the rest of the getters in this class, how about renaming this method `getConfigurationName()` and removing the getter above?
@Input boolean getAllowInsecureRegistries() { if (System.getProperty(PropertyNames.ALLOW_INSECURE_REGISTRIES) != null) { return Boolean.getBoolean(PropertyNames.ALLOW_INSECURE_REGISTRIES); } return allowInsecureRegistries.get(); } @Input @Optional public String getContainerizingMode() { ...
@@ -221,6 +227,17 @@ public String getContainerizingMode() { return property != null ? property : containerizingMode.get(); } + @Input + @Optional + public Property<String> getConfigurationName() { + return configurationName; + } + + public String readConfigurationName() { + String property = Syste...
jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibExtension.java
26
Java
0.5
question
176
33
38
false
Configurable gradle configurations
3,034
GoogleContainerTools/jib
11,032
Java
mpeddada1
cromefire
Review this pull request change. Language: Java File: jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibExtension.java PR Title: Configurable gradle configurations BEFORE CODE: @Input boolean getAllowInsecureRegistries() { if (System.getProperty(PropertyNames.ALLOW_INSECURE_REGISTRIES) !=...
Thanks for your work! To make this consistent with the rest of the getters in this class, how about renaming this method `getConfigurationName()` and removing the getter above?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@Nested @Optional public SkaffoldParameters getSkaffold() { return skaffold; } @Input boolean getAllowInsecureRegistries() { if (System.getProperty(PropertyNames.ALLOW_INSECURE_REGISTRIES) != null) { return Boolean.getBoolean(PropertyNames.ALLOW_INSECURE_REGISTRIES); } return allowIn...
our of curiosity, can we just set the property to the system property value here? ``` public Property<String> getConfigurationName() { String property = System.getProperty(PropertyNames.CONFIGURATION_NAME); if (property != null) { configurationName.set(property); } return configurationName; } ``` ...
@Nested @Optional public SkaffoldParameters getSkaffold() { return skaffold; } @Input boolean getAllowInsecureRegistries() { if (System.getProperty(PropertyNames.ALLOW_INSECURE_REGISTRIES) != null) { return Boolean.getBoolean(PropertyNames.ALLOW_INSECURE_REGISTRIES); } return allowIn...
@@ -221,6 +227,17 @@ public String getContainerizingMode() { return property != null ? property : containerizingMode.get(); } + @Input + @Optional + public Property<String> getConfigurationName() { + return configurationName;
jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibExtension.java
26
Java
1
suggestion
508
40
45
false
Configurable gradle configurations
3,034
GoogleContainerTools/jib
11,032
Java
loosebazooka
cromefire
Review this pull request change. Language: Java File: jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibExtension.java PR Title: Configurable gradle configurations BEFORE CODE: @Nested @Optional public SkaffoldParameters getSkaffold() { return skaffold; } @Input boolean getAllow...
our of curiosity, can we just set the property to the system property value here? ``` public Property<String> getConfigurationName() { String property = System.getProperty(PropertyNames.CONFIGURATION_NAME); if (property != null) { configurationName.set(property); } return configurationName; } ``` ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*/ public JibExtension(Project project) { ObjectFactory objectFactory = project.getObjects(); from = objectFactory.newInstance(BaseImageParameters.class); to = objectFactory.newInstance(TargetImageParameters.class); container = objectFactory.newInstance(ContainerParameters.class); extraDirecto...
I don't think this works. The system property should take precedence over the value set in `build.gradle`.
*/ public JibExtension(Project project) { ObjectFactory objectFactory = project.getObjects(); from = objectFactory.newInstance(BaseImageParameters.class); to = objectFactory.newInstance(TargetImageParameters.class); container = objectFactory.newInstance(ContainerParameters.class); extraDirecto...
@@ -118,6 +120,15 @@ public JibExtension(Project project) { objectFactory.newInstance(ExtensionParametersSpec.class, pluginExtensions); allowInsecureRegistries = objectFactory.property(Boolean.class); containerizingMode = objectFactory.property(String.class); + configurationName = + objectF...
jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibExtension.java
26
Java
0.571
suggestion
106
51
51
false
Configurable gradle configurations
3,034
GoogleContainerTools/jib
11,032
Java
chanseokoh
cromefire
Review this pull request change. Language: Java File: jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibExtension.java PR Title: Configurable gradle configurations BEFORE CODE: */ public JibExtension(Project project) { ObjectFactory objectFactory = project.getObjects(); from = objec...
I don't think this works. The system property should take precedence over the value set in `build.gradle`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return javaContainerBuilder.toContainerBuilder(); } catch (IOException ex) { throw new GradleException("Obtaining project build output files failed", ex); } } @Override public List<Path> getClassFiles() throws IOException { // TODO: Consolidate with createJibContainerBuilder FileColl...
`getAsFileTree()`: what does this do and why do we want to add this? Can you guarantee this does not change the current behavior? The order of the elements in the return value is important (that's why we have the code comment right above), but the [Javadoc](https://docs.gradle.org/current/javadoc/org/gradle/api/file/Fi...
} } @Override public List<Path> getClassFiles() throws IOException { // TODO: Consolidate with createJibContainerBuilder FileCollection classesOutputDirectories = getMainSourceSet().getOutput().getClassesDirs().filter(File::exists); List<Path> classFiles = new ArrayList<>(); for (File...
@@ -298,16 +311,18 @@ public JibContainerBuilder createJibContainerBuilder( @Override public List<Path> getDependencies() { List<Path> dependencies = new ArrayList<>(); - FileCollection runtimeClasspath = getMainSourceSet().getRuntimeClasspath(); + FileCollection runtimeClasspath = project.getConfigura...
jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java
26
Java
0.643
suggestion
437
51
51
false
Configurable gradle configurations
3,034
GoogleContainerTools/jib
11,032
Java
chanseokoh
cromefire
Review this pull request change. Language: Java File: jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java PR Title: Configurable gradle configurations BEFORE CODE: return javaContainerBuilder.toContainerBuilder(); } catch (IOException ex) { throw new Gradl...
`getAsFileTree()`: what does this do and why do we want to add this? Can you guarantee this does not change the current behavior? The order of the elements in the return value is important (that's why we have the code comment right above), but the [Javadoc](https://docs.gradle.org/current/javadoc/org/gradle/api/file/Fi...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*/ public JibExtension(Project project) { ObjectFactory objectFactory = project.getObjects(); from = objectFactory.newInstance(BaseImageParameters.class); to = objectFactory.newInstance(TargetImageParameters.class); container = objectFactory.newInstance(ContainerParameters.class); extraDirecto...
Need to revert this change: ```suggestion configurationName = objectFactory .property(String.class) .convention(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME); ```
*/ public JibExtension(Project project) { ObjectFactory objectFactory = project.getObjects(); from = objectFactory.newInstance(BaseImageParameters.class); to = objectFactory.newInstance(TargetImageParameters.class); container = objectFactory.newInstance(ContainerParameters.class); extraDirecto...
@@ -118,6 +120,15 @@ public JibExtension(Project project) { objectFactory.newInstance(ExtensionParametersSpec.class, pluginExtensions); allowInsecureRegistries = objectFactory.property(Boolean.class); containerizingMode = objectFactory.property(String.class); + configurationName = + objectF...
jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibExtension.java
26
Java
0.857
suggestion
208
51
51
false
Configurable gradle configurations
3,034
GoogleContainerTools/jib
11,032
Java
chanseokoh
cromefire
Review this pull request change. Language: Java File: jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibExtension.java PR Title: Configurable gradle configurations BEFORE CODE: */ public JibExtension(Project project) { ObjectFactory objectFactory = project.getObjects(); from = objec...
Need to revert this change: ```suggestion configurationName = objectFactory .property(String.class) .convention(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
tasks.register(SKAFFOLD_CHECK_REQUIRED_VERSION_TASK_NAME, CheckJibVersionTask.class); project.afterEvaluate( projectAfterEvaluation -> { TaskProvider<Task> warTask = TaskCommon.getWarTaskProvider(projectAfterEvaluation); TaskProvider<Task> bootWarTask = TaskCommon.getB...
Quick question, as I don't have a lot of Gradle expertise: would it be better if line 212 used `projectAfterEvaluation` instead of `project` (e.g., at least for consistency and eliminating future questions like this)?
String jarPath = jarTask.get().getOutputs().getFiles().getAsPath(); if (bootJarPath.equals(jarPath)) { if (!jarTask.get().getEnabled()) { ((Jar) jarTask.get()).getArchiveClassifier().set("original"); } else { thr...
@@ -215,6 +215,10 @@ public void apply(Project project) { .getSourceSets() .getByName(SourceSet.MAIN_SOURCE_SET_NAME); jibDependencies.add(mainSourceSet.getRuntimeClasspath()); + jibDependencies.add( + projectAfterEvaluation
jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibPlugin.java
26
Java
0.643
question
217
51
38
false
Configurable gradle configurations
3,034
GoogleContainerTools/jib
11,032
Java
chanseokoh
cromefire
Review this pull request change. Language: Java File: jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibPlugin.java PR Title: Configurable gradle configurations BEFORE CODE: tasks.register(SKAFFOLD_CHECK_REQUIRED_VERSION_TASK_NAME, CheckJibVersionTask.class); project.afterEvaluate( ...
Quick question, as I don't have a lot of Gradle expertise: would it be better if line 212 used `projectAfterEvaluation` instead of `project` (e.g., at least for consistency and eliminating future questions like this)?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2018 Google LLC. * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to...
FTR, this can be problematic and should be fixed. https://github.com/GoogleContainerTools/jib/pull/3034#issuecomment-792844429
@Input boolean getAllowInsecureRegistries() { if (System.getProperty(PropertyNames.ALLOW_INSECURE_REGISTRIES) != null) { return Boolean.getBoolean(PropertyNames.ALLOW_INSECURE_REGISTRIES); } return allowInsecureRegistries.get(); } @Input @Optional public String getContainerizingMode() { ...
@@ -221,6 +227,22 @@ public String getContainerizingMode() { return property != null ? property : containerizingMode.get(); } + /** + * Returns the configurationName property while setting it to the value of the system property if + * present. + * + * @return The configurationName property + */ + ...
jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibExtension.java
26
Java
0.429
suggestion
126
230
38
false
Configurable gradle configurations
3,034
GoogleContainerTools/jib
11,032
Java
chanseokoh
cromefire
Review this pull request change. Language: Java File: jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibExtension.java PR Title: Configurable gradle configurations BEFORE CODE: /* * Copyright 2018 Google LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * us...
FTR, this can be problematic and should be fixed. https://github.com/GoogleContainerTools/jib/pull/3034#issuecomment-792844429
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* 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....
I think `CACHE` is misleading. The primary purpose is to have an intermediate storage for further processing, not like keeping the contents for caching.
* 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....
@@ -32,6 +32,7 @@ public class CacheDirectories { private static final String APPLICATION_LAYER_CACHE_DIR = "application-layers"; + private static final String EXPLODED_JAR_CACHE_DIR = "exploded-jar";
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CacheDirectories.java
26
Java
0.5
performance
152
51
51
false
Modify jib cli jar command to preserve source file path
3,035
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CacheDirectories.java PR Title: Modify jib cli jar command to preserve source file path BEFORE CODE: * Unless required by applicable law or agreed to in writing, software * distributed under the License is d...
I think `CACHE` is misleading. The primary purpose is to have an intermediate storage for further processing, not like keeping the contents for caching.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import com.google.cloud.tools.jib.plugins.common.ZipUtil; import com.google.common.base.Predicates; import com.google.common.base.Verify; import com.google.common.collect.ImmutableList; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import ja...
It's difficult to understand what `targetDirectoryPath` means. `targetExplodedJarRoot`? And maybe we can remove `localExplodedJarRoot` below.
import com.google.cloud.tools.jib.plugins.common.ZipUtil; import com.google.common.base.Predicates; import com.google.common.base.Verify; import com.google.common.collect.ImmutableList; import com.google.common.io.MoreFiles; import com.google.common.io.RecursiveDeleteOption; import java.io.IOException; import java.nio....
@@ -41,20 +41,20 @@ public class SpringBootExplodedProcessor implements JarProcessor { @Nullable private final Path jarPath; - @Nullable private final Path tempDirectoryPath; + @Nullable private final Path targetDirectoryPath; - public SpringBootExplodedProcessor(Path jarPath, Path tempDirectoryPath) { + pu...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/SpringBootExplodedProcessor.java
26
Java
0.571
suggestion
141
51
51
false
Modify jib cli jar command to preserve source file path
3,035
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/SpringBootExplodedProcessor.java PR Title: Modify jib cli jar command to preserve source file path BEFORE CODE: import com.google.cloud.tools.jib.plugins.common.ZipUtil; import com.google.common.base.Predi...
It's difficult to understand what `targetDirectoryPath` means. `targetExplodedJarRoot`? And maybe we can remove `localExplodedJarRoot` below.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.Predicate; import java.util.jar.JarFile; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.ZipEntry; i...
`targetDirectoryPath` can never be `null`. Do you remember why we had this null check?
import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.Predicate; import java.util.jar.JarFile; import java.util.regex.Mat...
@@ -41,20 +41,20 @@ public class SpringBootExplodedProcessor implements JarProcessor { @Nullable private final Path jarPath; - @Nullable private final Path tempDirectoryPath; + @Nullable private final Path targetDirectoryPath; - public SpringBootExplodedProcessor(Path jarPath, Path tempDirectoryPath) { + pu...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/SpringBootExplodedProcessor.java
26
Java
0.5
question
86
51
51
false
Modify jib cli jar command to preserve source file path
3,035
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/SpringBootExplodedProcessor.java PR Title: Modify jib cli jar command to preserve source file path BEFORE CODE: import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.u...
`targetDirectoryPath` can never be `null`. Do you remember why we had this null check?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import com.google.cloud.tools.jib.ProjectInfo; import com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer; import com.google.cloud.tools.jib.plugins.common.ZipUtil; import com.google.common.base.Predicates; import com.google.common.base.Verify; import com.google.common.collect.ImmutableList; import java.io.IOExce...
Remove `@Nullable` for `jarPath` and `targetDirectoryPath`, and double-check that indeed they cannot be null. Do you remember why they started with `@Nullable`?
import com.google.cloud.tools.jib.ProjectInfo; import com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer; import com.google.cloud.tools.jib.plugins.common.ZipUtil; import com.google.common.base.Predicates; import com.google.common.base.Verify; import com.google.common.collect.ImmutableList; import com.google.com...
@@ -41,20 +41,20 @@ public class SpringBootExplodedProcessor implements JarProcessor { @Nullable private final Path jarPath; - @Nullable private final Path tempDirectoryPath; + @Nullable private final Path targetDirectoryPath;
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/SpringBootExplodedProcessor.java
26
Java
0.714
question
160
51
51
false
Modify jib cli jar command to preserve source file path
3,035
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/SpringBootExplodedProcessor.java PR Title: Modify jib cli jar command to preserve source file path BEFORE CODE: import com.google.cloud.tools.jib.ProjectInfo; import com.google.cloud.tools.jib.api.buildpla...
Remove `@Nullable` for `jarPath` and `targetDirectoryPath`, and double-check that indeed they cannot be null. Do you remember why they started with `@Nullable`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; /** Tests for {@link JarProcessors}. */ @RunWith(MockitoJUnitRunner.class) public class JarProcessorsTest { private static final String SPRING_BOOT = "jar/spring-boot/springboot_sample.jar"; private static final...
Maybe we can check if `Files.exists(destination.resolve("some-file"))`?
import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; /** Tests for {@link JarProcessors}. */ @RunWith(MockitoJUnitRunner.class) public class JarProcessorsTest { private static final String SPRING_BOOT = "jar/spring-boot/springboot_sample.jar"; private static final...
@@ -39,41 +43,53 @@ private static final String STANDARD = "jar/standard/emptyStandardJar.jar"; private static final String JAVA_14_JAR = "jar/java14WithModuleInfo.jar"; - @Mock private TempDirectoryProvider mockTemporaryDirectoryProvider; + @Mock private CacheDirectories mockCacheDirectories; + + @Rule publ...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorsTest.java
26
Java
0.357
question
71
51
51
false
Modify jib cli jar command to preserve source file path
3,035
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorsTest.java PR Title: Modify jib cli jar command to preserve source file path BEFORE CODE: import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; ...
Maybe we can check if `Files.exists(destination.resolve("some-file"))`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
private static final String JAVA_14_JAR = "jar/java14WithModuleInfo.jar"; @Mock private CacheDirectories mockCacheDirectories; @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); @Test public void testFrom_standardExploded() throws IOException, URISyntaxException { Path jarPath ...
Perhaps verify the exploded jar directory is empty.
private static final String JAVA_14_JAR = "jar/java14WithModuleInfo.jar"; @Mock private CacheDirectories mockCacheDirectories; @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); @Test public void testFrom_standardExploded() throws IOException, URISyntaxException { Path jarPath ...
@@ -39,41 +43,53 @@ private static final String STANDARD = "jar/standard/emptyStandardJar.jar"; private static final String JAVA_14_JAR = "jar/java14WithModuleInfo.jar"; - @Mock private TempDirectoryProvider mockTemporaryDirectoryProvider; + @Mock private CacheDirectories mockCacheDirectories; + + @Rule publ...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorsTest.java
26
Java
0.214
suggestion
51
51
51
false
Modify jib cli jar command to preserve source file path
3,035
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorsTest.java PR Title: Modify jib cli jar command to preserve source file path BEFORE CODE: private static final String JAVA_14_JAR = "jar/java14WithModuleInfo.jar"; @Mock private CacheDirec...
Perhaps verify the exploded jar directory is empty.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.