in hawtio-system/src/main/java/io/hawt/web/kubernetes/PodServlet.java [36:89]
protected ProxyAddress parseProxyAddress(HttpServletRequest servletRequest) {
String reqQueryString = servletRequest.getQueryString();
String queryPostfix = "";
if (Strings.isNotBlank(reqQueryString)) {
queryPostfix = "?" + reqQueryString;
}
String userName = null;
String password = null;
String podName = servletRequest.getPathInfo();
if (podName == null) {
podName = "";
}
if (podName.startsWith("/")) {
podName = podName.substring(1);
}
int idx = podName.indexOf('/');
String podPort = "";
String podPath = "/";
if (idx > 0) {
podPath = podName.substring(idx);
podName = podName.substring(0, idx);
idx = podPath.indexOf('/', 1);
if (idx >= 0) {
podPort = podPath.substring(1, idx);
podPath = podPath.substring(idx);
}
}
if (podName.isEmpty()) {
// lets list the pods for /pod
String url = ServiceResolver.getSingleton().getServiceURL("kubernetes");
if (url == null) {
return null;
}
url += "/kubernetes/api/v1beta2/pods" + queryPostfix;
return new DefaultProxyAddress(url, userName, password);
}
String url = ServiceResolver.getSingleton().getPodUrl(podName, podPort);
if (url == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("No pod for: " + podName + " port: " + podPort + " path: " + podPath);
}
System.out.println("No pod for: " + podName + " port: " + podPort + " path: " + podPath);
return null;
} else {
url += podPath + queryPostfix;
if (LOG.isDebugEnabled()) {
LOG.debug("Invoking: " + url + " from pod: " + podName + " port: " + podPort + " path: " + podPath);
}
System.out.println("Invoking: " + url + " from pod: " + podName + " port: " + podPort + " path: " + podPath);
return new DefaultProxyAddress(url, userName, password);
}
}