Skip to content

Commit 2713057

Browse files
committed
users: make the .kube directory creation better
I didn't like the way I originally checked for the directory, then created it -- all the while using hard-coded values. This one-liner will attempt to make the directory based on KUBECONFIG and if it exists, then it won't complain. However, if it does not exist, it will create it. This also should solve the case of the user having a bespoke KUBECONFIG directory in which they deleted their "config" file. Now, we will use their bespoke path and create the config file in their preferred location.
1 parent a74b689 commit 2713057

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/warnet/users.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ def auth(auth_config):
2222

2323
is_first_config = False
2424
if not os.path.exists(KUBECONFIG):
25-
kube_folder = os.path.join(os.path.expanduser("~"), ".kube")
26-
if not os.path.exists(kube_folder):
27-
os.makedirs(kube_folder)
25+
os.makedirs(os.path.dirname(KUBECONFIG), exist_ok=True)
2826
try:
2927
write_kubeconfig(auth_config, KUBECONFIG)
3028
is_first_config = True

0 commit comments

Comments
 (0)