Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{containerapp} az containerapp update fix list secret value for populate #6720

Merged
merged 4 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

Release History
===============
upcoming
0.3.39
++++++
* 'az containerapp update': fix bug for populating secret value with --yaml

0.3.38
++++++
Expand Down
6 changes: 3 additions & 3 deletions src/containerapp/azext_containerapp/containerapp_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def show(self):
except CLIError as e:
handle_raw_exception(e)

def list_secrets(self):
def list_secrets(self, show_values=False):
containerapp_def = None
try:
containerapp_def = self.client.show(cmd=self.cmd, resource_group_name=self.get_argument_resource_group_name(), name=self.get_argument_name())
Expand All @@ -113,7 +113,7 @@ def list_secrets(self):
if not containerapp_def:
raise ResourceNotFoundError("The containerapp '{}' does not exist".format(self.get_argument_name()))

if not self.get_argument_show_values():
if not show_values:
return safe_get(containerapp_def, "properties", "configuration", "secrets", default=[])

try:
Expand Down Expand Up @@ -1165,7 +1165,7 @@ def set_up_update_containerapp_yaml(self, name, file_name):
_remove_additional_attributes(self.new_containerapp)
_remove_readonly_attributes(self.new_containerapp)

secret_values = self.list_secrets()
secret_values = self.list_secrets(show_values=True)
_populate_secret_values(self.new_containerapp, secret_values)

# Clean null values since this is an update
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,9 @@ def test_containerapp_create_with_yaml(self, resource_group):
properties:
managedEnvironmentId: {containerapp_env["id"]}
configuration:
secrets:
- name: secret1
value: 1
activeRevisionsMode: Multiple
ingress:
external: true
Expand Down Expand Up @@ -1396,6 +1399,7 @@ def test_containerapp_create_with_yaml(self, resource_group):
JMESPathCheck("properties.configuration.ingress.ipSecurityRestrictions[0].name", "name"),
JMESPathCheck("properties.configuration.ingress.ipSecurityRestrictions[0].ipAddressRange", "1.1.1.1/10"),
JMESPathCheck("properties.configuration.ingress.ipSecurityRestrictions[0].action", "Allow"),
JMESPathCheck("length(properties.configuration.secrets)", 1),
JMESPathCheck("properties.environmentId", containerapp_env["id"]),
JMESPathCheck("properties.template.revisionSuffix", "myrevision"),
JMESPathCheck("properties.template.terminationGracePeriodSeconds", 90),
Expand All @@ -1418,6 +1422,10 @@ def test_containerapp_create_with_yaml(self, resource_group):
properties:
environmentId: {containerapp_env["id"]}
configuration:
secrets:
- name: secret1
- name: secret2
value: 123
activeRevisionsMode: Multiple
ingress:
external: true
Expand Down Expand Up @@ -1456,6 +1464,7 @@ def test_containerapp_create_with_yaml(self, resource_group):
JMESPathCheck("properties.configuration.ingress.ipSecurityRestrictions[0].name", "name"),
JMESPathCheck("properties.configuration.ingress.ipSecurityRestrictions[0].ipAddressRange", "1.1.1.1/10"),
JMESPathCheck("properties.configuration.ingress.ipSecurityRestrictions[0].action", "Allow"),
JMESPathCheck("length(properties.configuration.secrets)", 2),
JMESPathCheck("properties.environmentId", containerapp_env["id"]),
JMESPathCheck("properties.template.revisionSuffix", "myrevision2"),
JMESPathCheck("properties.template.containers[0].name", "nginx"),
Expand All @@ -1464,6 +1473,16 @@ def test_containerapp_create_with_yaml(self, resource_group):
JMESPathCheck("properties.template.scale.rules", None)
])

self.cmd(f'containerapp secret show -g {resource_group} -n {app} --secret-name secret1', checks=[
JMESPathCheck("name", 'secret1'),
JMESPathCheck("value", '1'),
])

self.cmd(f'containerapp secret show -g {resource_group} -n {app} --secret-name secret2', checks=[
JMESPathCheck("name", 'secret2'),
JMESPathCheck("value", '123'),
])

# test update without environmentId
containerapp_yaml_text = f"""
properties:
Expand Down
2 changes: 1 addition & 1 deletion src/containerapp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.

VERSION = '0.3.38'
VERSION = '0.3.39'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down