Skip to content

Commit 8006786

Browse files
committed
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 <fnordahl@ubuntu.com>
1 parent ae5e9f7 commit 8006786

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

zaza/utilities/deployment_env.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def parse_option_list_string(option_list, delimiter=None):
8585
return settings
8686

8787

88-
def get_overlay_ppas(model_alias='default_alias'):
88+
def get_overlay_ppas(model_alias='default_alias', application=None):
8989
"""Get overlay_ppas from global_config.
9090
9191
In the config file for the tests, the tests_options.overlay_ppa option
@@ -97,17 +97,25 @@ def get_overlay_ppas(model_alias='default_alias'):
9797
9898
:param model_alias: Name of model alias, defaults to 'default_alias'.
9999
:type model_alias: Option[str]
100+
:param application: Name of application to retrieve config for.
101+
:type application: Option[str]
100102
:returns: List of overlay PPAs.
101103
:rtype: Option[List[Any]]
102104
"""
103105
config = zaza.global_options.get_options()
106+
config_overlay_ppas = None
104107
try:
105-
return config[model_alias].overlay_ppas
108+
config_overlay_ppas = config[model_alias].overlay_ppas
106109
except KeyError:
107110
try:
108-
return config.overlay_ppas
111+
config_overlay_ppas = config.overlay_ppas
109112
except KeyError:
110113
pass
114+
if config_overlay_ppas and application:
115+
return [overlay_ppa
116+
for overlay_ppa in config_overlay_ppas
117+
if (isinstance(overlay_ppa, dict) and
118+
application in overlay_ppa)] or None
111119
return None
112120

113121

@@ -144,6 +152,26 @@ def _parse_overlay_ppa_v2(overlay_ppa):
144152
'key': overlay_ppa['key']}
145153

146154

155+
def _parse_overlay_ppa_v3(overlay_ppa):
156+
"""Parse per application overlay_ppa config.
157+
158+
Example YAML excerpt:
159+
overlay_ppas:
160+
application_name:
161+
- ppa:ubuntu-security-proposed/ppa
162+
other_application_name:
163+
- source: "deb https://user:pass@private-ppa.launchpad"
164+
key: |
165+
-----BEGIN PGP PUBLIC KEY BLOCK-----
166+
....
167+
-----END PGP PUBLIC KEY BLOCK-----
168+
:param overlay_ppa: Element of overlay_ppas configuration.
169+
:type overlay_ppa: Dict[str,List[Any]]
170+
:returns
171+
"""
172+
# {'application': ['plain', {'source': 'fakesource', 'key': 'fakekey'}]}
173+
174+
147175
def parse_overlay_ppa(overlay_ppa):
148176
"""Parse multiple versions of overlay_ppas elements.
149177

0 commit comments

Comments
 (0)