Search in sources :

Example 1 with ModificationTimeProvider

use of com.google.cloud.tools.jib.api.buildplan.ModificationTimeProvider in project jib by GoogleContainerTools.

the class PluginConfigurationProcessorTest method testCreateModificationTimeProvider_epochPlusSecond.

@Test
public void testCreateModificationTimeProvider_epochPlusSecond() throws InvalidFilesModificationTimeException {
    ModificationTimeProvider timeProvider = PluginConfigurationProcessor.createModificationTimeProvider("EPOCH_PLUS_SECOND");
    assertThat(timeProvider.get(Paths.get("foo"), AbsoluteUnixPath.get("/bar"))).isEqualTo(Instant.ofEpochSecond(1));
}
Also used : ModificationTimeProvider(com.google.cloud.tools.jib.api.buildplan.ModificationTimeProvider) Test(org.junit.Test)

Example 2 with ModificationTimeProvider

use of com.google.cloud.tools.jib.api.buildplan.ModificationTimeProvider in project jib by GoogleContainerTools.

the class PluginConfigurationProcessorTest method testCreateModificationTimeProvider_isoDateTimeValue.

@Test
public void testCreateModificationTimeProvider_isoDateTimeValue() throws InvalidFilesModificationTimeException {
    ModificationTimeProvider timeProvider = PluginConfigurationProcessor.createModificationTimeProvider("2011-12-03T10:15:30+09:00");
    Instant expected = DateTimeFormatter.ISO_DATE_TIME.parse("2011-12-03T01:15:30Z", Instant::from);
    assertThat(timeProvider.get(Paths.get("foo"), AbsoluteUnixPath.get("/bar"))).isEqualTo(expected);
}
Also used : Instant(java.time.Instant) ModificationTimeProvider(com.google.cloud.tools.jib.api.buildplan.ModificationTimeProvider) Test(org.junit.Test)

Example 3 with ModificationTimeProvider

use of com.google.cloud.tools.jib.api.buildplan.ModificationTimeProvider in project jib by GoogleContainerTools.

the class PluginConfigurationProcessor method processCommonConfiguration.

@VisibleForTesting
static JibContainerBuilder processCommonConfiguration(RawConfiguration rawConfiguration, InferredAuthProvider inferredAuthProvider, ProjectProperties projectProperties) throws InvalidFilesModificationTimeException, InvalidAppRootException, IncompatibleBaseImageJavaVersionException, IOException, InvalidImageReferenceException, InvalidContainerizingModeException, MainClassInferenceException, InvalidPlatformException, InvalidContainerVolumeException, InvalidWorkingDirectoryException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
    // Create and configure JibContainerBuilder
    ModificationTimeProvider modificationTimeProvider = createModificationTimeProvider(rawConfiguration.getFilesModificationTime());
    JavaContainerBuilder javaContainerBuilder = getJavaContainerBuilderWithBaseImage(rawConfiguration, projectProperties, inferredAuthProvider).setAppRoot(getAppRootChecked(rawConfiguration, projectProperties)).setModificationTimeProvider(modificationTimeProvider);
    JibContainerBuilder jibContainerBuilder = projectProperties.createJibContainerBuilder(javaContainerBuilder, getContainerizingModeChecked(rawConfiguration, projectProperties));
    jibContainerBuilder.setFormat(rawConfiguration.getImageFormat()).setPlatforms(getPlatformsSet(rawConfiguration)).setEntrypoint(computeEntrypoint(rawConfiguration, projectProperties, jibContainerBuilder)).setProgramArguments(rawConfiguration.getProgramArguments().orElse(null)).setEnvironment(rawConfiguration.getEnvironment()).setExposedPorts(Ports.parse(rawConfiguration.getPorts())).setVolumes(getVolumesSet(rawConfiguration)).setLabels(rawConfiguration.getLabels()).setUser(rawConfiguration.getUser().orElse(null)).setCreationTime(getCreationTime(rawConfiguration.getCreationTime(), projectProperties));
    getWorkingDirectoryChecked(rawConfiguration).ifPresent(jibContainerBuilder::setWorkingDirectory);
    // Adds all the extra files.
    for (ExtraDirectoriesConfiguration extraDirectory : rawConfiguration.getExtraDirectories()) {
        Path from = extraDirectory.getFrom();
        if (Files.exists(from)) {
            jibContainerBuilder.addFileEntriesLayer(JavaContainerBuilderHelper.extraDirectoryLayerConfiguration(from, AbsoluteUnixPath.get(extraDirectory.getInto()), extraDirectory.getIncludesList(), extraDirectory.getExcludesList(), rawConfiguration.getExtraDirectoryPermissions(), modificationTimeProvider));
        } else if (!from.endsWith(DEFAULT_JIB_DIR)) {
            throw new ExtraDirectoryNotFoundException(from.toString(), from.toString());
        }
    }
    return jibContainerBuilder;
}
Also used : Path(java.nio.file.Path) AbsoluteUnixPath(com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath) JavaContainerBuilder(com.google.cloud.tools.jib.api.JavaContainerBuilder) ModificationTimeProvider(com.google.cloud.tools.jib.api.buildplan.ModificationTimeProvider) JibContainerBuilder(com.google.cloud.tools.jib.api.JibContainerBuilder) ExtraDirectoriesConfiguration(com.google.cloud.tools.jib.plugins.common.RawConfiguration.ExtraDirectoriesConfiguration) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 4 with ModificationTimeProvider

