use of com.google.cloud.tools.jib.event.EventHandlers in project jib by GoogleContainerTools.
the class PlatformChecker method checkManifestPlatform.
/**
* Assuming the base image is not a manifest list, checks and warns misconfigured platforms.
*
* @param buildContext the {@link BuildContext}
* @param containerConfig container configuration JSON of the base image
*/
static void checkManifestPlatform(BuildContext buildContext, ContainerConfigurationTemplate containerConfig) {
EventHandlers eventHandlers = buildContext.getEventHandlers();
Optional<Path> path = buildContext.getBaseImageConfiguration().getTarPath();
String baseImageName = path.map(Path::toString).orElse(buildContext.getBaseImageConfiguration().getImage().toString());
Set<Platform> platforms = buildContext.getContainerConfiguration().getPlatforms();
Verify.verify(!platforms.isEmpty());
if (platforms.size() != 1) {
eventHandlers.dispatch(LogEvent.warn("platforms configured, but '" + baseImageName + "' is not a manifest list"));
} else {
Platform platform = platforms.iterator().next();
if (!platform.getArchitecture().equals(containerConfig.getArchitecture()) || !platform.getOs().equals(containerConfig.getOs())) {
// configure it. Skip reporting to suppress false alarm.
if (!(platform.getArchitecture().equals("amd64") && platform.getOs().equals("linux"))) {
String warning = "the configured platform (%s/%s) doesn't match the platform (%s/%s) of the base " + "image (%s)";
eventHandlers.dispatch(LogEvent.warn(String.format(warning, platform.getArchitecture(), platform.getOs(), containerConfig.getArchitecture(), containerConfig.getOs(), baseImageName)));
}
}
}
}
use of com.google.cloud.tools.jib.event.EventHandlers in project jib by GoogleContainerTools.
the class PushImageStep method call.
@Override
public BuildResult call() throws IOException, RegistryException {
EventHandlers eventHandlers = buildContext.getEventHandlers();
try (TimerEventDispatcher ignored = new TimerEventDispatcher(eventHandlers, DESCRIPTION);
ProgressEventDispatcher ignored2 = progressEventDispatcherFactory.create("pushing manifest for " + imageQualifier, 1)) {
eventHandlers.dispatch(LogEvent.info("Pushing manifest for " + imageQualifier + "..."));
registryClient.pushManifest(manifestTemplate, imageQualifier);
return new BuildResult(imageDigest, imageId);
}
}
Aggregations