use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.
the class J4pClientProvider method lookup.
@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
KubernetesClient client = this.clientInstance.get();
Session session = this.sessionInstance.get();
JolokiaClients jolokiaClients = new JolokiaClients(client);
String serviceName = getServiceName(qualifiers);
String podName = getPodName(qualifiers);
String replicationControllerName = getReplicationControllerName(qualifiers);
if (Strings.isNotBlank(serviceName)) {
Service service = client.services().inNamespace(session.getNamespace()).withName(serviceName).get();
if (service != null) {
return jolokiaClients.clientForService(service);
}
}
if (Strings.isNotBlank(podName)) {
Pod pod = client.pods().inNamespace(session.getNamespace()).withName(serviceName).get();
if (pod != null) {
return jolokiaClients.clientForPod(pod);
}
}
if (Strings.isNotBlank(replicationControllerName)) {
ReplicationController replicationController = client.replicationControllers().inNamespace(session.getNamespace()).withName(replicationControllerName).get();
if (replicationController != null) {
return jolokiaClients.clientForReplicationController(replicationController);
}
}
return null;
}
use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.
the class PodResourceProvider method lookup.
@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
KubernetesClient client = this.clientInstance.get();
Session session = sessionInstance.get();
String name = getPodName(qualifiers);
if (name != null) {
return client.pods().inNamespace(session.getNamespace()).withName(name).get();
}
// Gets the first pod found that matches the labels.
Map<String, String> labels = getLabels(qualifiers);
PodList list = client.pods().inNamespace(session.getNamespace()).withLabels(labels).list();
List<Pod> pods = notNullList(list.getItems());
if (!pods.isEmpty()) {
return pods.get(0);
}
return null;
}
use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.
the class ReplicationControllerListResourceProvider method lookup.
@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
KubernetesClient client = this.clientInstance.get();
Session session = sessionInstance.get();
Map<String, String> labels = getLabels(qualifiers);
if (labels.isEmpty()) {
return client.replicationControllers().inNamespace(session.getNamespace()).list();
} else {
return client.replicationControllers().inNamespace(session.getNamespace()).withLabels(labels).list();
}
}
use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.
the class ReplicationControllerResourceProvider method lookup.
@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
KubernetesClient client = this.clientInstance.get();
Session session = sessionInstance.get();
String name = getReplicationControllerName(qualifiers);
return client.replicationControllers().inNamespace(session.getNamespace()).withName(name).get();
}
use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.
the class ServiceResourceProvider method lookup.
@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
KubernetesClient client = this.clientInstance.get();
Session session = sessionInstance.get();
String name = getServiceName(qualifiers);
return client.services().inNamespace(session.getNamespace()).withName(name).get();
}
Aggregations