@PUT
 @Path("/{imageStream}")
 @Consumes(MediaType.APPLICATION_JSON)
 @Produces(MediaType.APPLICATION_JSON)
 public ImageStream updateImageStream(
     @PathParam("namespace") String namespace,
     @PathParam("imageStream") String imageStreamName,
     ImageStream imageStream)
     throws ForbiddenException, UnauthorizedException, ServerException {
   if (!imageStreamName.equals(imageStream.getMetadata().getName())) {
     throw new ForbiddenException("Name of resources can read only access mode");
   }
   final IClient client = clientFactory.getOpenshiftClient();
   return toDto(ImageStream.class, client.update(toOpenshiftResource(client, imageStream)));
 }
 @Before
 public void setup() throws Exception {
   when(client.getBaseURL()).thenReturn(new URL("https://localhost:8442"));
   registry = new ConnectionsRegistry();
   connection = new Connection(client, null, null);
   registry.add(connection);
   provider = new OpenShiftExplorerContentProvider();
 }
예제 #3
0
 private void connect(IClient client) {
   WatchKey key = new WatchKey(conn, project, kind);
   if (watches.containsKey(key)) {
     AtomicReference<IWatcher> watcherRef = watches.get(key);
     watcherRef.set(client.watch(project.getName(), this, kind));
     state.set(State.CONNECTED);
     lastConnect = System.currentTimeMillis();
   }
 }
  @POST
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public ImageStream createImageStream(
      @PathParam("namespace") String namespace, ImageStream imageStream)
      throws BadRequestException, UnauthorizedException, ServerException {
    if (imageStream.getKind() == null) {
      imageStream.setKind(ResourceKind.IMAGE_STREAM);
    }
    if (!ResourceKind.IMAGE_STREAM.equals(imageStream.getKind())) {
      throw new BadRequestException(
          imageStream.getKind() + " cannot be handled as a " + ResourceKind.IMAGE_STREAM);
    }

    final IClient client = clientFactory.getOpenshiftClient();
    final IImageStream openshiftImageStream = toOpenshiftResource(client, imageStream);
    return toDto(ImageStream.class, client.create(openshiftImageStream, namespace));
  }
  @Test
  public void getChildrenForConnectionReturnsProjects() {
    List<IProject> projects = Arrays.asList(new IProject[] {project});
    when(client.<IProject>list(ResourceKind.PROJECT)).thenReturn(projects);

    assertArrayEquals(
        "Exp. to get all the projects for a Connection",
        projects.toArray(),
        provider.getChildrenFor(connection));
  }
 @Before
 public void setUp() throws Exception {
   when(project.getName()).thenReturn(NAMESPACE);
   when(parameters.getProject()).thenReturn(project);
   when(parameters.getReplicas()).thenReturn(5);
   when(parameters.getResourceName()).thenReturn("aresourcename");
   when(client.getOpenShiftAPIVersion()).thenReturn("v1");
   factory = new ResourceFactory(client);
   job = spy(new TestDeployImageJob(parameters));
 }