feat: implement profile activation and runtime identity clarity (#131)
This commit is contained in:
@@ -192,11 +192,32 @@ def config_path():
|
||||
return (os.environ.get(ENV_CONFIG_PATH) or "").strip() or None
|
||||
|
||||
|
||||
_active_profile_override = None
|
||||
|
||||
|
||||
def selected_profile_name():
|
||||
"""Return the selected profile name from the environment, or None."""
|
||||
if _active_profile_override is not None:
|
||||
return _active_profile_override
|
||||
return (os.environ.get(ENV_PROFILE) or "").strip() or None
|
||||
|
||||
|
||||
def is_runtime_switching_enabled(path=None):
|
||||
"""Check if runtime profile switching is explicitly enabled in config."""
|
||||
try:
|
||||
config = load_config(path)
|
||||
except Exception:
|
||||
return False
|
||||
if not config:
|
||||
return False
|
||||
rules = config.get("rules") or {}
|
||||
if rules.get("allow_runtime_switching") is True:
|
||||
return True
|
||||
if config.get("allow_runtime_switching") is True:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def load_config(path=None):
|
||||
"""Load and minimally validate the canonical JSON config.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user