diff --git a/oks_cli/utils.py b/oks_cli/utils.py index fd068f3..6f181ee 100644 --- a/oks_cli/utils.py +++ b/oks_cli/utils.py @@ -309,8 +309,13 @@ def login_profile(name): Raises an exception if the profile does not exist or lacks required info. """ _, PROFILE_FILE = get_config_path() + + # check is profile name is defined by user as environment variable if name is None: - name = "default" + if os.getenv('OKS_PROFILE') is None: + name = "default" + else: + name = os.getenv('OKS_PROFILE') if os.path.exists(PROFILE_FILE): with open(PROFILE_FILE, 'r') as file: @@ -636,7 +641,14 @@ def shell_completions(ctx, param: click.core.Option, incomplete): CONFIG_FOLDER, _ = get_config_path() profiles = profile_list() - profile = ctx.params["profile"] or ctx.parent.params["profile"] or ctx.parent.parent.params["profile"] or "default" + profile = ctx.params["profile"] or ctx.parent.params["profile"] or ctx.parent.parent.params["profile"] or None + + # Check if OKS_PROFILE is set somehow + if profile is None: + if os.getenv('OKS_PROFILE') is None: + profile = 'default' + else: + profile = os.getenv('OKS_PROFILE') if profile not in profiles: return []