@Test(expected = Fabric8ServiceException.class) public void testFailedBuild() throws Exception { BuildService.BuildServiceConfig config = defaultConfig.build(); WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(config, false, 50, false, false); OpenShiftMockServer mockServer = collector.getMockServer(); OpenShiftClient client = mockServer.createOpenShiftClient(); OpenshiftBuildService service = new OpenshiftBuildService(client, logger, dockerServiceHub, config); service.build(image); }
@Override public void build(ImageConfiguration imageConfig) throws Fabric8ServiceException { String buildName = null; try { ImageName imageName = new ImageName(imageConfig.getName()); File dockerTar = createBuildArchive(imageConfig); KubernetesListBuilder builder = new KubernetesListBuilder(); String openshiftPullSecret = config.getOpenshiftPullSecret(); Boolean usePullSecret = checkOrCreatePullSecret(config, client, builder, openshiftPullSecret, imageConfig); if (usePullSecret) { buildName = updateOrCreateBuildConfig(config, client, builder, imageConfig, openshiftPullSecret); } else { buildName = updateOrCreateBuildConfig(config, client, builder, imageConfig, null); } checkOrCreateImageStream(config, client, builder, getImageStreamName(imageName)); applyResourceObjects(config, client, builder); Build build = startBuild(client, dockerTar, buildName); waitForOpenShiftBuildToComplete(client, build); addImageStreamToFile(getImageStreamFile(config), imageName, client); } catch (Fabric8ServiceException e) { throw e; } catch (Exception ex) { if (ex != null && ex.getCause() instanceof IOException) { log.error("Build for %s failed: %s", buildName, ex.getCause().getMessage()); logBuildFailure(client, buildName); } else { throw new Fabric8ServiceException("Unable to build the image using the OpenShift build service", ex); } } }
OpenshiftBuildService implements BuildService { @Override public void build(ImageConfiguration imageConfig) throws Fabric8ServiceException { String buildName = null; try { ImageName imageName = new ImageName(imageConfig.getName()); File dockerTar = createBuildArchive(imageConfig); KubernetesListBuilder builder = new KubernetesListBuilder(); String openshiftPullSecret = config.getOpenshiftPullSecret(); Boolean usePullSecret = checkOrCreatePullSecret(config, client, builder, openshiftPullSecret, imageConfig); if (usePullSecret) { buildName = updateOrCreateBuildConfig(config, client, builder, imageConfig, openshiftPullSecret); } else { buildName = updateOrCreateBuildConfig(config, client, builder, imageConfig, null); } checkOrCreateImageStream(config, client, builder, getImageStreamName(imageName)); applyResourceObjects(config, client, builder); Build build = startBuild(client, dockerTar, buildName); waitForOpenShiftBuildToComplete(client, build); addImageStreamToFile(getImageStreamFile(config), imageName, client); } catch (Fabric8ServiceException e) { throw e; } catch (Exception ex) { if (ex != null && ex.getCause() instanceof IOException) { log.error("Build for %s failed: %s", buildName, ex.getCause().getMessage()); logBuildFailure(client, buildName); } else { throw new Fabric8ServiceException("Unable to build the image using the OpenShift build service", ex); } } } }
OpenshiftBuildService implements BuildService { @Override public void build(ImageConfiguration imageConfig) throws Fabric8ServiceException { String buildName = null; try { ImageName imageName = new ImageName(imageConfig.getName()); File dockerTar = createBuildArchive(imageConfig); KubernetesListBuilder builder = new KubernetesListBuilder(); String openshiftPullSecret = config.getOpenshiftPullSecret(); Boolean usePullSecret = checkOrCreatePullSecret(config, client, builder, openshiftPullSecret, imageConfig); if (usePullSecret) { buildName = updateOrCreateBuildConfig(config, client, builder, imageConfig, openshiftPullSecret); } else { buildName = updateOrCreateBuildConfig(config, client, builder, imageConfig, null); } checkOrCreateImageStream(config, client, builder, getImageStreamName(imageName)); applyResourceObjects(config, client, builder); Build build = startBuild(client, dockerTar, buildName); waitForOpenShiftBuildToComplete(client, build); addImageStreamToFile(getImageStreamFile(config), imageName, client); } catch (Fabric8ServiceException e) { throw e; } catch (Exception ex) { if (ex != null && ex.getCause() instanceof IOException) { log.error("Build for %s failed: %s", buildName, ex.getCause().getMessage()); logBuildFailure(client, buildName); } else { throw new Fabric8ServiceException("Unable to build the image using the OpenShift build service", ex); } } } OpenshiftBuildService(OpenShiftClient client, Logger log, ServiceHub dockerServiceHub, BuildServiceConfig config); }
OpenshiftBuildService implements BuildService { @Override public void build(ImageConfiguration imageConfig) throws Fabric8ServiceException { String buildName = null; try { ImageName imageName = new ImageName(imageConfig.getName()); File dockerTar = createBuildArchive(imageConfig); KubernetesListBuilder builder = new KubernetesListBuilder(); String openshiftPullSecret = config.getOpenshiftPullSecret(); Boolean usePullSecret = checkOrCreatePullSecret(config, client, builder, openshiftPullSecret, imageConfig); if (usePullSecret) { buildName = updateOrCreateBuildConfig(config, client, builder, imageConfig, openshiftPullSecret); } else { buildName = updateOrCreateBuildConfig(config, client, builder, imageConfig, null); } checkOrCreateImageStream(config, client, builder, getImageStreamName(imageName)); applyResourceObjects(config, client, builder); Build build = startBuild(client, dockerTar, buildName); waitForOpenShiftBuildToComplete(client, build); addImageStreamToFile(getImageStreamFile(config), imageName, client); } catch (Fabric8ServiceException e) { throw e; } catch (Exception ex) { if (ex != null && ex.getCause() instanceof IOException) { log.error("Build for %s failed: %s", buildName, ex.getCause().getMessage()); logBuildFailure(client, buildName); } else { throw new Fabric8ServiceException("Unable to build the image using the OpenShift build service", ex); } } } OpenshiftBuildService(OpenShiftClient client, Logger log, ServiceHub dockerServiceHub, BuildServiceConfig config); @Override void build(ImageConfiguration imageConfig); @Override void postProcess(BuildServiceConfig config); }
OpenshiftBuildService implements BuildService { @Override public void build(ImageConfiguration imageConfig) throws Fabric8ServiceException { String buildName = null; try { ImageName imageName = new ImageName(imageConfig.getName()); File dockerTar = createBuildArchive(imageConfig); KubernetesListBuilder builder = new KubernetesListBuilder(); String openshiftPullSecret = config.getOpenshiftPullSecret(); Boolean usePullSecret = checkOrCreatePullSecret(config, client, builder, openshiftPullSecret, imageConfig); if (usePullSecret) { buildName = updateOrCreateBuildConfig(config, client, builder, imageConfig, openshiftPullSecret); } else { buildName = updateOrCreateBuildConfig(config, client, builder, imageConfig, null); } checkOrCreateImageStream(config, client, builder, getImageStreamName(imageName)); applyResourceObjects(config, client, builder); Build build = startBuild(client, dockerTar, buildName); waitForOpenShiftBuildToComplete(client, build); addImageStreamToFile(getImageStreamFile(config), imageName, client); } catch (Fabric8ServiceException e) { throw e; } catch (Exception ex) { if (ex != null && ex.getCause() instanceof IOException) { log.error("Build for %s failed: %s", buildName, ex.getCause().getMessage()); logBuildFailure(client, buildName); } else { throw new Fabric8ServiceException("Unable to build the image using the OpenShift build service", ex); } } } OpenshiftBuildService(OpenShiftClient client, Logger log, ServiceHub dockerServiceHub, BuildServiceConfig config); @Override void build(ImageConfiguration imageConfig); @Override void postProcess(BuildServiceConfig config); static final String DEFAULT_S2I_SOURCE_TYPE; }