diff --git a/sat/plugins/plugin_misc_app_manager.py b/sat/plugins/plugin_misc_app_manager.py index 009e746e..7015c1a7 100644 --- a/sat/plugins/plugin_misc_app_manager.py +++ b/sat/plugins/plugin_misc_app_manager.py @@ -548,6 +548,24 @@ class AppManager: if prepare: raise exceptions.InternalError('"prepare" should be empty') + async def _doCreateFiles( + self, + app_data: dict, + ) -> None: + dest_path = app_data['_instance_dir_path'] + files = app_data.get('files') + if not files: + return + if not isinstance(files, dict): + raise ValueError('"files" must be a dictionary') + for filename, data in files.items(): + path = dest_path / filename + if path.is_file(): + log.info(f"{path} already exists, skipping") + with path.open("w") as f: + f.write(data.get("content", "")) + log.debug(f"{path} created") + async def startCommon(self, app_data: dict) -> None: """Method running common action when starting a manager @@ -555,3 +573,4 @@ class AppManager: """ log.info(f"starting {app_data['name']!r}") await self._doPrepare(app_data) + await self._doCreateFiles(app_data)