Skip to content

Commit

Permalink
Merge pull request #141 from galaxyproject/fix_helm_get_values
Browse files Browse the repository at this point in the history
Specify format when using helm get values + tests
  • Loading branch information
nuwang committed Dec 21, 2020
2 parents 32b66d9 + b089cbc commit 720bb74
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 2 additions & 3 deletions cloudman/helmsman/clients/helm_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import contextlib
import shutil

import yaml

from enum import Enum

from clusterman.clients import helpers
Expand Down Expand Up @@ -150,7 +148,8 @@ def get_values(self, namespace, release_name, get_all=True):
get_all=True will also dump chart default values.
get_all=False will only return user overridden values.
"""
cmd = ["helm", "get", "values", "--namespace", namespace, release_name]
cmd = ["helm", "get", "values", "-o", "yaml",
"--namespace", namespace, release_name]
if get_all:
cmd += ["--all"]
return helpers.run_yaml_command(cmd)
Expand Down
10 changes: 9 additions & 1 deletion cloudman/helmsman/tests/mock_helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ def _create_parser(self):
'values', help='download values for a release')
p_get_values.add_argument(
'release', type=str, help='release name')
p_get_values.add_argument(
'-o', '--output', type=str, help='output format',
choices=['table', 'json', 'yaml'], default='table',
const='all', nargs='?')
p_get_values.add_argument(
'--all', action='store_true', help='dump all values')
p_get_values.add_argument(
Expand Down Expand Up @@ -328,7 +332,11 @@ def _helm_get_values(self, args):
return 'Error: release: "%s" not found' % args.release
latest_release = revisions[-1]
with StringIO() as output:
yaml.safe_dump(latest_release.get('VALUES'), output, allow_unicode=True)
if args.output == "yaml":
yaml.safe_dump(latest_release.get('VALUES'), output, allow_unicode=True)
else:
output.write("USER-SUPPLIED VALUES:")
yaml.safe_dump(latest_release.get('VALUES'), output, allow_unicode=True)
return output.getvalue()

def _helm_get_manifest(self, args):
Expand Down

0 comments on commit 720bb74

Please sign in to comment.