From 8cfbc69d3d4141c0ea621dcb3e5343d2372c9b19 Mon Sep 17 00:00:00 2001 From: Alexis Rivera DeLa Torre Date: Fri, 14 Apr 2017 12:18:57 -0500 Subject: [PATCH] [feature] check-chart-diff-before-upgrade (#43) * if no diff we dont upgrade --- README.md | 2 +- armada/armada.py | 16 ++++++++++++---- scripts/armada | 21 ++++++++------------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index de87ccc1..1a305943 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Before using armada we need to check a few things: To run armada, simply supply it with your YAML based intention for any number of charts: ``` -aramda -c examples/armada.yaml +armada -c examples/armada.yaml ``` Your output will look something like this: diff --git a/armada/armada.py b/armada/armada.py index b8f116c4..6861e9e1 100644 --- a/armada/armada.py +++ b/armada/armada.py @@ -72,8 +72,14 @@ class Armada(object): # show delta for both the chart templates and the chart values # TODO(alanmeadows) account for .files differences # once we support those - self.show_diff(chart, installed_chart, - installed_values, chartbuilder.dump(), values) + + upgrade_diff = self.show_diff(chart, installed_chart, + installed_values, + chartbuilder.dump(), values) + + if not upgrade_diff: + LOG.info("There are no updates found in this chart") + continue # do actual update self.tiller.update_release(protoc_chart, self.args.dry_run, @@ -111,7 +117,7 @@ class Armada(object): if len(chart_diff) > 0: LOG.info("Chart Unified Diff (%s)", chart.release_name) for line in chart_diff: - print line + LOG.debug(line) values_diff = list(difflib.unified_diff(installed_values.split('\n'), yaml .safe_dump(target_values) @@ -119,4 +125,6 @@ class Armada(object): if len(values_diff) > 0: LOG.info("Values Unified Diff (%s)", chart.release_name) for line in values_diff: - print line + LOG.debug(line) + + return (len(chart_diff) > 0) or (len(chart_diff) > 0) diff --git a/scripts/armada b/scripts/armada index 2298b1fe..2ae50a7c 100755 --- a/scripts/armada +++ b/scripts/armada @@ -1,25 +1,22 @@ #!/usr/bin/env python -import yaml -import tempfile import sys -import os import argparse -from supermutes.dot import dotify from armada.armada import Armada -from armada.logutil import * +from armada.logutil import LOG, setup_logging DESCRIPTION = "Armada" def parse_args(): ap = argparse.ArgumentParser(description=DESCRIPTION) - ap.add_argument('--debug', action='store', - default=False, required=False, help='Enable debug logging') - ap.add_argument('-c', '--config', action='store', - required=True, help='Path to YAML File or Directory') - ap.add_argument('-d', '--dry-run', action='store', - default=False, required=False, help='Enable dry-run flag on all Tiller Calls') + ap.add_argument('-c', '--config', action='store', required=True, + help='Path to YAML File or Directory') + ap.add_argument('--debug', action='store_true', default=False, + required=False, help='Enable debug logging') + ap.add_argument('-d', '--dry-run', action='store_true', default=False, + required=False, help='Enable dry-run flag on all Tiller' + 'Calls') return ap.parse_args() @@ -41,5 +38,3 @@ if __name__ == '__main__': except Exception as err: LOG.exception(err) sys.exit(1) - -