use of com.google.cloud.tools.jib.plugins.common.RawConfiguration.ExtraDirectoriesConfiguration 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.plugins.common.RawConfiguration.ExtraDirectoriesConfiguration in project jib by google.
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;
}
Aggregations