Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions oks_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 []
Expand Down