예제 #1
0
  private WebTarget createPushRequestFromTag(final String nameAndTag) {
    ImageDescriptor descriptor = new ImageDescriptor(nameAndTag);
    WebTarget target =
        getServiceEndPoint().path(descriptor.getRegistryRepositoryAndImage()).path("push");

    if (descriptor.getTag().isPresent()) {
      target = target.queryParam("tag", descriptor.getTag().get());
    }

    return target;
  }
예제 #2
0
  public String pullImage(final String image) {
    ImageDescriptor descriptor = new ImageDescriptor(image);

    WebTarget target = getServiceEndPoint().path("create");

    target = target.queryParam("fromImage", descriptor.getRegistryRepositoryAndImage());

    if (descriptor.getTag().isPresent()) {
      target = target.queryParam("tag", descriptor.getTag().get());
    }

    return target
        .request()
        .header(REGISTRY_AUTH_HEADER, getRegistryAuthHeaderValue())
        .accept(MediaType.APPLICATION_JSON_TYPE)
        .post(null, String.class);
  }
예제 #3
0
  public void tagImage(final String imageId, final String nameAndTag) {
    ImageDescriptor descriptor = new ImageDescriptor(nameAndTag);

    WebTarget target =
        getServiceEndPoint()
            .path(imageId)
            .path("tag")
            .queryParam("repo", descriptor.getRegistryRepositoryAndImage());

    Optional<String> targetTag = descriptor.getTag();
    if (targetTag.isPresent()) {
      target = target.queryParam("tag", targetTag.get());
    }

    Response response = target.request().accept(MediaType.APPLICATION_JSON_TYPE).post(null);

    Response.StatusType statusInfo = response.getStatusInfo();

    response.close();

    checkImageTargetingResponse(imageId, statusInfo);
  }
예제 #4
0
  public String pullImage(final String image) {
    ImageDescriptor descriptor = new ImageDescriptor(image);

    WebTarget target =
        getServiceEndPoint().path("create").queryParam("fromImage", descriptor.getImage());

    if (descriptor.getRepository().isPresent()) {
      target = target.queryParam("repo", descriptor.getRepository().get());
    }

    if (descriptor.getTag().isPresent()) {
      target = target.queryParam("tag", descriptor.getTag().get());
    }

    if (descriptor.getRegistry().isPresent()) {
      target = target.queryParam("registry", descriptor.getRegistry().get());
    }

    return target.request().accept(MediaType.APPLICATION_JSON_TYPE).post(null, String.class);
  }