use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib-extensions by GoogleContainerTools.
the class JibQuarkusExtensionTest method testExtendContainerBuildPlan_entrypoint.
@Test
public void testExtendContainerBuildPlan_entrypoint() throws JibPluginExtensionException {
ContainerBuildPlan buildPlan = ContainerBuildPlan.builder().build();
ContainerBuildPlan newPlan = new JibQuarkusExtension().extendContainerBuildPlan(buildPlan, null, Optional.empty(), gradleData, logger);
assertEquals(Arrays.asList("java", "-verbose:gc", "-Dmy.property=value", "-jar", "/new/appRoot/app.jar"), newPlan.getEntrypoint());
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib-extensions by GoogleContainerTools.
the class JibNativeImageExtensionTest method testEntrypoint_setByJib.
@Test
public void testEntrypoint_setByJib() throws JibPluginExtensionException, IOException {
Map<String, String> properties = Collections.singletonMap("imageName", "theExecutable");
tempFolder.newFile("theExecutable");
when(project.getPlugin("com.google.cloud.tools:jib-maven-plugin")).thenReturn(plugin);
Xpp3Dom configuration = buildDom(Arrays.asList("configuration", "container", "entrypoint"), "non-empty");
when(plugin.getConfiguration()).thenReturn(configuration);
ContainerBuildPlan buildPlan = ContainerBuildPlan.builder().setEntrypoint(Arrays.asList("set by Jib")).build();
ContainerBuildPlan newPlan = new JibNativeImageExtension().extendContainerBuildPlan(buildPlan, properties, Optional.empty(), mavenData, logger);
assertEquals(Arrays.asList("set by Jib"), newPlan.getEntrypoint());
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib-extensions by GoogleContainerTools.
the class JibNativeImageExtensionTest method testNoExecutableNameDetected.
@Test
public void testNoExecutableNameDetected() {
ContainerBuildPlan buildPlan = ContainerBuildPlan.builder().build();
try {
new JibNativeImageExtension().extendContainerBuildPlan(buildPlan, Collections.emptyMap(), Optional.empty(), mavenData, logger);
fail();
} catch (JibPluginExtensionException ex) {
assertEquals("cannot auto-detect native-image executable name; consider setting 'imageName' property", ex.getMessage());
}
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib-extensions by GoogleContainerTools.
the class JibOwnershipExtensionTest method testExtendContainerBuildPlan.
@Test
public void testExtendContainerBuildPlan() throws JibPluginExtensionException {
FileEntriesLayer layer1 = FileEntriesLayer.builder().addEntry(Paths.get("whatever"), AbsoluteUnixPath.get("/target/file")).addEntry(Paths.get("whatever"), AbsoluteUnixPath.get("/target/another")).addEntry(Paths.get("whatever"), AbsoluteUnixPath.get("/target/sub/dir/file")).addEntry(Paths.get("whatever"), AbsoluteUnixPath.get("/target/sub/dir/another")).addEntry(Paths.get("whatever"), AbsoluteUnixPath.get("/untouched/file")).addEntry(Paths.get("whatever"), AbsoluteUnixPath.get("/untouched/another")).build();
FileEntriesLayer layer2 = FileEntriesLayer.builder().addEntry(Paths.get("whatever"), AbsoluteUnixPath.get("/target/foo")).addEntry(Paths.get("whatever"), AbsoluteUnixPath.get("/target/bar")).addEntry(Paths.get("whatever"), AbsoluteUnixPath.get("/target/sub/dir/foo")).addEntry(Paths.get("whatever"), AbsoluteUnixPath.get("/target/sub/dir/bar")).addEntry(Paths.get("whatever"), AbsoluteUnixPath.get("/untouched/foo")).addEntry(Paths.get("whatever"), AbsoluteUnixPath.get("/untouched/bar")).build();
ContainerBuildPlan buildPlan = ContainerBuildPlan.builder().addLayer(layer1).addLayer(layer2).build();
Configuration.Rule rule1 = mockRule("/target/**", "10:20");
Configuration.Rule rule2 = mockRule("**/bar", "999:777");
when(config.getRules()).thenReturn(Arrays.asList(rule1, rule2));
ContainerBuildPlan newPlan = new JibOwnershipExtension().extendContainerBuildPlan(buildPlan, null, Optional.of(config), null, logger);
FileEntriesLayer newLayer1 = (FileEntriesLayer) newPlan.getLayers().get(0);
FileEntriesLayer newLayer2 = (FileEntriesLayer) newPlan.getLayers().get(1);
assertEquals(Arrays.asList(AbsoluteUnixPath.get("/target/file"), AbsoluteUnixPath.get("/target/another"), AbsoluteUnixPath.get("/target/sub/dir/file"), AbsoluteUnixPath.get("/target/sub/dir/another"), AbsoluteUnixPath.get("/untouched/file"), AbsoluteUnixPath.get("/untouched/another")), mapLayerEntries(newLayer1, FileEntry::getExtractionPath));
assertEquals(Arrays.asList("10:20", "10:20", "10:20", "10:20", "", ""), mapLayerEntries(newLayer1, FileEntry::getOwnership));
assertEquals(Arrays.asList(AbsoluteUnixPath.get("/target/foo"), AbsoluteUnixPath.get("/target/bar"), AbsoluteUnixPath.get("/target/sub/dir/foo"), AbsoluteUnixPath.get("/target/sub/dir/bar"), AbsoluteUnixPath.get("/untouched/foo"), AbsoluteUnixPath.get("/untouched/bar")), mapLayerEntries(newLayer2, FileEntry::getExtractionPath));
assertEquals(Arrays.asList("10:20", "999:777", "10:20", "999:777", "", "999:777"), mapLayerEntries(newLayer2, FileEntry::getOwnership));
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib-extensions by GoogleContainerTools.
the class JibOwnershipExtensionTest method testExtendContainerBuildPlan_noConfiguration.
@Test
public void testExtendContainerBuildPlan_noConfiguration() throws JibPluginExtensionException {
ContainerBuildPlan buildPlan = ContainerBuildPlan.builder().build();
ContainerBuildPlan newPlan = new JibOwnershipExtension().extendContainerBuildPlan(buildPlan, null, Optional.empty(), null, logger);
assertSame(buildPlan, newPlan);
verify(logger).log(LogLevel.WARN, "Nothing configured for Jib Ownership Extension");
}
Aggregations