use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib-extensions by GoogleContainerTools.
the class JibSpringBootExtensionTest method testExtendContainerBuildPlan_noFiltering.
@Test
public void testExtendContainerBuildPlan_noFiltering() throws JibPluginExtensionException {
when(bootJar.getClasspath()).thenReturn(new MockFileCollection(Paths.get("spring-boot-devtools-1.2.3.jar")));
FileEntriesLayer layer1 = buildLayer("dependencies", Paths.get("spring-boot-devtools-1.2.3.jar"), Paths.get("archive").resolve("bar.zip"));
FileEntriesLayer layer2 = buildLayer("NOT dependencies", Paths.get("spring-boot-devtools-1.2.3.jar"));
ContainerBuildPlan buildPlan = ContainerBuildPlan.builder().addLayer(layer1).addLayer(layer2).build();
ContainerBuildPlan newPlan = new JibSpringBootExtension().extendContainerBuildPlan(buildPlan, properties, Optional.empty(), gradleData, logger);
assertSame(buildPlan, newPlan);
verify(logger).log(LogLevel.INFO, "Keeping spring-boot-devtools (if any)");
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib-extensions by GoogleContainerTools.
the class JibLayerFilterExtensionTest method testExtendContainerBuildPlan_sameLayerNameInMultipleFilters.
@Test
public void testExtendContainerBuildPlan_sameLayerNameInMultipleFilters() throws JibPluginExtensionException {
FileEntriesLayer layer = buildLayer("", Arrays.asList("/filter1", "/filter2", "/filter3", "/filter4", "/filter5"));
ContainerBuildPlan buildPlan = ContainerBuildPlan.builder().addLayer(layer).build();
Configuration.Filter filter1 = mockFilter("/filter1", "foo");
Configuration.Filter filter2 = mockFilter("/filter2", "same layer name");
Configuration.Filter filter3 = mockFilter("/filter3", "bar");
Configuration.Filter filter4 = mockFilter("/filter4", "same layer name");
Configuration.Filter filter5 = mockFilter("/filter5", "baz");
when(config.getFilters()).thenReturn(Arrays.asList(filter1, filter2, filter3, filter4, filter5));
JibLayerFilterExtension extension = new JibLayerFilterExtension();
ContainerBuildPlan newPlan = extension.extendContainerBuildPlan(buildPlan, null, Optional.of(config), null, logger);
ArrayList<String> layerNames = new ArrayList<>(extension.newToLayers.keySet());
assertEquals(Arrays.asList("foo", "same layer name", "bar", "baz"), layerNames);
assertEquals(4, newPlan.getLayers().size());
FileEntriesLayer newLayer1 = (FileEntriesLayer) newPlan.getLayers().get(0);
FileEntriesLayer newLayer2 = (FileEntriesLayer) newPlan.getLayers().get(1);
FileEntriesLayer newLayer3 = (FileEntriesLayer) newPlan.getLayers().get(2);
FileEntriesLayer newLayer4 = (FileEntriesLayer) newPlan.getLayers().get(3);
assertEquals("foo", newLayer1.getName());
assertEquals("same layer name", newLayer2.getName());
assertEquals("bar", newLayer3.getName());
assertEquals("baz", newLayer4.getName());
assertEquals(Arrays.asList("/filter1"), layerToExtractionPaths(newLayer1));
assertEquals(Arrays.asList("/filter2", "/filter4"), layerToExtractionPaths(newLayer2));
assertEquals(Arrays.asList("/filter3"), layerToExtractionPaths(newLayer3));
assertEquals(Arrays.asList("/filter5"), layerToExtractionPaths(newLayer4));
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib-extensions by GoogleContainerTools.
the class JibLayerFilterExtensionTest method testExtendContainerBuildPlan_lastConfigWins.
@Test
public void testExtendContainerBuildPlan_lastConfigWins() throws JibPluginExtensionException {
FileEntriesLayer layer = buildLayer("extra files", Arrays.asList("/foo"));
ContainerBuildPlan buildPlan = ContainerBuildPlan.builder().addLayer(layer).build();
Configuration.Filter filter1 = mockFilter("**", "looser");
Configuration.Filter filter2 = mockFilter("**", "winner");
when(config.getFilters()).thenReturn(Arrays.asList(filter1, filter2));
ContainerBuildPlan newPlan = new JibLayerFilterExtension().extendContainerBuildPlan(buildPlan, null, Optional.of(config), null, logger);
assertEquals(1, newPlan.getLayers().size());
FileEntriesLayer newLayer = (FileEntriesLayer) newPlan.getLayers().get(0);
assertEquals("winner", newLayer.getName());
assertEquals(layer.getEntries(), newLayer.getEntries());
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib-extensions by GoogleContainerTools.
the class JibLayerFilterExtensionTest method testExtendContainerBuildPlan_noConfiguration.
@Test
public void testExtendContainerBuildPlan_noConfiguration() throws JibPluginExtensionException {
ContainerBuildPlan buildPlan = ContainerBuildPlan.builder().build();
ContainerBuildPlan newPlan = new JibLayerFilterExtension().extendContainerBuildPlan(buildPlan, null, Optional.empty(), null, logger);
assertSame(buildPlan, newPlan);
verify(logger).log(LogLevel.WARN, "Nothing configured for Jib Layer Filter Extension");
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib-extensions by GoogleContainerTools.
the class JibLayerFilterExtensionTest method testExtendContainerBuildPlan_noMatches.
@Test
public void testExtendContainerBuildPlan_noMatches() throws JibPluginExtensionException {
FileEntriesLayer layer1 = buildLayer("", Arrays.asList("/foo"));
FileEntriesLayer layer2 = buildLayer("", Arrays.asList("/foo", "/bar"));
ContainerBuildPlan buildPlan = ContainerBuildPlan.builder().addLayer(layer1).addLayer(layer2).build();
Configuration.Filter filter = mockFilter("nothing/matches", "");
when(config.getFilters()).thenReturn(Arrays.asList(filter));
ContainerBuildPlan newPlan = new JibLayerFilterExtension().extendContainerBuildPlan(buildPlan, null, Optional.of(config), null, logger);
assertEquals(2, newPlan.getLayers().size());
FileEntriesLayer newLayer1 = (FileEntriesLayer) newPlan.getLayers().get(0);
FileEntriesLayer newLayer2 = (FileEntriesLayer) newPlan.getLayers().get(1);
assertEquals("", newLayer1.getName());
assertEquals("", newLayer2.getName());
assertEquals(layer1.getEntries(), newLayer1.getEntries());
assertEquals(layer2.getEntries(), newLayer2.getEntries());
}
Aggregations