Fix various issues with helm-override-show
This commit addresses the following issues with helm-override-show command: - incorrect response if user overrides is not available, system overrides should be displayed as opposed to exception. - incorrect response for invalid/unsupported chart name and/or namespace. Tests conducted: The following commands were used to verify the changes: - system helm-override-show ingress abc - system helm-override-show abc ingress - system helm-override-show abc def - system helm-override-show ingress openstack - system helm-override-update ingress openstack \ --set pod.replicas.ingress=2 - system helm-override-show ingress openstack Story: 2003909 Task: 28180 Task: 28265 Change-Id: I96e4c682c13b129a04e8827a00c63e39882c133a Signed-off-by: Tee Ngo <Tee.Ngo@windriver.com>
This commit is contained in:
parent
30b5b97208
commit
5eb4e206c0
|
@ -42,6 +42,7 @@ class HelmChartsController(rest.RestController):
|
||||||
:param name: name of helm chart
|
:param name: name of helm chart
|
||||||
:param namespace: namespace of chart overrides
|
:param namespace: namespace of chart overrides
|
||||||
"""
|
"""
|
||||||
|
self.validate_name_and_namespace(name, namespace)
|
||||||
|
|
||||||
# Get any user-specified overrides.
|
# Get any user-specified overrides.
|
||||||
try:
|
try:
|
||||||
|
@ -52,20 +53,24 @@ class HelmChartsController(rest.RestController):
|
||||||
if name in constants.SUPPORTED_HELM_CHARTS:
|
if name in constants.SUPPORTED_HELM_CHARTS:
|
||||||
user_overrides = ''
|
user_overrides = ''
|
||||||
else:
|
else:
|
||||||
raise
|
# Unsupported/invalid chart name (and namespace)
|
||||||
|
raise wsme.exc.ClientSideError(_("Override not found."))
|
||||||
|
|
||||||
# Get any system overrides.
|
# Get any system overrides.
|
||||||
try:
|
try:
|
||||||
system_overrides = pecan.request.rpcapi.get_helm_chart_overrides(
|
system_overrides = pecan.request.rpcapi.get_helm_chart_overrides(
|
||||||
pecan.request.context, name, namespace)
|
pecan.request.context, name, namespace)
|
||||||
system_overrides = yaml.safe_dump(system_overrides)
|
system_overrides = yaml.safe_dump(system_overrides)
|
||||||
except (exception.InvalidHelmChart, exception.InvalidHelmNamespace):
|
except Exception:
|
||||||
raise
|
# Unsupported/invalid namespace
|
||||||
|
raise wsme.exc.ClientSideError(_("Override not found."))
|
||||||
|
|
||||||
# Merge the system overrides with the saved user-specified overrides,
|
# Merge the system overrides with the saved user-specified overrides,
|
||||||
# with user-specified overrides taking priority over the system
|
# with user-specified overrides taking priority over the system
|
||||||
# overrides.
|
# overrides.
|
||||||
file_overrides = [system_overrides, user_overrides]
|
file_overrides = [system_overrides, user_overrides] \
|
||||||
|
if user_overrides else [system_overrides]
|
||||||
|
|
||||||
combined_overrides = pecan.request.rpcapi.merge_overrides(
|
combined_overrides = pecan.request.rpcapi.merge_overrides(
|
||||||
pecan.request.context, file_overrides=file_overrides)
|
pecan.request.context, file_overrides=file_overrides)
|
||||||
|
|
||||||
|
@ -79,11 +84,9 @@ class HelmChartsController(rest.RestController):
|
||||||
|
|
||||||
def validate_name_and_namespace(self, name, namespace):
|
def validate_name_and_namespace(self, name, namespace):
|
||||||
if not name:
|
if not name:
|
||||||
raise wsme.exc.ClientSideError(_(
|
raise wsme.exc.ClientSideError(_("Name must be specified."))
|
||||||
"Helm-override-update rejected: name must be specified"))
|
|
||||||
if not namespace:
|
if not namespace:
|
||||||
raise wsme.exc.ClientSideError(_(
|
raise wsme.exc.ClientSideError(_("Namespace must be specified."))
|
||||||
"Helm-override-update rejected: namespace must be specified"))
|
|
||||||
|
|
||||||
@wsme_pecan.wsexpose(wtypes.text, wtypes.text, wtypes.text, wtypes.text, wtypes.text)
|
@wsme_pecan.wsexpose(wtypes.text, wtypes.text, wtypes.text, wtypes.text, wtypes.text)
|
||||||
def patch(self, name, namespace, flag, values):
|
def patch(self, name, namespace, flag, values):
|
||||||
|
|
Loading…
Reference in New Issue