当前位置: 首页>>代码示例>>Java>>正文


Java PushImageResultCallback类代码示例

本文整理汇总了Java中com.github.dockerjava.core.command.PushImageResultCallback的典型用法代码示例。如果您正苦于以下问题:Java PushImageResultCallback类的具体用法?Java PushImageResultCallback怎么用?Java PushImageResultCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PushImageResultCallback类属于com.github.dockerjava.core.command包,在下文中一共展示了PushImageResultCallback类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pushImage

import com.github.dockerjava.core.command.PushImageResultCallback; //导入依赖的package包/类
/**
 * Push image to container registry.
 * @param imageName the name of the image.
 * @throws InvalidCredentialsException if authentication fails.
 */
public void pushImage(String imageName) throws
    InvalidCredentialsException {

  setupDockerClient();

  AuthConfig authConfig = new AuthConfig();
  authConfig.withUsername(registryUsername);
  authConfig.withPassword(registryPassword);
  authConfig.withRegistryAddress(registryUrl);
  authConfig.withEmail(registryEmail);

  dockerClient.pushImageCmd(imageName)
      .withAuthConfig(authConfig)
      .exec(new PushImageResultCallback())
      .awaitSuccess();
}
 
开发者ID:tsiq,项目名称:magic-beanstalk,代码行数:22,代码来源:DockerClientManagerWithAuth.java

示例2: pushImage

import com.github.dockerjava.core.command.PushImageResultCallback; //导入依赖的package包/类
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));
}
 
开发者ID:dianping,项目名称:Dolphin,代码行数:26,代码来源:DockerServiceImpl.java

示例3: call

import com.github.dockerjava.core.command.PushImageResultCallback; //导入依赖的package包/类
public Void call() throws Exception {
    final ConsoleLogger console = new ConsoleLogger(listener);
    DockerClient client = DockerCommand.getClient(descriptor, cfgData.dockerUrlRes, cfgData.dockerVersionRes, cfgData.dockerCertPathRes, authConfig);

    PushImageCmd pushImageCmd = client.pushImageCmd(imageRes).withTag(tagRes);
    PushImageResultCallback callback = new PushImageResultCallback() {
        @Override
        public void onNext(PushResponseItem item) {
            console.logInfo(item.toString());
            super.onNext(item);
        }

        @Override
        public void onError(Throwable throwable) {
            console.logError("Failed to exec start:" + throwable.getMessage());
            super.onError(throwable);
        }
    };
    pushImageCmd.exec(callback).awaitSuccess();
    
    return null;
}
 
开发者ID:jenkinsci,项目名称:docker-build-step-plugin,代码行数:23,代码来源:PushImageRemoteCallable.java

示例4: createPrivateImage

