io.fabric8.openshift.api.model.DeploymentConfigList Java Examples

The following examples show how to use io.fabric8.openshift.api.model.DeploymentConfigList. 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: DeploymentConfigTest.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
@Test
public void testList() {
 server.expect().withPath("/apis/apps.openshift.io/v1/namespaces/test/deploymentconfigs").andReturn(200, new DeploymentConfigListBuilder().build()).once();
 server.expect().withPath("/apis").andReturn(200, new APIGroupListBuilder()
    .addNewGroup()
    .withApiVersion("v1")
    .withName("autoscaling.k8s.io")
    .endGroup()
    .addNewGroup()
    .withApiVersion("v1")
    .withName("security.openshift.io")
    .endGroup()
    .build()).always();
 server.expect().withPath("/apis/apps.openshift.io/v1/namespaces/ns1/deploymentconfigs").andReturn(200, new DeploymentConfigListBuilder()
    .addNewItem().and()
    .addNewItem().and().build()).once();

 server.expect().withPath("/apis/apps.openshift.io/v1/deploymentconfigs").andReturn(200, new DeploymentConfigListBuilder()
    .addNewItem().and()
    .addNewItem().and()
    .addNewItem()
    .and().build()).once();

  OpenShiftClient client = server.getOpenshiftClient();

  DeploymentConfigList buildConfigList = client.deploymentConfigs().list();
  assertNotNull(buildConfigList);
  assertEquals(0, buildConfigList.getItems().size());

  buildConfigList = client.deploymentConfigs().inNamespace("ns1").list();
  assertNotNull(buildConfigList);
  assertEquals(2, buildConfigList.getItems().size());

  buildConfigList = client.deploymentConfigs().inAnyNamespace().list();
  assertNotNull(buildConfigList);
  assertEquals(3, buildConfigList.getItems().size());
}
 
Example #2
Source File: ListDeploymentConfigs.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  try {
    OpenShiftClient client = new DefaultOpenShiftClient();
    if (!client.supportsOpenShiftAPIGroup(OpenShiftAPIGroups.APPS)) {
      System.out.println("WARNING this cluster does not support the API Group " + OpenShiftAPIGroups.APPS);
      return;
    }
    DeploymentConfigList list = client.deploymentConfigs().list();
    if (list == null) {
      System.out.println("ERROR no list returned!");
      return;
    }
    List<DeploymentConfig> items = list.getItems();
    for (DeploymentConfig item : items) {
      System.out.println("DeploymentConfig " + item.getMetadata().getName() + " has version: " + item.getApiVersion());
    }

    if (items.size() > 0) {
      // lets check .get() too
      DeploymentConfig deploymentConfig = items.get(0);
      String name = deploymentConfig.getMetadata().getName();
      deploymentConfig = client.deploymentConfigs().withName(name).get();
      assertNotNull("No DeploymentConfig found for name " + name, deploymentConfig);
      System.out.println("get() DeploymentConfig " + name + " has version: " + deploymentConfig.getApiVersion());
    }
  } catch (KubernetesClientException e) {
    System.out.println("Failed: " + e);
    e.printStackTrace();
  }
}
 
Example #3
Source File: SupportUtilTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void createSupportZipFileTest() throws IOException {
    final NamespacedOpenShiftClient client = mock(NamespacedOpenShiftClient.class);

    final MixedOperation<Pod, PodList, DoneablePod, PodResource<Pod, DoneablePod>> pods = mock(mixedOperationType());
    when(pods.list()).thenReturn(new PodList());

    when(client.pods()).thenReturn(pods);

    final MixedOperation<BuildConfig, BuildConfigList, DoneableBuildConfig, BuildConfigResource<BuildConfig, DoneableBuildConfig, Void, Build>> bcs = mock(
        mixedOperationType());
    when(bcs.list()).thenReturn(new BuildConfigList());

    when(client.buildConfigs()).thenReturn(bcs);

    final MixedOperation<DeploymentConfig, DeploymentConfigList, DoneableDeploymentConfig, DeployableScalableResource<DeploymentConfig, DoneableDeploymentConfig>> dcs = mock(
        mixedOperationType());
    when(dcs.list()).thenReturn(new DeploymentConfigList());

    when(client.deploymentConfigs()).thenReturn(dcs);

    final MixedOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>> cm = mock(mixedOperationType());
    when(cm.list()).thenReturn(new ConfigMapList());

    when(client.configMaps()).thenReturn(cm);

    final MixedOperation<ImageStreamTag, ImageStreamTagList, DoneableImageStreamTag, Resource<ImageStreamTag, DoneableImageStreamTag>> ist = mock(
        mixedOperationType());
    final ImageStreamTagList istl = new ImageStreamTagList();
    final List<ImageStreamTag> istList = new ArrayList<>();
    final ImageStreamTag imageStreamTag = new ImageStreamTag();
    imageStreamTag.setKind("ImageStreamTag");
    final ObjectMeta objectMeta = new ObjectMeta();
    objectMeta.setName("ImageStreamTag1");
    imageStreamTag.setMetadata(objectMeta);
    istList.add(imageStreamTag);
    istl.setItems(istList);

    when(ist.list()).thenReturn(istl);

    when(client.imageStreamTags()).thenReturn(ist);

    final IntegrationHandler integrationHandler = mock(IntegrationHandler.class);
    when(integrationHandler.list(anyInt(), anyInt())).thenReturn(new EmptyListResult<IntegrationOverview>());
    final IntegrationSupportHandler integrationSupportHandler = mock(IntegrationSupportHandler.class);

    final Logger log = mock(Logger.class);
    final SupportUtil supportUtil = new SupportUtil(client, integrationHandler, integrationSupportHandler, log);

    final Map<String, Boolean> configurationMap = new HashMap<>(ImmutableMap.of("int1", true, "int2", true));

    final File output = supportUtil.createSupportZipFile(configurationMap, 1, 20);

    try (final ZipFile zip = new ZipFile(output)) {
        final ZipEntry imageStreamTag1 = zip.getEntry("descriptors/ImageStreamTag/ImageStreamTag1.YAML");
        assertThat(imageStreamTag1).isNotNull();
        AssertionsForClassTypes.assertThat(zip.getInputStream(imageStreamTag1)).hasContent(SupportUtil.YAML.dump(imageStreamTag));
    }

    verify(log).info("Created Support file: {}", output);
    // tests that we haven't logged any error messages
    verifyZeroInteractions(log);
}
 
