From 5738a4ced0a57fc446150268dbfef397f9466ef1 Mon Sep 17 00:00:00 2001 From: Sean Eagan Date: Thu, 15 Aug 2019 16:53:43 -0500 Subject: [PATCH] [WIP]: Support reading dependencies from chart Change-Id: Ifc541dc273fa2a5c5b4e43125f468ea3fdb0f379 --- armada/handlers/chartbuilder.py | 20 ++++++++++++++++++- .../operations/documents/migration-v1-v2.rst | 12 ++++++++--- .../documents/v2/document-authoring.rst | 6 ++++-- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/armada/handlers/chartbuilder.py b/armada/handlers/chartbuilder.py index fce581d3..808b08b4 100644 --- a/armada/handlers/chartbuilder.py +++ b/armada/handlers/chartbuilder.py @@ -242,11 +242,29 @@ class ChartBuilder(object): return self._helm_chart dependencies = [] - chart_dependencies = self.chart_data.get('dependencies', []) + chart_dependencies = self.chart_data.get('dependencies') + + # Chart dependencies are not specified, read them out of the chart. + if chart_dependencies is None: + chart_dependencies = [] + charts_dir = os.path.join(self.source_directory, 'charts') + if os.path.isdir(charts_dir): + for item in os.listdir(charts_dir): + dep_chart = { + 'metadata': { + 'name': item + }, + const.KEYWORD_DATA: { + 'source_dir': os.path.join(charts_dir, item) + } + } + chart_dependencies.append(dep_chart) + chart_name = self.chart['metadata']['name'] chart_release = self.chart_data.get('release', None) for dep_chart in chart_dependencies: dep_chart_name = dep_chart['metadata']['name'] + # TODO: chart_release can be None, should log dependency chain instead. LOG.info( "Building dependency chart %s for release %s.", dep_chart_name, chart_release) diff --git a/doc/source/operations/documents/migration-v1-v2.rst b/doc/source/operations/documents/migration-v1-v2.rst index 40ddfa97..6cf0df56 100644 --- a/doc/source/operations/documents/migration-v1-v2.rst +++ b/doc/source/operations/documents/migration-v1-v2.rst @@ -52,9 +52,15 @@ Chart | ``upgrade.options.no_hooks``, | | | and now optional | | +--------------------------------+------------------------------------------------------------+ -| ``dependencies``, | Remove as desired. | -| ``source.subpath`` | | -| now optional | | +| ``dependencies`` now | Remove if you want to use the dependencies already built | +| optional, defaults to using | into the chart. | +| any dependencies built into | | +| `charts` dir of the `source` | | +| helm chart, as Helm CLI does. | | ++--------------------------------+------------------------------------------------------------+ +| ``source.subpath`` | Remove as desired. | +| now optional, deafults to no | | +| subpath. | | +--------------------------------+------------------------------------------------------------+ | ``wait`` improvements | See `Wait Improvements`_. | +--------------------------------+------------------------------------------------------------+ diff --git a/doc/source/operations/documents/v2/document-authoring.rst b/doc/source/operations/documents/v2/document-authoring.rst index a9552350..e40b7987 100644 --- a/doc/source/operations/documents/v2/document-authoring.rst +++ b/doc/source/operations/documents/v2/document-authoring.rst @@ -121,7 +121,9 @@ Chart +-----------------+----------+---------------------------------------------------------------------------------------+ | source | object | provide a path to a ``git repo``, ``local dir``, or ``tarball url`` chart | +-----------------+----------+---------------------------------------------------------------------------------------+ -| dependencies | object | (optional) reference any chart dependencies before install | +| dependencies | object | (optional) reference any chart dependencies before install. | +| | | Defaults to using the dependencies already built into the `charts` dir of the | +| | | `source` chart, as the Helm CLI does. | +-----------------+----------+---------------------------------------------------------------------------------------+ .. _wait_v2: @@ -574,4 +576,4 @@ References ~~~~~~~~~~ For working examples please check the examples in our repo -`here `__. +`here `__