-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Containerapp]
az containerapp update
: Fix issue for minReplicas in…
… `--yaml` or `--min-replicas` is not set when the value is 0 (#28163)
- Loading branch information
Showing
13 changed files
with
15,279 additions
and
12,421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,850 changes: 995 additions & 855 deletions
1,850
.../cli/command_modules/containerapp/tests/latest/recordings/test_container_acr_env_var.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
2,038 changes: 933 additions & 1,105 deletions
2,038
...mand_modules/containerapp/tests/latest/recordings/test_containerapp_create_with_yaml.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
953 changes: 664 additions & 289 deletions
953
...containerapp/tests/latest/recordings/test_containerapp_job_custom_executionstest_e2e.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
1,001 changes: 713 additions & 288 deletions
1,001
...odules/containerapp/tests/latest/recordings/test_containerapp_job_executionstest_e2e.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
2,606 changes: 2,606 additions & 0 deletions
2,606
...mand_modules/containerapp/tests/latest/recordings/test_containerapp_replica_commands.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
14,422 changes: 4,884 additions & 9,538 deletions
14,422
...d_modules/containerapp/tests/latest/recordings/test_containerappjob_create_with_yaml.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
4,549 changes: 4,218 additions & 331 deletions
4,549
...inerapp/tests/latest/recordings/test_containerappjob_eventtriggered_create_with_yaml.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
223 changes: 223 additions & 0 deletions
223
...zure/cli/command_modules/containerapp/tests/latest/test_containerapp_clean_null_values.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
import unittest | ||
|
||
from azure.cli.command_modules.containerapp._utils import clean_null_values | ||
|
||
|
||
class UtilsTest(unittest.TestCase): | ||
def test_clean_empty_values(self): | ||
test_dict = { | ||
|
||
} | ||
result = clean_null_values(test_dict) | ||
self.assertEqual({}, result) | ||
|
||
test_dict["properties"] = {} | ||
|
||
result_new = clean_null_values(test_dict) | ||
result_old = old_clean_null_values(test_dict) | ||
|
||
# test remove empty {} | ||
expect_result = {} | ||
self.assertEqual(expect_result, result_new) | ||
self.assertEqual(result_new, result_old) | ||
|
||
test_dict = { | ||
"properties": { | ||
"environmentId": None, | ||
"test": {}, | ||
"configuration": { | ||
"secrets": None, | ||
"activeRevisionsMode": None, | ||
"ingress": { | ||
"fqdn": None, | ||
"external": None, | ||
"targetPort": None, | ||
"exposedPort": None, | ||
"transport": None, | ||
"traffic": [ | ||
{ | ||
"revisionName": None, | ||
"weight": None, | ||
"latestRevision": None, | ||
"label": None | ||
} | ||
], | ||
"customDomains": None, | ||
"allowInsecure": None, | ||
"ipSecurityRestrictions": None, | ||
"stickySessions": None, | ||
"clientCertificateMode": None, | ||
"corsPolicy": None | ||
}, | ||
"registries": None, | ||
"dapr": None, | ||
"maxInactiveRevisions": None | ||
}, | ||
}, | ||
} | ||
|
||
# test remove empty {} | ||
result_new = clean_null_values(test_dict) | ||
result_old = old_clean_null_values(test_dict) | ||
|
||
expect_result = {'properties': {'configuration': {'ingress': {'traffic': []}}}} | ||
self.assertEqual(expect_result, result_new) | ||
self.assertEqual(result_new, result_old) | ||
|
||
test_dict = { | ||
"properties": { | ||
"environmentId": None, | ||
"test": {}, | ||
"configuration": { | ||
"secrets": None, | ||
"activeRevisionsMode": "Single", | ||
"ingress": { | ||
"fqdn": None, | ||
"external": None, | ||
"targetPort": 80, | ||
"exposedPort": None, | ||
"transport": "Auto", | ||
"traffic": [ | ||
{ | ||
"revisionName": None, | ||
"weight": 100, | ||
"latestRevision": None, | ||
"label": None | ||
} | ||
], | ||
"customDomains": None, | ||
"allowInsecure": None, | ||
"ipSecurityRestrictions": None, | ||
"stickySessions": None, | ||
"clientCertificateMode": None, | ||
"corsPolicy": None | ||
}, | ||
"registries": None, | ||
"dapr": None, | ||
"maxInactiveRevisions": None | ||
}, | ||
}, | ||
} | ||
|
||
result_new = clean_null_values(test_dict) | ||
result_old = old_clean_null_values(test_dict) | ||
|
||
expect_result = { | ||
'properties': { | ||
'configuration': { | ||
'activeRevisionsMode': 'Single', | ||
'ingress': { | ||
'targetPort': 80, | ||
'traffic': [ | ||
{ | ||
'weight': 100 | ||
} | ||
], | ||
'transport': 'Auto' | ||
} | ||
} | ||
} | ||
} | ||
self.assertEqual(expect_result, result_new) | ||
self.assertEqual(result_new, result_old) | ||
|
||
test_dict = { | ||
"properties": { | ||
"environmentId": None, | ||
"test": { | ||
"secrets": "secretTest", | ||
}, | ||
"configuration": { | ||
"secrets": None, | ||
"activeRevisionsMode": "Single", | ||
"ingress": { | ||
"fqdn": None, | ||
"external": None, | ||
"targetPort": 80, | ||
"exposedPort": None, | ||
"transport": "Auto", | ||
"traffic": [ | ||
{ | ||
"revisionName": None, | ||
"weight": 100, | ||
"latestRevision": 0, | ||
"label": None | ||
} | ||
], | ||
"customDomains": None, | ||
"allowInsecure": 0, | ||
"ipSecurityRestrictions": None, | ||
"stickySessions": None, | ||
"clientCertificateMode": None, | ||
"corsPolicy": None | ||
}, | ||
"registries": None, | ||
"dapr": None, | ||
"maxInactiveRevisions": None | ||
}, | ||
}, | ||
} | ||
|
||
result_new = clean_null_values(test_dict) | ||
result_old = old_clean_null_values(test_dict) | ||
expect_result_for_new = { | ||
'properties': { | ||
"test": { | ||
"secrets": "secretTest", | ||
}, | ||
'configuration': { | ||
'activeRevisionsMode': 'Single', | ||
'ingress': { | ||
'targetPort': 80, | ||
'traffic': [ | ||
{ | ||
'weight': 100, | ||
'latestRevision': 0, | ||
} | ||
], | ||
'allowInsecure': 0, | ||
'transport': 'Auto' | ||
} | ||
} | ||
} | ||
} | ||
expect_result_for_old = { | ||
'properties': { | ||
"test": { | ||
"secrets": "secretTest", | ||
}, | ||
'configuration': { | ||
'activeRevisionsMode': 'Single', | ||
'ingress': { | ||
'targetPort': 80, | ||
'traffic': [ | ||
{ | ||
'weight': 100, | ||
} | ||
], | ||
'transport': 'Auto' | ||
} | ||
} | ||
} | ||
} | ||
self.assertEqual(expect_result_for_new, result_new) | ||
self.assertEqual(expect_result_for_old, result_old) | ||
|
||
|
||
# Remove null/None/empty properties in a model since the PATCH API will delete those. Not needed once we move to the SDK | ||
# This old version will remove properties which value is 0 | ||
# The new version is to fix this bug and should not change other behaviors | ||
def old_clean_null_values(d): | ||
if isinstance(d, dict): | ||
return { | ||
k: v | ||
for k, v in ((k, old_clean_null_values(v)) for k, v in d.items()) | ||
if v or isinstance(v, list) | ||
} | ||
if isinstance(d, list): | ||
return [v for v in map(old_clean_null_values, d) if v] | ||
return d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters