I'd like to do the Java equivalent of the Kubernetes Go client's ability to create a URL to a resource without having to manually construct it.
In Go, using Kubernetes' client-go/rest/client.go
, it's something like this:
u := client.Post()
.Resource("pods")
.Namespace("fred")
.Name("podname")
.URL()
(Note: I am no kind of Go programmer.)
I don't see anything in the undocumented KubernetesClient
interface that would let me do the equivalent. Is there something I'm missing?
It looks like I can do something like this:
final DefaultKubernetesClient client = new DefaultKubernetesClient();
final NonNamespaceOperation<Pod, PodList, DoneablePod, PodResource<Pod, DoneablePod>> foo = client.pods().inNamespace("kube-system");
assert foo instanceof OperationSupport;
final URL url = ((OperationSupport)foo).getNamespacedUrl();
Obviously this isn't great from a super-clean perspective (the return value of pods()
is an OperationSupport
only because of the way it's implemented, not by contract) but it is a way to do it.