Example #4
Source File: DeploymentConfigOperator.java    From strimzi-kafka-operator with Apache License 2.0 4 votes vote down vote up
@Override
protected MixedOperation<DeploymentConfig, DeploymentConfigList, DoneableDeploymentConfig, DeployableScalableResource<DeploymentConfig, DoneableDeploymentConfig>> operation() {
    return client.deploymentConfigs();
}
 
Example #5
Source File: DeploymentConfigCrudTest.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testCrud() {
  OpenShiftClient client = server.getOpenshiftClient();

  DeploymentConfig deploymentConfig1 = new DeploymentConfigBuilder().withNewMetadata()
    .withName("deploymentConfig1")
    .withNamespace("ns1")
    .addToLabels("testKey", "testValue")
    .endMetadata()
    .build();

  DeploymentConfig deploymentConfig2 = new DeploymentConfigBuilder().withNewMetadata()
    .withName("deploymentConfig2")
    .withNamespace("ns1")
    .addToLabels("testKey", "testValue")
    .endMetadata()
    .build();

  DeploymentConfig deploymentConfig3 = new DeploymentConfigBuilder().withNewMetadata()
    .withName("deploymentConfig3")
    .addToLabels("testKey", "testValue")
    .withNamespace("ns2")
    .endMetadata()
    .build();

  client.deploymentConfigs().inNamespace("ns1").create(deploymentConfig1);
  client.deploymentConfigs().inNamespace("ns1").create(deploymentConfig2);
  client.deploymentConfigs().inNamespace("ns2").create(deploymentConfig3);

  DeploymentConfigList aDeploymentConfigList = client.deploymentConfigs().list();
  assertNotNull(aDeploymentConfigList);
  assertEquals(0, aDeploymentConfigList.getItems().size());

  aDeploymentConfigList = client.deploymentConfigs().inAnyNamespace().list();
  assertNotNull(aDeploymentConfigList);
  assertEquals(3, aDeploymentConfigList.getItems().size());

  aDeploymentConfigList = client.deploymentConfigs().inNamespace("ns1").list();
  assertNotNull(aDeploymentConfigList);
  assertEquals(2, aDeploymentConfigList.getItems().size());

  aDeploymentConfigList = client.deploymentConfigs().inNamespace("ns1")
    .withLabels(Collections.singletonMap("testKey", "testValue")).list();
  assertNotNull(aDeploymentConfigList);
  assertEquals(2, aDeploymentConfigList.getItems().size());

  deploymentConfig3 = client.deploymentConfigs().inNamespace("ns2").withName("deploymentConfig3").edit()
    .editMetadata().addToLabels("testkey1","testvalue2").endMetadata()
    .done();
  assertNotNull(deploymentConfig3);
  assertEquals(2, deploymentConfig3.getMetadata().getLabels().size());

  // ! Doesn't work
  // boolean bDeleted = client.deploymentConfigs().inNamespace("ns1").withName("deploymentConfig2").delete();
  // assertTrue(bDeleted);
}
 
Example #6
Source File: DeploymentConfigIT.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Test
public void list() {
  DeploymentConfigList aDeploymentConfigList = client.deploymentConfigs().inNamespace(currentNamespace).list();
  assertThat(aDeploymentConfigList).isNotNull();
  assertEquals(1, aDeploymentConfigList.getItems().size());
}
 
Example #7
Source File: DeploymentConfigOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public DeploymentConfigOperationsImpl(RollingOperationContext context) {
  super(context.withApiGroupName(APPS).withPlural("deploymentconfigs"));
  this.type = DeploymentConfig.class;
  this.listType = DeploymentConfigList.class;
  this.doneableType = DoneableDeploymentConfig.class;
}
 
Example #8
Source File: DefaultOpenShiftClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public MixedOperation<DeploymentConfig, DeploymentConfigList, DoneableDeploymentConfig, DeployableScalableResource<DeploymentConfig, DoneableDeploymentConfig>> deploymentConfigs() {
  return new DeploymentConfigOperationsImpl(httpClient, OpenShiftConfig.wrap(getConfiguration()));
}