@Test public void testGetPodsbyLabel_WithNullLabel_ThrowsIllegalArgumentException() throws Exception { this.exception.expect(IllegalArgumentException.class); this.service.getPodsByLabel(null); }
public List<KubernetesPod> getPodsByLabel(String label) throws VmidcException { List<KubernetesPod> resultPodList = new ArrayList<KubernetesPod>(); if (label == null) { throw new IllegalArgumentException("Label should not be null"); } try { PodList pods = getKubernetesClient().pods().withLabel(label).list(); if (pods == null || pods.getItems() == null || pods.getItems().isEmpty()) { return resultPodList; } for (Pod pod : pods.getItems()) { resultPodList.add( new KubernetesPod( pod.getMetadata().getName(), pod.getMetadata().getNamespace(), pod.getMetadata().getUid(), pod.getSpec().getNodeName()) ); } } catch (KubernetesClientException e) { throw new VmidcException("Failed to get Pods"); } return resultPodList; }
KubernetesPodApi extends KubernetesApi { public List<KubernetesPod> getPodsByLabel(String label) throws VmidcException { List<KubernetesPod> resultPodList = new ArrayList<KubernetesPod>(); if (label == null) { throw new IllegalArgumentException("Label should not be null"); } try { PodList pods = getKubernetesClient().pods().withLabel(label).list(); if (pods == null || pods.getItems() == null || pods.getItems().isEmpty()) { return resultPodList; } for (Pod pod : pods.getItems()) { resultPodList.add( new KubernetesPod( pod.getMetadata().getName(), pod.getMetadata().getNamespace(), pod.getMetadata().getUid(), pod.getSpec().getNodeName()) ); } } catch (KubernetesClientException e) { throw new VmidcException("Failed to get Pods"); } return resultPodList; } }
KubernetesPodApi extends KubernetesApi { public List<KubernetesPod> getPodsByLabel(String label) throws VmidcException { List<KubernetesPod> resultPodList = new ArrayList<KubernetesPod>(); if (label == null) { throw new IllegalArgumentException("Label should not be null"); } try { PodList pods = getKubernetesClient().pods().withLabel(label).list(); if (pods == null || pods.getItems() == null || pods.getItems().isEmpty()) { return resultPodList; } for (Pod pod : pods.getItems()) { resultPodList.add( new KubernetesPod( pod.getMetadata().getName(), pod.getMetadata().getNamespace(), pod.getMetadata().getUid(), pod.getSpec().getNodeName()) ); } } catch (KubernetesClientException e) { throw new VmidcException("Failed to get Pods"); } return resultPodList; } KubernetesPodApi(KubernetesClient client); }
KubernetesPodApi extends KubernetesApi { public List<KubernetesPod> getPodsByLabel(String label) throws VmidcException { List<KubernetesPod> resultPodList = new ArrayList<KubernetesPod>(); if (label == null) { throw new IllegalArgumentException("Label should not be null"); } try { PodList pods = getKubernetesClient().pods().withLabel(label).list(); if (pods == null || pods.getItems() == null || pods.getItems().isEmpty()) { return resultPodList; } for (Pod pod : pods.getItems()) { resultPodList.add( new KubernetesPod( pod.getMetadata().getName(), pod.getMetadata().getNamespace(), pod.getMetadata().getUid(), pod.getSpec().getNodeName()) ); } } catch (KubernetesClientException e) { throw new VmidcException("Failed to get Pods"); } return resultPodList; } KubernetesPodApi(KubernetesClient client); List<KubernetesPod> getPodsByLabel(String label); KubernetesPod getPodById(String uid, String namespace, String name); }
KubernetesPodApi extends KubernetesApi { public List<KubernetesPod> getPodsByLabel(String label) throws VmidcException { List<KubernetesPod> resultPodList = new ArrayList<KubernetesPod>(); if (label == null) { throw new IllegalArgumentException("Label should not be null"); } try { PodList pods = getKubernetesClient().pods().withLabel(label).list(); if (pods == null || pods.getItems() == null || pods.getItems().isEmpty()) { return resultPodList; } for (Pod pod : pods.getItems()) { resultPodList.add( new KubernetesPod( pod.getMetadata().getName(), pod.getMetadata().getNamespace(), pod.getMetadata().getUid(), pod.getSpec().getNodeName()) ); } } catch (KubernetesClientException e) { throw new VmidcException("Failed to get Pods"); } return resultPodList; } KubernetesPodApi(KubernetesClient client); List<KubernetesPod> getPodsByLabel(String label); KubernetesPod getPodById(String uid, String namespace, String name);  }