From aaf9bd4033bce7d5fa758592fc2ba48ad09b659b Mon Sep 17 00:00:00 2001 From: Tim Heyer Date: Thu, 10 Aug 2017 15:05:57 +0000 Subject: [PATCH] Fix cloning only single repo branch bug Fixes a bug where armada is only able to clone one branch of a particular repo and all other are ignored (GitHub issue #153). Additionally, removes 'reference' and 'subpath' keywords as a requirement in the manifest for non-git sources (GitHub issue #154). Change-Id: I9762404e80283216bea87e218500299606a1d0e8 --- armada/handlers/armada.py | 21 ++-- .../operations/guide-build-armada-yaml.rst | 96 +++++++++++-------- 2 files changed, 68 insertions(+), 49 deletions(-) diff --git a/armada/handlers/armada.py b/armada/handlers/armada.py index 8c4ae9e3..e00d3b28 100644 --- a/armada/handlers/armada.py +++ b/armada/handlers/armada.py @@ -135,8 +135,7 @@ class Armada(object): def tag_cloned_repo(self, ch, repos): location = ch.get('chart').get('source').get('location') ct_type = ch.get('chart').get('source').get('type') - reference = ch.get('chart').get('source').get('reference') - subpath = ch.get('chart').get('source').get('subpath') + subpath = ch.get('chart').get('source').get('subpath', '.') if ct_type == 'local': ch.get('chart')['source_dir'] = (location, subpath) @@ -145,16 +144,22 @@ class Armada(object): tarball_dir = source.get_tarball(location) ch.get('chart')['source_dir'] = (tarball_dir, subpath) elif ct_type == 'git': - if location not in repos.keys(): + reference = ch.get('chart').get('source').get('reference', + 'master') + repo_branch = (location, reference) + + if repo_branch not in repos.keys(): try: - LOG.info('Cloning repo: %s', location) - repo_dir = source.git_clone(location, reference) + LOG.info('Cloning repo: %s branch: %s', *repo_branch) + repo_dir = source.git_clone(*repo_branch) except Exception: - raise source_exceptions.GitLocationException(location) - repos[location] = repo_dir + raise source_exceptions.GitLocationException( + '{} branch: {}'.format(*repo_branch)) + repos[repo_branch] = repo_dir ch.get('chart')['source_dir'] = (repo_dir, subpath) else: - ch.get('chart')['source_dir'] = (repos.get(location), subpath) + ch.get('chart')['source_dir'] = (repos.get(repo_branch), + subpath) else: chart_name = ch.get('chart').get('chart_name') raise source_exceptions.ChartSourceException(ct_type, chart_name) diff --git a/docs/source/operations/guide-build-armada-yaml.rst b/docs/source/operations/guide-build-armada-yaml.rst index ede90f3f..9c1ecbdb 100644 --- a/docs/source/operations/guide-build-armada-yaml.rst +++ b/docs/source/operations/guide-build-armada-yaml.rst @@ -76,27 +76,27 @@ armada/Chart/v1 Chart ^^^^^ -+-----------------+----------+------------------------------------------------------------------------+ -| keyword | type | action | -+=================+==========+========================================================================+ -| chart\_name | string | name for the chart | -+-----------------+----------+------------------------------------------------------------------------+ -| release\_name | string | name of the release | -+-----------------+----------+------------------------------------------------------------------------+ -| namespace | string | namespace of your chart | -+-----------------+----------+------------------------------------------------------------------------+ -| timeout | int | time (in seconds) allotted for chart to deploy when 'wait' flag is set | -+-----------------+----------+------------------------------------------------------------------------+ -| install | object | install the chart into your Kubernetes cluster | -+-----------------+----------+------------------------------------------------------------------------+ -| update | object | update the chart managed by the armada yaml | -+-----------------+----------+------------------------------------------------------------------------+ -| values | object | override any default values in the charts | -+-----------------+----------+------------------------------------------------------------------------+ -| source | object | provide a path to a ``git repo`` or ``local dir`` deploy chart. | -+-----------------+----------+------------------------------------------------------------------------+ -| dependencies | object | reference any chart dependencies before install | -+-----------------+----------+------------------------------------------------------------------------+ ++-----------------+----------+---------------------------------------------------------------------------+ +| keyword | type | action | ++=================+==========+===========================================================================+ +| chart\_name | string | name for the chart | ++-----------------+----------+---------------------------------------------------------------------------+ +| release\_name | string | name of the release | ++-----------------+----------+---------------------------------------------------------------------------+ +| namespace | string | namespace of your chart | ++-----------------+----------+---------------------------------------------------------------------------+ +| timeout | int | time (in seconds) allotted for chart to deploy when 'wait' flag is set | ++-----------------+----------+---------------------------------------------------------------------------+ +| install | object | install the chart into your Kubernetes cluster | ++-----------------+----------+---------------------------------------------------------------------------+ +| update | object | update the chart managed by the armada yaml | ++-----------------+----------+---------------------------------------------------------------------------+ +| values | object | override any default values in the charts | ++-----------------+----------+---------------------------------------------------------------------------+ +| source | object | provide a path to a ``git repo``, ``local dir``, or ``tarball url`` chart | ++-----------------+----------+---------------------------------------------------------------------------+ +| dependencies | object | reference any chart dependencies before install | ++-----------------+----------+---------------------------------------------------------------------------+ Update - Pre or Post ^^^^^^^^^^^^^^^^^^^^ @@ -148,17 +148,17 @@ Update - Actions - Update/Delete Source ^^^^^^ -+-------------+----------+---------------------------------------------------------------+ -| keyword | type | action | -+=============+==========+===============================================================+ -| type | string | source to build the chart: ``git``, ``local``, or ``tar`` | -+-------------+----------+---------------------------------------------------------------+ -| location | string | ``url`` or ``path`` to the chart's parent directory | -+-------------+----------+---------------------------------------------------------------+ -| subpath | string | relative path to target chart from parent | -+-------------+----------+---------------------------------------------------------------+ -| reference | string | branch of the repo | -+-------------+----------+---------------------------------------------------------------+ ++-------------+----------+-------------------------------------------------------------------------------+ +| keyword | type | action | ++=============+==========+===============================================================================+ +| type | string | source to build the chart: ``git``, ``local``, or ``tar`` | ++-------------+----------+-------------------------------------------------------------------------------+ +| location | string | ``url`` or ``path`` to the chart's parent directory | ++-------------+----------+-------------------------------------------------------------------------------+ +| subpath | string | (optional) relative path to target chart from parent (``.`` if not specified) | ++-------------+----------+-------------------------------------------------------------------------------+ +| reference | string | (optional) branch of the repo (``master`` if not specified) | ++-------------+----------+-------------------------------------------------------------------------------+ Example ~~~~~~~ @@ -247,10 +247,10 @@ Simple Example namespace: default values: {} source: - type: tar - location: http://localhost:8879/namespace/repo - subpath: blog-2 - reference: master + type: git + location: http://github.com/namespace/repo + subpath: blog-1 + reference: new-feat dependencies: [] --- schema: armada/ChartGroup/v1 @@ -290,7 +290,7 @@ Multichart Example source: type: git location: https://github.com/namespace/repo - subpath: . + subpath: blog1 reference: master dependencies: [] --- @@ -304,10 +304,23 @@ Multichart Example namespace: default values: {} source: - type: git - location: https://github.com/namespace/repo - subpath: . - reference: master + type: tar + location: https://github.com/namespace/repo/blog2.tgz + subpath: blog2 + dependencies: [] + --- + schema: armada/Chart/v1 + metadata: + schema: metadata/Document/v1 + name: blog-3 + data: + chart_name: blog-3 + release: blog-3 + namespace: default + values: {} + source: + type: local + location: /home/user/namespace/repo/blog3 dependencies: [] --- schema: armada/ChartGroup/v1 @@ -329,6 +342,7 @@ Multichart Example sequenced: False chart_group: - blog-1 + - blog-3 --- schema: armada/Manifest/v1 metadata: