kubernetes-client / c

Official C client library for Kubernetes
Apache License 2.0
141 stars 45 forks source link

Is it possible to change the cURL HTTP accpet header? #211

Closed 903d09f6-e821-4655-9e8b-7e6068b26f74 closed 6 months ago

903d09f6-e821-4655-9e8b-7e6068b26f74 commented 6 months ago

Hello. I'm using the output of this project with gratitude. I am currently changing the HTTP accept header of the cURL message sent to the API server as follows:

curl -k -g \
-H "Authorization: Bearer $TOKEN" \
-H 'Accept: application/json;as=Table;g=meta.k8s.io;v=v1' \ <= This part is added..
https://[${KUBERNETES_SERVICE_HOST}]/api/v1/namespaces/$NAMESPACE/pods

By this way, I could collect each pod's status information in table form at once by sending a single cURL command to get all pods. This is an official usage example provided by Kubernetes:

I'd like to know if there is a feature already implemented or planned for this project that can change the HTTP accept header in cURL and parse the changed JSON response accordingly. Or should I implement a generic API myself?

Thank you.

ityuhui commented 6 months ago

Passing custom "Accept header" to the API server is not supported now.

We have already provided a generic client (example) but not support passing "Accetp header" now, you can work based on it.