Skip to content

Commit 9850b70

Browse files
authored
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.
1 parent ff9295b commit 9850b70

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import os
3131
from kubernetes import client, config
3232

3333
# Configs can be set in Configuration class directly or using helper utility
34-
config.load_kube_config(os.environ["HOME"] + '/.kube/config')
34+
config.load_kube_config(os.path.join(os.path.expanduser('~'), '.kube', 'config')
3535

3636
v1=client.CoreV1Api()
3737
print("Listing pods with their IPs:")
@@ -48,7 +48,7 @@ import os
4848
from kubernetes import client, config, watch
4949

5050
# Configs can be set in Configuration class directly or using helper utility
51-
config.load_kube_config(os.environ["HOME"] + '/.kube/config')
51+
config.load_kube_config(os.path.join(os.path.expanduser('~'), '.kube', 'config')
5252

5353
v1 = client.CoreV1Api()
5454
count = 10

0 commit comments

Comments
 (0)