Enhance helm override generator to support Armada
The "sysinv-helm create-app-overrides" command normally emits helm-formatted overrides files. In order to use the overrides with Armada we introduce a new "sysinv-helm create-armada-app-overrides" command to emit the overrides in armada format. In addition, we fix up a code comment to make it more accurate. Change-Id: I8c5175518afa3a77c6eb528924cb7d8bc2bae9c8 Story: 2003908 Task: 26791 Depends-On: Ifb905ed16eefc9162db5b5fdfc92712cc8bc0622 Signed-off-by: Robert Church <robert.church@windriver.com>
This commit is contained in:
parent
59e7630067
commit
8cea1aef3d
|
@ -104,7 +104,7 @@ class HelmChartsController(rest.RestController):
|
|||
|
||||
@wsme_pecan.wsexpose(wtypes.text, wtypes.text, wtypes.text)
|
||||
def get_one(self, name, namespace):
|
||||
"""Retrieve information about the given event_log.
|
||||
"""Retrieve information about the given chart.
|
||||
|
||||
:param name: name of helm chart
|
||||
:param namespace: namespace of chart overrides
|
||||
|
|
|
@ -26,6 +26,13 @@ def create_app_overrides_action(path, app_name=None, repository=None, namespace=
|
|||
operator.generate_helm_application_overrides(app_name, namespace)
|
||||
|
||||
|
||||
def create_armada_app_overrides_action(path, app_name=None, repository=None, namespace=None):
|
||||
dbapi = api.get_instance()
|
||||
operator = helm.HelmOperator(dbapi=dbapi, path=path, docker_repository=repository)
|
||||
operator.generate_helm_application_overrides(app_name, namespace,
|
||||
armada_format=True)
|
||||
|
||||
|
||||
def create_chart_override_action(path, chart_name=None, repository=None, namespace=None):
|
||||
dbapi = api.get_instance()
|
||||
operator = helm.HelmOperator(dbapi=dbapi, path=path, docker_repository=repository)
|
||||
|
@ -40,6 +47,13 @@ def add_action_parsers(subparsers):
|
|||
parser.add_argument('repository', nargs='?')
|
||||
parser.add_argument('namespace', nargs='?')
|
||||
|
||||
parser = subparsers.add_parser('create-armada-app-overrides')
|
||||
parser.set_defaults(func=create_armada_app_overrides_action)
|
||||
parser.add_argument('path', nargs='?')
|
||||
parser.add_argument('app_name', nargs='?')
|
||||
parser.add_argument('repository', nargs='?')
|
||||
parser.add_argument('namespace', nargs='?')
|
||||
|
||||
parser = subparsers.add_parser('create-chart-overrides')
|
||||
parser.set_defaults(func=create_chart_override_action)
|
||||
parser.add_argument('path', nargs='?')
|
||||
|
@ -59,6 +73,11 @@ def main():
|
|||
service.prepare_service(sys.argv)
|
||||
if CONF.action.name == 'create-app-overrides':
|
||||
|
||||
CONF.action.func(CONF.action.path,
|
||||
CONF.action.app_name,
|
||||
CONF.action.repository,
|
||||
CONF.action.namespace)
|
||||
elif CONF.action.name == 'create-armada-app-overrides':
|
||||
CONF.action.func(CONF.action.path,
|
||||
CONF.action.app_name,
|
||||
CONF.action.repository,
|
||||
|
|
|
@ -255,6 +255,20 @@ class HelmOperator(object):
|
|||
LOG.info(e)
|
||||
return overrides
|
||||
|
||||
@staticmethod
|
||||
def _add_armada_override_header(chart_name, namespace, overrides):
|
||||
new_overrides = {
|
||||
'schema': 'armada/Chart/v1',
|
||||
'metadata': {
|
||||
'schema': 'metadata/Document/v1',
|
||||
'name': namespace + '-' + chart_name
|
||||
},
|
||||
'data': {
|
||||
'values': overrides
|
||||
}
|
||||
}
|
||||
return new_overrides
|
||||
|
||||
@helm_context
|
||||
def generate_helm_chart_overrides(self, chart_name, cnamespace=None):
|
||||
"""Generate system helm chart overrides
|
||||
|
@ -290,7 +304,8 @@ class HelmOperator(object):
|
|||
LOG.exception("chart name is required")
|
||||
|
||||
@helm_context
|
||||
def generate_helm_application_overrides(self, app_name, cnamespace=None):
|
||||
def generate_helm_application_overrides(self, app_name, cnamespace=None,
|
||||
armada_format=False):
|
||||
"""Create the system overrides files for a supported application
|
||||
|
||||
This method will generate system helm chart overrides yaml files for a
|
||||
|
@ -301,13 +316,22 @@ class HelmOperator(object):
|
|||
:param app_name: name of the bundle of charts required to support an
|
||||
application
|
||||
:param cnamespace: (optional) namespace
|
||||
:param armada_format: (optional) whether to emit in armada format
|
||||
instead of helm format (with extra header)
|
||||
"""
|
||||
|
||||
if app_name in constants.SUPPORTED_HELM_APP_NAMES:
|
||||
app_overrides = self.get_helm_application_overrides(app_name,
|
||||
app_overrides = self._get_helm_application_overrides(app_name,
|
||||
cnamespace)
|
||||
|
||||
for (chart_name, overrides) in iteritems(app_overrides):
|
||||
# If armada formatting is wanted, we need to change the
|
||||
# structure of the yaml file somewhat
|
||||
if armada_format:
|
||||
for key in overrides:
|
||||
new_overrides = self._add_armada_override_header(
|
||||
chart_name, key, overrides[key])
|
||||
overrides[key] = new_overrides
|
||||
|
||||
self._write_chart_overrides(chart_name, cnamespace, overrides)
|
||||
elif app_name:
|
||||
LOG.exception("%s application is not supported" % app_name)
|
||||
|
|
Loading…
Reference in New Issue