use of com.google.cloud.tools.jib.api.buildplan.ModificationTimeProvider in project jib by google.

the class PluginConfigurationProcessorTest method testCreateModificationTimeProvider_isoDateTimeValue.

@Test
public void testCreateModificationTimeProvider_isoDateTimeValue() throws InvalidFilesModificationTimeException {
    ModificationTimeProvider timeProvider = PluginConfigurationProcessor.createModificationTimeProvider("2011-12-03T10:15:30+09:00");
    Instant expected = DateTimeFormatter.ISO_DATE_TIME.parse("2011-12-03T01:15:30Z", Instant::from);
    assertThat(timeProvider.get(Paths.get("foo"), AbsoluteUnixPath.get("/bar"))).isEqualTo(expected);
}
Also used : Instant(java.time.Instant) ModificationTimeProvider(com.google.cloud.tools.jib.api.buildplan.ModificationTimeProvider) Test(org.junit.Test)

Example 5 with ModificationTimeProvider

use of com.google.cloud.tools.jib.api.buildplan.ModificationTimeProvider in project jib by google.

the class PluginConfigurationProcessorTest method testCreateModificationTimeProvider_epochPlusSecond.

@Test
public void testCreateModificationTimeProvider_epochPlusSecond() throws InvalidFilesModificationTimeException {
    ModificationTimeProvider timeProvider = PluginConfigurationProcessor.createModificationTimeProvider("EPOCH_PLUS_SECOND");
    assertThat(timeProvider.get(Paths.get("foo"), AbsoluteUnixPath.get("/bar"))).isEqualTo(Instant.ofEpochSecond(1));
}
Also used : ModificationTimeProvider(com.google.cloud.tools.jib.api.buildplan.ModificationTimeProvider) Test(org.junit.Test)

Aggregations

ModificationTimeProvider (com.google.cloud.tools.jib.api.buildplan.ModificationTimeProvider)8 JavaContainerBuilder (com.google.cloud.tools.jib.api.JavaContainerBuilder)4 JibContainerBuilder (com.google.cloud.tools.jib.api.JibContainerBuilder)4 AbsoluteUnixPath (com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath)4 Path (java.nio.file.Path)4 Instant (java.time.Instant)4 Test (org.junit.Test)4 LayerType (com.google.cloud.tools.jib.api.JavaContainerBuilder.LayerType)2 FileEntriesLayer (com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer)2 FilePermissions (com.google.cloud.tools.jib.api.buildplan.FilePermissions)2 RelativeUnixPath (com.google.cloud.tools.jib.api.buildplan.RelativeUnixPath)2 DirectoryWalker (com.google.cloud.tools.jib.filesystem.DirectoryWalker)2 ExtraDirectoriesConfiguration (com.google.cloud.tools.jib.plugins.common.RawConfiguration.ExtraDirectoriesConfiguration)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 IOException (java.io.IOException)2 FileSystems (java.nio.file.FileSystems)2 Files (java.nio.file.Files)2 PathMatcher (java.nio.file.PathMatcher)2 Paths (java.nio.file.Paths)2 LinkedHashMap (java.util.LinkedHashMap)2