Skip to content

Commit

Permalink
Fixed update yaml bug with revision suffix (Azure#136)
Browse files Browse the repository at this point in the history
* Fixed yaml breaking change and bug where revision suffix would return invalid if user is adding a container and the previous revision has a revision suffix.

* Fixed revision suffix yaml bug.

Co-authored-by: Haroon Feisal <haroonfeisal@microsoft.com>
  • Loading branch information
runefa and Haroon Feisal authored Jul 18, 2022
1 parent 35fddc1 commit e55116f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@ def update_containerapp_yaml(cmd, name, resource_group_name, file_name, from_rev

containerapp_def = None

# Change which revision we update from
if from_revision:
logger.warning('Flag --from-revision was passed along with --yaml. This flag will be ignored, and the configuration defined in the yaml will be used instead')

# Deserialize the yaml into a ContainerApp object. Need this since we're not using SDK
try:
deserializer = create_deserializer()
Expand All @@ -174,6 +170,12 @@ def update_containerapp_yaml(cmd, name, resource_group_name, file_name, from_rev
# After deserializing, some properties may need to be moved under the "properties" attribute. Need this since we're not using SDK
containerapp_def = process_loaded_yaml(containerapp_def)

# Change which revision we update from
if from_revision:
r = ContainerAppClient.show_revision(cmd=cmd, resource_group_name=resource_group_name, container_app_name=name, name=from_revision)
_update_revision_env_secretrefs(r["properties"]["template"]["containers"], name)
containerapp_def["properties"]["template"] = r["properties"]["template"]

# Remove "additionalProperties" and read-only attributes that are introduced in the deserialization. Need this since we're not using SDK
_remove_additional_attributes(containerapp_def)
_remove_readonly_attributes(containerapp_def)
Expand All @@ -184,6 +186,14 @@ def update_containerapp_yaml(cmd, name, resource_group_name, file_name, from_rev
# Clean null values since this is an update
containerapp_def = clean_null_values(containerapp_def)

# Fix bug with revisionSuffix when containers are added
if not safe_get(containerapp_def, "properties", "template", "revisionSuffix"):
if "properties" not in containerapp_def:
containerapp_def["properties"] = {}
if "template" not in containerapp_def["properties"]:
containerapp_def["properties"]["template"] = {}
containerapp_def["properties"]["template"]["revisionSuffix"] = None

try:
r = ContainerAppClient.update(
cmd=cmd, resource_group_name=resource_group_name, name=name, container_app_envelope=containerapp_def, no_wait=no_wait)
Expand Down

0 comments on commit e55116f

Please sign in to comment.