import com.github.dockerjava.core.command.PushImageResultCallback; //导入依赖的package包/类
public static String createPrivateImage(DockerRule dockerRule, String tagName) throws InterruptedException {
    if (privateRegistryAuthConfig == null)
        throw new IllegalStateException("Ensure that you have invoked runPrivateRegistry beforehand.");

    String imgNameWithTag = createTestImage(dockerRule, tagName);

    dockerRule.getClient().pushImageCmd(imgNameWithTag)
            .withAuthConfig(privateRegistryAuthConfig)
            .exec(new PushImageResultCallback())
            .awaitCompletion(30, TimeUnit.SECONDS);

    dockerRule.getClient().removeImageCmd(imgNameWithTag)
            .exec();

    //ensures that the image is available, the private registry needs some time to reflect a tag push
    Thread.sleep(5000);

    return imgNameWithTag;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:20,代码来源:RegistryUtils.java

示例5: testPushImageWithInvalidAuth

import com.github.dockerjava.core.command.PushImageResultCallback; //导入依赖的package包/类
@Test
public void testPushImageWithInvalidAuth() throws Exception {
    AuthConfig invalidAuthConfig = new AuthConfig()
            .withUsername("testuser")
            .withPassword("testwrongpassword")
            .withEmail("[email protected]")
            .withRegistryAddress(authConfig.getRegistryAddress());

    String imgName = RegistryUtils.createTestImage(dockerRule, "push-image-with-invalid-auth");

    exception.expect(DockerClientException.class);

    // stream needs to be fully read in order to close the underlying connection
    dockerRule.getClient().pushImageCmd(imgName)
            .withAuthConfig(invalidAuthConfig)
            .exec(new PushImageResultCallback())
            .awaitCompletion(30, TimeUnit.SECONDS);
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:19,代码来源:PushImageCmdIT.java

示例6: pushImageNoAuth

import com.github.dockerjava.core.command.PushImageResultCallback; //导入依赖的package包/类
/**
 * Push image without authentication.
 * @param imageName the name of the image to be pushed.
 * @throws InvalidCredentialsException if authentication fails.
 */
public void pushImageNoAuth(String imageName) throws
    InvalidCredentialsException {
  setupDockerClient();

  dockerClient.pushImageCmd(imageName)
      .exec(new PushImageResultCallback())
      .awaitSuccess();
}
 
开发者ID:tsiq,项目名称:magic-beanstalk,代码行数:14,代码来源:DockerClientManagerWithAuth.java

示例7: pushLatest

import com.github.dockerjava.core.command.PushImageResultCallback; //导入依赖的package包/类
@Test
public void pushLatest() throws Exception {
    CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("true").exec();

    LOG.info("Created container {}", container.toString());
    assertThat(container.getId(), not(isEmptyString()));

    LOG.info("Committing container: {}", container.toString());
    String imgName = authConfig.getRegistryAddress() + "/" + dockerRule.getKind() + "-push-latest";
    String imageId = dockerRule.getClient().commitCmd(container.getId())
            .withRepository(imgName)
            .exec();

    // we have to block until image is pushed
    dockerRule.getClient().pushImageCmd(imgName)
            .withAuthConfig(authConfig)
            .exec(new PushImageResultCallback())
            .awaitCompletion(30, TimeUnit.SECONDS);

    LOG.info("Removing image: {}", imageId);
    dockerRule.getClient().removeImageCmd(imageId).exec();

    dockerRule.getClient().pullImageCmd(imgName)
            .withTag("latest")
            .withAuthConfig(authConfig)
            .exec(new PullImageResultCallback())
            .awaitCompletion(30, TimeUnit.SECONDS);
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:29,代码来源:PushImageCmdIT.java

示例8: pushNonExistentImage

import com.github.dockerjava.core.command.PushImageResultCallback; //导入依赖的package包/类
@Test
public void pushNonExistentImage() throws Exception {

    if (isNotSwarm(dockerRule.getClient()) && getVersion(dockerRule.getClient())
            .isGreaterOrEqual(RemoteApiVersion.VERSION_1_24)) {
        exception.expect(DockerClientException.class);
    } else {
        exception.expect(NotFoundException.class);
    }

    dockerRule.getClient().pushImageCmd(username + "/xxx")
            .exec(new PushImageResultCallback())
            .awaitCompletion(30, TimeUnit.SECONDS); // exclude infinite await sleep

}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:16,代码来源:PushImageCmdIT.java

示例9: testPushImageWithValidAuth

import com.github.dockerjava.core.command.PushImageResultCallback; //导入依赖的package包/类
@Test
public void testPushImageWithValidAuth() throws Exception {
    String imgName = RegistryUtils.createTestImage(dockerRule, "push-image-with-valid-auth");

    // stream needs to be fully read in order to close the underlying connection
    dockerRule.getClient().pushImageCmd(imgName)
            .withAuthConfig(authConfig)
            .exec(new PushImageResultCallback())
            .awaitCompletion(30, TimeUnit.SECONDS);
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:11,代码来源:PushImageCmdIT.java

示例10: testPushImageWithNoAuth

import com.github.dockerjava.core.command.PushImageResultCallback; //导入依赖的package包/类
@Test
public void testPushImageWithNoAuth() throws Exception {
    String imgName = RegistryUtils.createTestImage(dockerRule, "push-image-with-no-auth");

    exception.expect(DockerClientException.class);

    // stream needs to be fully read in order to close the underlying connection
    dockerRule.getClient().pushImageCmd(imgName)
            .exec(new PushImageResultCallback())
            .awaitCompletion(30, TimeUnit.SECONDS);
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:12,代码来源:PushImageCmdIT.java

示例11: pushImages

import com.github.dockerjava.core.command.PushImageResultCallback; //导入依赖的package包/类
private void pushImages() throws IOException {
    for (String tagToUse : tagsToUse) {
        Identifier identifier = Identifier.fromCompoundString(tagToUse);
        PushImageResultCallback resultCallback = new PushImageResultCallback() {
            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 {
            PushImageCmd cmd = getClient().pushImageCmd(identifier);

            int i = identifier.repository.name.indexOf('/');
            String registry = i >= 0 ?
                    identifier.repository.name.substring(0,i) : null;

            DockerCloud.setRegistryAuthentication(cmd,
                    new DockerRegistryEndpoint(registry, pushCredentialsId),
                    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;
        }
    }
}
 
开发者ID:jenkinsci,项目名称:docker-plugin,代码行数:34,代码来源:DockerBuilderPublisher.java

示例12: fromPrivateRegistry

import com.github.dockerjava.core.command.PushImageResultCallback; //导入依赖的package包/类
@Test
    public void fromPrivateRegistry() throws Exception {
        AuthConfig authConfig = RegistryUtils.runPrivateRegistry(dockerRule.getClient());
        String imgName = authConfig.getRegistryAddress() + "/testuser/busybox";

        File dockerfile = folder.newFile("Dockerfile");
        writeStringToFile(dockerfile, "FROM " + imgName);

        File baseDir;
        InspectImageResponse inspectImageResponse;

        dockerRule.getClient().authCmd().withAuthConfig(authConfig).exec();
        dockerRule.getClient().tagImageCmd("busybox:latest", imgName, "latest")
                .withForce()
                .exec();

        dockerRule.getClient().pushImageCmd(imgName)
                .withTag("latest")
                .withAuthConfig(authConfig)
                .exec(new PushImageResultCallback())
                .awaitCompletion(30, TimeUnit.SECONDS);

        dockerRule.getClient().removeImageCmd(imgName)
                .withForce(true)
                .exec();

//        baseDir = fileFromBuildTestResource("FROM/privateRegistry");
        baseDir = folder.getRoot();

        AuthConfigurations authConfigurations = new AuthConfigurations();
        authConfigurations.addConfig(authConfig);

        String imageId = dockerRule.getClient().buildImageCmd(baseDir)
                .withNoCache(true)
                .withBuildAuthConfigs(authConfigurations)
                .exec(new BuildImageResultCallback())
                .awaitImageId();

        inspectImageResponse = dockerRule.getClient().inspectImageCmd(imageId).exec();
        assertThat(inspectImageResponse, not(nullValue()));
        LOG.info("Image Inspect: {}", inspectImageResponse.toString());
    }
 
开发者ID:docker-java,项目名称:docker-java,代码行数:43,代码来源:BuildImageCmdIT.java


注:本文中的com.github.dockerjava.core.command.PushImageResultCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。