com.github.dockerjava.api.model.Identifier Java Examples

The following examples show how to use com.github.dockerjava.api.model.Identifier. 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: DockerServiceImpl.java    From Dolphin with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: DockerClientImpl.java    From docker-java with Apache License 2.0 5 votes vote down vote up
@Override
public PushImageCmd pushImageCmd(Identifier identifier) {
    PushImageCmd cmd = pushImageCmd(identifier.repository.name);
    if (identifier.tag.isPresent()) {
        cmd.withTag(identifier.tag.get());
    }

    AuthConfig cfg = dockerClientConfig.effectiveAuthConfig(identifier.repository.name);
    if (cfg != null) {
        cmd.withAuthConfig(cfg);
    }

    return cmd;
}
 
Example #3
Source File: DockerBuilderPublisher.java    From docker-plugin with MIT License 5 votes vote down vote up
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 #4
Source File: DelegatingDockerClient.java    From docker-plugin with MIT License 4 votes vote down vote up
@Override
public PushImageCmd pushImageCmd(Identifier arg0) {
    return getDelegate().pushImageCmd(arg0);
}
 
Example #5
Source File: DockerClient.java    From docker-java with Apache License 2.0 votes vote down vote up
PushImageCmd pushImageCmd(@Nonnull Identifier identifier);