Auto-update: Thu Aug 8 18:04:17 PDT 2024
This commit is contained in:
parent
750d8f853e
commit
eb9abb1060
1 changed files with 19 additions and 13 deletions
|
@ -99,31 +99,37 @@ class Configuration(BaseModel):
|
||||||
config_data = yaml.safe_load(file)
|
config_data = yaml.safe_load(file)
|
||||||
|
|
||||||
debug(f"Loaded configuration data from {yaml_path}")
|
debug(f"Loaded configuration data from {yaml_path}")
|
||||||
secrets_data = {}
|
|
||||||
if secrets_path:
|
if secrets_path:
|
||||||
with secrets_path.open('r') as file:
|
with secrets_path.open('r') as file:
|
||||||
secrets_data = yaml.safe_load(file)
|
secrets_data = yaml.safe_load(file)
|
||||||
debug(f"Loaded secrets data from {secrets_path}")
|
debug(f"Loaded secrets data from {secrets_path}")
|
||||||
|
if isinstance(config_data, list):
|
||||||
# Set default HOME if not present
|
for item in config_data:
|
||||||
if 'HOME' not in config_data:
|
if isinstance(item, dict):
|
||||||
config_data['HOME'] = str(Path.home())
|
item.update(secrets_data)
|
||||||
debug(f"HOME was not in config, set to default: {config_data['HOME']}")
|
else:
|
||||||
|
config_data.update(secrets_data)
|
||||||
# Resolve placeholders using secrets
|
|
||||||
config_data = cls.resolve_placeholders(config_data, secrets_data, Path(config_data['HOME']))
|
|
||||||
|
|
||||||
if isinstance(config_data, list):
|
if isinstance(config_data, list):
|
||||||
config_data = {"configurations": config_data}
|
config_data = {"configurations": config_data}
|
||||||
|
|
||||||
|
if 'HOME' not in config_data:
|
||||||
|
config_data['HOME'] = str(Path.home())
|
||||||
|
debug(f"HOME was not in config, set to default: {config_data['HOME']}")
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
instance = cls.create_dynamic_model(**config_data)
|
instance = cls.create_dynamic_model(**config_data)
|
||||||
instance._dir_config = dir_config or instance
|
instance._dir_config = dir_config or instance
|
||||||
|
resolved_data = instance.resolve_placeholders(config_data)
|
||||||
|
instance = cls.create_dynamic_model(**resolved_data)
|
||||||
|
instance._dir_config = dir_config or instance
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
err(f"Error loading configuration: {str(e)}")
|
err(f"Error loading configuration: {str(e)}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _resolve_path(cls, path: Union[str, Path], default_dir: str) -> Path:
|
def _resolve_path(cls, path: Union[str, Path], default_dir: str) -> Path:
|
||||||
base_path = Path(__file__).parent.parent
|
base_path = Path(__file__).parent.parent
|
||||||
|
|
Loading…
Reference in a new issue