From 2c5ce282d50ad9f6f09cc7421da11d4b279e07d0 Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Tue, 22 Oct 2024 18:10:11 +0200 Subject: [PATCH] Add test config grammar for per app overlay ppa. In some circumstances we want to install packages from overlay PPA on specific applications and not across the whole model. Add configuration grammar, actual implementation of generic setup step will follow in subsequent patch. Signed-off-by: Frode Nordahl --- zaza/utilities/deployment_env.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/zaza/utilities/deployment_env.py b/zaza/utilities/deployment_env.py index d8b5234d..3450e952 100644 --- a/zaza/utilities/deployment_env.py +++ b/zaza/utilities/deployment_env.py @@ -85,7 +85,7 @@ def parse_option_list_string(option_list, delimiter=None): return settings -def get_overlay_ppas(model_alias='default_alias'): +def get_overlay_ppas(model_alias='default_alias', application=None): """Get overlay_ppas from global_config. In the config file for the tests, the tests_options.overlay_ppa option @@ -95,20 +95,38 @@ def get_overlay_ppas(model_alias='default_alias'): Please refer to docstring of parse_overlay_ppa function for more information. + When application is provided, additional grammar to constrain the + overlay PPA to specific applications is supported, for example: + + overlay_ppas: + myapp: + - ppa:mylpuser/myppa + myotherapp: + - source: fakesource + key: fakekey + :param model_alias: Name of model alias, defaults to 'default_alias'. :type model_alias: Option[str] + :param application: Name of application to retrieve config for. + :type application: Option[str] :returns: List of overlay PPAs. :rtype: Option[List[Any]] """ config = zaza.global_options.get_options() + config_overlay_ppas = None try: - return config[model_alias].overlay_ppas + config_overlay_ppas = config[model_alias].overlay_ppas except KeyError: try: - return config.overlay_ppas + config_overlay_ppas = config.overlay_ppas except KeyError: pass - return None + if config_overlay_ppas and application: + return [overlay_ppa + for overlay_ppa in config_overlay_ppas + if (isinstance(overlay_ppa, dict) and + application in overlay_ppa)] or None + return config_overlay_ppas def _parse_overlay_ppa_v1(overlay_ppa):