kelproject / pykube

Python client library for Kubernetes
Apache License 2.0
349 stars 183 forks source link

can't support windows platform? #124

Open xiaoxiaoye opened 7 years ago

xiaoxiaoye commented 7 years ago

when i operate Node,i find that i can create,but cann't delete.so i analyse the url,i add some code(print(kw["url"])) to see what the url like. in the window,the url is wrong,it like "http://127.0.01/nodes\centos1" the reason is that in windows platform os.path.join function will concat path use "\",not "\/"

def api_kwargs(self, **kwargs):
        kw = {}
        # Construct url for api request
        obj_list = kwargs.pop("obj_list", False)
        if obj_list:
            kw["url"] = self.endpoint
        else:
            operation = kwargs.pop("operation", "")
            kw["url"] = op.normpath(op.join(self.endpoint, self.name, operation))
        print(kw["url"])

useage:

api = pykube.HTTPClient(pykube.KubeConfig.from_file("./kubeconfig"))
obj_node = {
    "apiVersion": "v1",
    "kind": "Node",
    "metadata": {
        "name": "centos1",
        "labels": {
            "hostname": "centos1"
        }
    }
}
#pykube.Node(api,obj_node).create()
pykube.Node(api,obj_node).delete()

output:

nodes\centos1