Skip to content

Commit

Permalink
Fix drenv delete when kubeconfig is empty
Browse files Browse the repository at this point in the history
If start failed before any kubeconfig was would get None instead of an
empty list, and fail with:

    % drenv delete envs/regional-dr.yaml
    2024-10-09 19:05:17,766 INFO    [rdr] Deleting environment
    2024-10-09 19:05:17,769 INFO    [dr1] Deleting lima cluster
    2024-10-09 19:05:17,769 INFO    [dr2] Deleting lima cluster
    2024-10-09 19:05:17,769 INFO    [hub] Deleting lima cluster
    2024-10-09 19:05:17,795 INFO    [dr1] Deleting disk dr1-disk0
    2024-10-09 19:05:17,827 ERROR   Command failed
    Traceback (most recent call last):
        ...
      File "/Users/nsoffer/src/ramen/test/drenv/kubeconfig.py", line 55, in remove
        new = [v for v in old if v["name"] != profile["name"]]
                          ^^^
    TypeError: 'NoneType' object is not iterable
  • Loading branch information
nirs authored and ShyamsundarR committed Oct 9, 2024
1 parent bed4c01 commit 0dfc251
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/drenv/kubeconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def remove(profile, target=DEFAULT_CONFIG):
return

for k in ("contexts", "clusters", "users"):
old = config.get(k, [])
old = config.get(k) or []
new = [v for v in old if v["name"] != profile["name"]]
if len(new) < len(old):
config[k] = new
Expand Down

0 comments on commit 0dfc251

Please sign in to comment.