Skip to content

Commit a7d7d64

Browse files
committed
Fixed token issue
1 parent 00e6175 commit a7d7d64

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

provider-kubeconfig.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -347,17 +347,21 @@ def _create_secret(self, sa, namespace, kubeconfig):
347347

348348
def _extract_kubeconfig(self, sa, namespace, filename, serverip="", kubecfg="", cluster_name=None):
349349
"""Extract token from secret, determine server URL, build kubeconfig and store in ConfigMap."""
350+
token_found = False
350351
token = ""
351-
while not token:
352-
out, _ = run_command(" kubectl describe secret " + sa + " -n " + namespace + kubecfg)
352+
while not token_found:
353+
out, _ = run_command(
354+
" kubectl describe secret " + sa + " -n " + namespace + kubecfg
355+
)
356+
token = ""
353357
for line in (out or "").split("\n"):
354-
if "token" in line:
355-
parts = line.split(":")
356-
if len(parts) > 1:
357-
token = parts[1].strip()
358-
break
359-
if not token:
360-
time.sleep(2)
358+
parts = line.split(":", 1)
359+
if len(parts) == 2 and parts[0].strip() == "token":
360+
token = parts[1].strip()
361+
if token != "":
362+
token_found = True
363+
else:
364+
time.sleep(2)
361365

362366
out, _ = run_command(" kubectl get secret " + sa + " -n " + namespace + " -o json " + kubecfg)
363367
json_out = json.loads(out or "{}")

0 commit comments

Comments
 (0)