def choose_context()

in projects/enable-irsa/src/main.py [0:0]


def choose_context():
    try:
        config.load_kube_config()
    except Exception:
        print(f'Could not find kubeconfig in the default location.')
        return None
    contexts, active_context = config.list_kube_config_contexts()
    if not contexts:
        print("Cannot find any context in kube-config file.")
        exit()
    contexts = [context['name'] for context in contexts]
    active_index = contexts.index(active_context['name'])
    selected, first_index = pick(contexts, title="Pick the context to run this against (press SPACE to mark, ENTER to continue): ", default_index=active_index)
    return selected