Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
StackModels.DeploymentStacksWhatIfChangeType.MODIFY,
StackModels.DeploymentStacksWhatIfChangeType.DELETE,
StackModels.DeploymentStacksWhatIfChangeType.NO_CHANGE,
StackModels.DeploymentStacksWhatIfChangeType.DETACH
StackModels.DeploymentStacksWhatIfChangeType.DETACH,
StackModels.DeploymentStacksWhatIfPropertyChangeType.NO_EFFECT
]


Expand All @@ -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: '!',
})

Expand All @@ -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(
Expand Down Expand Up @@ -472,16 +474,19 @@ 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:
if not 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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
"before": "resourceA-before",
"after": "resourceA-after",
"children": []
},
{
"path": "sku.tier",
"changeType": "noEffect",
"after": "Standard",
"children": []
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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}

Expand Down
Loading