Skip to content

Commit ab38fac

Browse files
committed
Allow aliases for autoVars/noris
Signed-off-by: Matthias Büchse <matthias.buechse@alasca.cloud>
1 parent 6225c97 commit ab38fac

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

Tests/kaas/plugin/plugin_gardener.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,10 @@ def __init__(self, plugin_config, basepath='.', cwd='.', name=None):
164164
def _render_template(self, key):
165165
return self.template_map[key].render(**self.vars, **self.secrets)
166166

167-
def _auto_vars_noris(self, api_instance: _gh.CustomObjectsApi):
168-
logging.debug('using autoVars/noris')
167+
def _auto_vars_noris(self, api_instance: _gh.CustomObjectsApi, alias: str):
168+
# this was introduced for use with noris Sovereign Cloud, but it works for others as well,
169+
# and to reduce potential for confusion, allow aliases (such as autoVars/scaleup)
170+
logging.debug(f'using autoVars/{alias}')
169171
cloud_profile = _gh.get_cloudprofile(api_instance, self.namespace, self.vars['cloud_profile_name'])
170172
version_items = cloud_profile['spec']['kubernetes']['versions']
171173
# filter by kubernetesVersion and classification==supported
@@ -178,7 +180,7 @@ def _auto_vars_noris(self, api_instance: _gh.CustomObjectsApi):
178180
]
179181
logging.debug(f'matching k8s versions: {versions}')
180182
if not versions:
181-
raise RuntimeError(f'autoVars/noris failed: no versions found for v{version_prefix}x')
183+
raise RuntimeError(f'autoVars/{alias} failed: no versions found for v{version_prefix}x')
182184
# select latest patch version (assume patch part is numeric)
183185
selected_version = max(versions, key=lambda ver: int(ver.rsplit('.', 1)[-1]))
184186
return {'kubernetes_version': selected_version}
@@ -189,8 +191,8 @@ def _auto_vars(self, auto_vars_kind, co_api: _gh.CustomObjectsApi):
189191
# now on to specifics
190192
if not auto_vars_kind:
191193
return
192-
if auto_vars_kind == 'noris':
193-
auto_vars = self._auto_vars_noris(co_api)
194+
if auto_vars_kind in ('noris', 'scaleup'):
195+
auto_vars = self._auto_vars_noris(co_api, alias=auto_vars_kind)
194196
else:
195197
raise RuntimeError(f'unknown kind of autoVars: {auto_vars_kind}')
196198
logger.debug(f'applying autoVars/{auto_vars_kind}: {auto_vars}')

0 commit comments

Comments
 (0)