Skip to content

Commit

Permalink
Merge pull request #165 from SoftwareAG/feat-improve-config-guess
Browse files Browse the repository at this point in the history
feat: improve passthrough config guess
  • Loading branch information
reubenmiller committed Feb 5, 2024
2 parents 389489d + f557619 commit 522311f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion c8ylp/cli/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,23 @@ def extract_config_id(matching_config):
return matching_config.get("id")

if not config:
# use first config
# If user has not provide the config, then we can try guessing
if len(config) == 1:
return extract_config_id(valid_configs[0])

# Use first match which uses port 22
configs_using_ssh_port = [c for c in valid_configs if c.get("port", 0) == 22]
if configs_using_ssh_port:
return extract_config_id(configs_using_ssh_port[0])

# Use first match with ssh in its name
configs_with_ssh_name = [
c for c in valid_configs if "ssh" in str(c.get("name", "")).lower()
]
if configs_with_ssh_name:
return extract_config_id(configs_with_ssh_name[0])

# fallback to first config
return extract_config_id(valid_configs[0])

# find config matching name
Expand Down

0 comments on commit 522311f

Please sign in to comment.