From 9850b70283c47ce8f8ac1d28b1f49c89ec480813 Mon Sep 17 00:00:00 2001 From: Jeff Schroeder Date: Wed, 30 Nov 2016 13:03:25 -0600 Subject: [PATCH 1/2] Make the README example code more portable Also, the `$HOME` variable can be modified while `os.path.expanduser()` does the right thing. This works on windows as well whereas the previous code did not. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 855b24f25..e477d73da 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ import os from kubernetes import client, config # Configs can be set in Configuration class directly or using helper utility -config.load_kube_config(os.environ["HOME"] + '/.kube/config') +config.load_kube_config(os.path.join(os.path.expanduser('~'), '.kube', 'config') v1=client.CoreV1Api() print("Listing pods with their IPs:") @@ -48,7 +48,7 @@ import os from kubernetes import client, config, watch # Configs can be set in Configuration class directly or using helper utility -config.load_kube_config(os.environ["HOME"] + '/.kube/config') +config.load_kube_config(os.path.join(os.path.expanduser('~'), '.kube', 'config') v1 = client.CoreV1Api() count = 10 From 699d71cfac533c27d4afd2462f36c047c2eb7297 Mon Sep 17 00:00:00 2001 From: Jeff Schroeder Date: Wed, 30 Nov 2016 19:43:34 -0600 Subject: [PATCH 2/2] Make example code using `config.load_kube_config()` more portable --- examples/example1.py | 2 +- examples/example2.py | 2 +- examples/example3.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/example1.py b/examples/example1.py index 0aeed2016..e74be96cf 100644 --- a/examples/example1.py +++ b/examples/example1.py @@ -20,7 +20,7 @@ from kubernetes import client, config def main(): # Configs can be set in Configuration class directly or using helper # utility - config.load_kube_config(os.environ["HOME"] + '/.kube/config') + config.load_kube_config(os.path.join(os.path.expanduser('~'), '.kube', 'config') v1 = client.CoreV1Api() print("Listing pods with their IPs:") diff --git a/examples/example2.py b/examples/example2.py index f594407d8..a02d56355 100644 --- a/examples/example2.py +++ b/examples/example2.py @@ -20,7 +20,7 @@ from kubernetes import client, config, watch def main(): # Configs can be set in Configuration class directly or using helper # utility - config.load_kube_config(os.environ["HOME"] + '/.kube/config') + config.load_kube_config(os.path.join(os.path.expanduser('~'), '.kube', 'config') v1 = client.CoreV1Api() count = 10 diff --git a/examples/example3.py b/examples/example3.py index deb1abcff..01f152bd3 100644 --- a/examples/example3.py +++ b/examples/example3.py @@ -20,7 +20,7 @@ from kubernetes import client, config def main(): # Configs can be set in Configuration class directly or using helper # utility - config.load_kube_config(os.environ["HOME"] + '/.kube/config') + config.load_kube_config(os.path.join(os.path.expanduser('~'), '.kube', 'config') print("Supported APIs (* is preferred version):") print("%-20s %s" %