[feature] check-chart-diff-before-upgrade (#43)

* if no diff we dont upgrade
This commit is contained in:
Alexis Rivera DeLa Torre 2017-04-14 12:18:57 -05:00 committed by Alan Meadows
parent ef46d4bfe1
commit 8cfbc69d3d
3 changed files with 21 additions and 18 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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)