Skip to content

Commit

Permalink
Merge pull request #75 from app-registry/exit_with_helm_errorcode
Browse files Browse the repository at this point in the history
Exit with same errorcode than helm
  • Loading branch information
ant31 authored Sep 2, 2017
2 parents 2c136e0 + 4b826f2 commit f7aeb43
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.7.3 Released on 2017-09-02

- Fix #72: MacOS build
- Fix #73: Exit with the same error-code than Helm

## 0.7.2 Released on 2017-08-13

- Add login/creds per namespaces / repo
Expand Down
7 changes: 6 additions & 1 deletion appr/commands/command_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json
import os
import re

import subprocess
import requests
import yaml

Expand Down Expand Up @@ -143,6 +143,11 @@ def exec_cmd(self, render=True):
payload["response"] = content
self.render_error(payload)
exit(2)
except subprocess.CalledProcessError as exc:
payload = {"message": str(exc.output)}
self.render_error(payload)
exit(exc.returncode)

if render:
self.render()

Expand Down
8 changes: 7 additions & 1 deletion appr/commands/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import argparse
import os
import tempfile
import subprocess
from copy import copy
from appr.commands.command_base import CommandBase
from appr.commands.pull import PullCmd
Expand Down Expand Up @@ -35,7 +36,12 @@ def exec_helm_cmd(self, cmd, options, helm_opts):
pull_cmd = PullCmd(options)
pull_cmd.exec_cmd(render=False)
helm_cli = Helm()
output = helm_cli.action(cmd, pull_cmd.path, helm_opts)
try:
output = helm_cli.action(cmd, pull_cmd.path, helm_opts)
except subprocess.CalledProcessError as exc:
payload = {"message": str(exc.output)}
self.render_error(payload)
exit(exc.returncode)
self.status = {'result': output}
self.render()

Expand Down
5 changes: 1 addition & 4 deletions appr/plugins/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,4 @@ def action(self, cmd, package_path, helm_opts=None):

def _call(self, cmd):
command = ['helm'] + cmd
try:
return subprocess.check_output(command, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as exc:
return exc.output
return subprocess.check_output(command, stderr=subprocess.STDOUT)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

extra_requirements = [
'urllib3[secure]<1.22',
'pyopenssl',
'jinja2>=2.8',
'jsonpatch',
'tabulate',
Expand Down

0 comments on commit f7aeb43

Please sign in to comment.