Skip to content

Commit

Permalink
Use PATCH API for containerapp update. (Azure#129)
Browse files Browse the repository at this point in the history
* init containerapp version 0.3.7

* Use PATCH API for containerapp update.

* Removed double lines.

* fix bug

* Fix microsoft/azure-container-apps#261

* Fixed issue where containerapp up would not honor --registry-server. (Azure#128)

* Fixed issue where containerapp up would not honor --registry-server.

* Updated history.

Co-authored-by: Haroon Feisal <haroonfeisal@microsoft.com>

* bug fix

* add tests

* fix credscan suppressions

* Use constant for acr registry prefix.

* Fixed multi-container issue.

* Removed comment.

* Updated update_containerapp_yaml to use patch. Fixed minor style errors.

* Fixed merge conflicts.

* Rerecorded necessary tests.

* Updated history.

* Auto-populate secret values if passed without values.

* Fixed bug where the containerapp had no secrets.

Co-authored-by: Silas Strawn <strawnsc@gmail.com>
Co-authored-by: Haroon Feisal <haroonfeisal@microsoft.com>
  • Loading branch information
3 people authored Jul 15, 2022
1 parent bfaaaf1 commit 4995049
Show file tree
Hide file tree
Showing 4 changed files with 1,300 additions and 667 deletions.
2 changes: 1 addition & 1 deletion src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Release History

0.3.8
++++++
* TODO
* Fixed bug with 'az containerapp update' where --yaml would error out due to secret values

0.3.7
++++++
Expand Down
31 changes: 30 additions & 1 deletion src/containerapp/azext_containerapp/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long, consider-using-f-string, no-else-return, duplicate-string-formatting-argument, expression-not-assigned, too-many-locals, logging-fstring-interpolation
# pylint: disable=line-too-long, consider-using-f-string, no-else-return, duplicate-string-formatting-argument, expression-not-assigned, too-many-locals, logging-fstring-interpolation, broad-except

import time
import json
Expand Down Expand Up @@ -788,6 +788,35 @@ def _remove_readonly_attributes(containerapp_def):
del containerapp_def['properties'][unneeded_property]


def clean_null_values(d):
if isinstance(d, dict):
return {
k: v
for k, v in ((k, clean_null_values(v)) for k, v in d.items())
if v
}
if isinstance(d, list):
return [v for v in map(clean_null_values, d) if v]
return d


def _populate_secret_values(containerapp_def, secret_values):
secrets = safe_get(containerapp_def, "properties", "configuration", "secrets", default=None)
if not secrets:
secrets = []
if not secret_values:
secret_values = []
index = 0
while index < len(secrets):
value = secrets[index]
if "value" not in value or not value["value"]:
try:
value["value"] = next(s["value"] for s in secret_values if s["name"] == value["name"])
except StopIteration:
pass
index += 1


def _remove_dapr_readonly_attributes(daprcomponent_def):
unneeded_properties = [
"id",
Expand Down
Loading

0 comments on commit 4995049

Please sign in to comment.