com.github.dockerjava.api.model.PushResponseItem Java Examples
The following examples show how to use
com.github.dockerjava.api.model.PushResponseItem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PushImageCommand.java From cubeai with Apache License 2.0 | 6 votes |
@Override public void execute() throws DockerException { if (!StringUtils.isNotBlank(image)) { throw new IllegalArgumentException("Image name must be provided"); } // Don't include tag in the image name. Docker daemon can't handle it. // put tag in query string parameter. String imageFullName = CommandUtils.imageFullNameFrom(registry, image, tag); final DockerClient client = getClient(); PushImageCmd pushImageCmd = client.pushImageCmd(imageFullName).withTag(tag); PushImageResultCallback callback = new PushImageResultCallback() { @Override public void onNext(PushResponseItem item) { super.onNext(item); } @Override public void onError(Throwable throwable) { logger.error("Failed to push image:" + throwable.getMessage()); super.onError(throwable); } }; pushImageCmd.exec(callback).awaitSuccess(); }
Example #2
Source File: DockerOpt.java From dew with Apache License 2.0 | 6 votes |
/** * Push. * * @param imageName the image name * @param auth the auth * @param awaitSec the await sec */ public void push(String imageName, boolean auth, long awaitSec) { PushImageCmd pushImageCmd = docker.pushImageCmd(imageName); if (auth) { pushImageCmd.withAuthConfig(defaultAuthConfig); } try { pushImageCmd.exec(new PushImageResultCallback() { @Override public void onNext(PushResponseItem item) { super.onNext(item); log.debug(item.toString()); } }).awaitCompletion(awaitSec, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); log.error("Push image error.", e); } }
Example #3
Source File: DockerServiceImpl.java From Dolphin with Apache License 2.0 | 6 votes |
private void pushImage(DockerfileRequest request, DockerfileResponse response) { logger.info(String.format("begin pushImage: %s", request)); try { String repositoryName = buildRepositoryName(request); Repository repository = new Repository(repositoryName); Identifier identifier = new Identifier(repository, request.getAppTag()); dockerClient.pushImageCmd(identifier).exec(new PushImageResultCallback() { @Override public void onNext(PushResponseItem item) { super.onNext(item); if (logger.isDebugEnabled()) { logger.debug(item); } } }).awaitSuccess(); response.setRepository(String.format("%s:%s", repositoryName, request.getAppTag())); } catch (Exception e) { response.fail(e.toString()); logger.error(String.format("error pushImage: %s", request), e); } logger.info(String.format("end pushImage: %s", response)); }
Example #4
Source File: PushImageCmd.java From docker-java with Apache License 2.0 | 6 votes |
@Override default ResultCallback.Adapter<PushResponseItem> start() { return exec(new ResultCallback.Adapter<PushResponseItem>() { @Nullable private PushResponseItem latestItem = null; @Override public void onNext(PushResponseItem item) { this.latestItem = item; } @Override protected void throwFirstError() { super.throwFirstError(); if (latestItem == null) { throw new DockerClientException("Could not push image"); } else if (latestItem.isErrorIndicated()) { throw new DockerClientException("Could not push image: " + latestItem.getError()); } } }); }
Example #5
Source File: PushImageCmdExec.java From docker-java with Apache License 2.0 | 6 votes |
@Override protected Void execute0(PushImageCmd command, ResultCallback<PushResponseItem> resultCallback) { WebTarget webResource = getBaseResource().path("/images/{imageName}/push") .resolveTemplate("imageName", command.getName()) .queryParam("tag", command.getTag()); LOGGER.trace("POST: {}", webResource); InvocationBuilder builder = resourceWithAuthConfig(command.getAuthConfig(), webResource.request()) .accept(MediaType.APPLICATION_JSON); builder.post(null, new TypeReference<PushResponseItem>() { }, resultCallback); return null; }
Example #6
Source File: DockerArtifactHandler.java From module-ballerina-docker with Apache License 2.0 | 5 votes |
@Override public void onNext(PushResponseItem item) { // handling error if (item.isErrorIndicated()) { StringBuilder errString = new StringBuilder("[push][error]: "); ResponseItem.ErrorDetail errDetail = null; if (null != item.getErrorDetail()) { errDetail = item.getErrorDetail(); } if (null != errDetail && null != errDetail.getCode()) { errString.append("(").append(errDetail.getCode()).append(") "); } if (null != errDetail && null != errDetail.getMessage()) { errString.append(errDetail.getMessage()); } String errorMessage = errString.toString(); printDebug(errorMessage); dockerPushError.setErrorMsg("unable to push docker image: " + errorMessage); } String streamLog = item.getStream(); if (null != streamLog && !"".equals(streamLog.replaceAll("\n", ""))) { printDebug("[push][stream] " + streamLog.replaceAll("\n", "")); } String statusLog = item.getStatus(); if (null != statusLog && !"".equals(statusLog.replaceAll("\n", ""))) { printDebug("[push][status] " + statusLog.replaceAll("\n", "")); } String idLog = item.getId(); if (null != idLog) { printDebug("[push][ID]: " + idLog); } super.onNext(item); }
Example #7
Source File: DockerBuilderPublisher.java From docker-plugin with MIT License | 5 votes |
private void pushImages() throws IOException { for (String tagToUse : tagsToUse) { Identifier identifier = Identifier.fromCompoundString(tagToUse); PushImageResultCallback resultCallback = new PushImageResultCallback() { @Override public void onNext(PushResponseItem item) { if (item == null) { // docker-java not happy if you pass it nulls. log("Received NULL Push Response. Ignoring"); return; } printResponseItemToListener(listener, item); super.onNext(item); } }; try(final DockerClient client = getClientWithNoTimeout()) { PushImageCmd cmd = client.pushImageCmd(identifier); int i = identifier.repository.name.indexOf('/'); String regName = i >= 0 ? identifier.repository.name.substring(0,i) : null; DockerCloud.setRegistryAuthentication(cmd, new DockerRegistryEndpoint(regName, getPushCredentialsId()), run.getParent().getParent()); cmd.exec(resultCallback).awaitSuccess(); } catch (DockerException ex) { // Private Docker registries fall over regularly. Tell the user so they // have some clue as to what to do as the exception gives no hint. log("Exception pushing docker image. Check that the destination registry is running."); throw ex; } } }
Example #8
Source File: PushImageResultCallback.java From docker-java with Apache License 2.0 | 4 votes |
@Override public void onNext(PushResponseItem item) { this.latestItem = item; LOGGER.debug(item.toString()); }
Example #9
Source File: PushImageCmd.java From docker-java with Apache License 2.0 | 2 votes |
/** * @throws NotFoundException * No such image */ @Override <T extends ResultCallback<PushResponseItem>> T exec(T resultCallback);