diff --git a/src/azure-cli/azure/cli/command_modules/resource/_stacks_formatters.py b/src/azure-cli/azure/cli/command_modules/resource/_stacks_formatters.py index e798f0dc5e1..01c0ed8ea89 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/_stacks_formatters.py +++ b/src/azure-cli/azure/cli/command_modules/resource/_stacks_formatters.py @@ -22,7 +22,8 @@ StackModels.DeploymentStacksWhatIfChangeType.MODIFY, StackModels.DeploymentStacksWhatIfChangeType.DELETE, StackModels.DeploymentStacksWhatIfChangeType.NO_CHANGE, - StackModels.DeploymentStacksWhatIfChangeType.DETACH + StackModels.DeploymentStacksWhatIfChangeType.DETACH, + StackModels.DeploymentStacksWhatIfPropertyChangeType.NO_EFFECT ] @@ -38,7 +39,7 @@ class DeploymentStacksWhatIfResultFormatter: # pylint: disable=too-few-public-m StackModels.DeploymentStacksWhatIfChangeType.DETACH: 'v', StackModels.DeploymentStacksWhatIfChangeType.MODIFY: '~', StackModels.DeploymentStacksWhatIfChangeType.NO_CHANGE: '=', - StackModels.DeploymentStacksWhatIfPropertyChangeType.NO_EFFECT: '=', + StackModels.DeploymentStacksWhatIfPropertyChangeType.NO_EFFECT: 'x', StackModels.DeploymentStacksWhatIfChangeType.UNSUPPORTED: '!', }) @@ -48,7 +49,8 @@ class DeploymentStacksWhatIfResultFormatter: # pylint: disable=too-few-public-m StackModels.DeploymentStacksWhatIfChangeType.CREATE: Color.GREEN, StackModels.DeploymentStacksWhatIfChangeType.DELETE: Color.RED, StackModels.DeploymentStacksWhatIfChangeType.DETACH: Color.BLUE, - StackModels.DeploymentStacksWhatIfChangeType.MODIFY: Color.PURPLE + StackModels.DeploymentStacksWhatIfChangeType.MODIFY: Color.PURPLE, + StackModels.DeploymentStacksWhatIfPropertyChangeType.NO_EFFECT: Color.GRAY, }) CHANGE_CERTAINTY_PRIORITIES = CaseInsensitiveDict( @@ -472,8 +474,11 @@ def _format_array_changes( def _format_primitive_change( self, - primitive_change: t.Optional[ - t.Union[StackModels.DeploymentStacksChangeBase, StackModels.DeploymentStacksWhatIfPropertyChange]], + primitive_change: t.Optional[t.Union[ + StackModels.DeploymentStacksChangeBase, + StackModels.DeploymentStacksWhatIfPropertyChange, + StackModels.DeploymentStacksChangeBaseDenyStatusMode, + StackModels.DeploymentStacksChangeBaseDeploymentStacksManagementStatus]], parent_path: t.Optional[str] = None, is_array_item: bool = False ) -> bool: @@ -481,7 +486,7 @@ def _format_primitive_change( return False change_type = primitive_change.change_type if hasattr(primitive_change, "change_type") else None - change_type = (change_type or (StackModels.DeploymentStacksWhatIfPropertyChangeType.NO_EFFECT + change_type = (change_type or (StackModels.DeploymentStacksWhatIfChangeType.NO_CHANGE if primitive_change.before == primitive_change.after else StackModels.DeploymentStacksWhatIfPropertyChangeType.MODIFY)) diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/data/stacks-what-if/what-if-1.json b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/data/stacks-what-if/what-if-1.json index ca2187d8fc6..4d0ac8bbf39 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/data/stacks-what-if/what-if-1.json +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/data/stacks-what-if/what-if-1.json @@ -69,6 +69,12 @@ "before": "resourceA-before", "after": "resourceA-after", "children": [] + }, + { + "path": "sku.tier", + "changeType": "noEffect", + "after": "Standard", + "children": [] } ] }, diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_stack_formatters.py b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_stack_formatters.py index b58a1f58f9a..a306ecfcbf1 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_stack_formatters.py +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_stack_formatters.py @@ -23,6 +23,7 @@ def test_what_if_1(self): what_if_result = self._get_stacks_what_if_result("what-if-1.json") formatted = DeploymentStacksWhatIfResultFormatter().format(what_if_result) + print(formatted) self.assertEqual(self.EXPECTED_STACKS_WHAT_IF_1, formatted) expected_no_color_result = self.EXPECTED_STACKS_WHAT_IF_1 @@ -36,6 +37,7 @@ def test_what_if_2(self): what_if_result = self._get_stacks_what_if_result("what-if-2.json") formatted = DeploymentStacksWhatIfResultFormatter().format(what_if_result) + print(formatted) self.assertEqual(self.EXPECTED_STACKS_WHAT_IF_2, formatted) expected_no_color_result = self.EXPECTED_STACKS_WHAT_IF_2 @@ -62,6 +64,7 @@ def _get_stacks_what_if_test_file_path(file_name: str): {Color.GREEN}+{Color.RESET} Create ! Unsupported {Color.PURPLE}~{Color.RESET} Modify {Color.RED}-{Color.RESET} Delete = NoChange {Color.BLUE}v{Color.RESET} Detach + {Color.GRAY}x{Color.RESET} NoEffect {Color.DARK_YELLOW}Changes to Stack /subscriptions/6d41d86d-eb6b-473a-b31d-bbd084e1814d/resourceGroups/503ace4c-9b1c-4059-a3e9-09553d24e9e1/providers/Microsoft.Resources/deploymentStacks/testStack_9ef16884f0dad7d0e5de3d3ec57:{Color.RESET} {Color.PURPLE}~{Color.RESET} DeploymentScope: {Color.PURPLE}"ThisIsBefore"{Color.RESET} => {Color.PURPLE}"ThisIsAfter"{Color.RESET} @@ -154,6 +157,7 @@ def _get_stacks_what_if_test_file_path(file_name: str): = Management Status: "Managed" {Color.PURPLE}~{Color.RESET} Deny Status: {Color.PURPLE}"None"{Color.RESET} => {Color.PURPLE}"DenyDelete"{Color.RESET} {Color.PURPLE}~{Color.RESET} properties.properties1: {Color.PURPLE}"resourceA-before"{Color.RESET} => {Color.PURPLE}"resourceA-after"{Color.RESET} + {Color.GRAY}x{Color.RESET} sku.tier: {Color.GRAY}"Standard"{Color.RESET} = /subscriptions/6d41d86d-eb6b-473a-b31d-bbd084e1814d/resourceGroups/503ace4c-9b1c-4059-a3e9-09553d24e9e1/providers/Microsoft.Test/testB/resourceB [2021-05-01] = Management Status: "Managed" {Color.PURPLE}~{Color.RESET} Deny Status: {Color.PURPLE}"None"{Color.RESET} => {Color.PURPLE}"DenyDelete"{Color.RESET} @@ -239,6 +243,7 @@ def _get_stacks_what_if_test_file_path(file_name: str): {Color.GREEN}+{Color.RESET} Create ! Unsupported {Color.PURPLE}~{Color.RESET} Modify {Color.RED}-{Color.RESET} Delete = NoChange {Color.BLUE}v{Color.RESET} Detach + {Color.GRAY}x{Color.RESET} NoEffect {Color.DARK_YELLOW}Changes to Managed Resources:{Color.RESET}