spoved/kube-client.cr

Can't get a pod's logs due to type error

emeraldarcher opened this issue · 2 comments

https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#read-log-pod-v1-core

pod_log_resource_client = kubeClient.api("v1").resource("pods/log")
logs = pod_log_resource_client.get(pod.metadata.not_nil!.name.not_nil!)

The return type is a String so there is a type error when trying to convert to the Pod type

Problem spot: https://github.com/spoved/kube-client.cr/blob/master/src/kube/resource_client.cr#L169

adding a method to the resource_client to return as type string instead of T would work

 # returns response body as a String instead of T
    def get_as_string(name, namespace = @namespace)
      @transport.request(
        method: "GET",
        path: path(name, namespace: namespace),
        response_class: @resource_class
      ).as(String)
    end

Closing because #2 provides a work around.