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));
}
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);
}
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;
}
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);
}
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));
}
Aggregations