Use a singular configured cluster by default

If there is...
  1. No '--cluster' passed, and
  2. No 'local' cluster, and
  3. There is exactly one cluster configured
...then use that cluster by default in the CLI.
This commit is contained in:
Joshua Boniface 2022-01-13 18:36:20 -05:00
parent ea709f573f
commit 53aed0a735
1 changed files with 5 additions and 0 deletions

View File

@ -5741,6 +5741,11 @@ def cli(_cluster, _debug, _quiet, _unsafe, _colour):
global config global config
store_data = get_store(store_path) store_data = get_store(store_path)
config = get_config(store_data, _cluster) config = get_config(store_data, _cluster)
# There is only one cluster and no local cluster, so even if nothing was passed, use it
if len(store_data) == 1 and _cluster is None and config.get("badcfg", None):
config = get_config(store_data, list(store_data.keys())[0])
if not config.get("badcfg", None): if not config.get("badcfg", None):
config["debug"] = _debug config["debug"] = _debug
config["unsafe"] = _unsafe config["unsafe"] = _unsafe