-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Henrydai/implement change state crud0901 #9357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
henryzdai
wants to merge
25
commits into
Azure:main
Choose a base branch
from
henryzdai:henrydai/implementChangeStateCRUD0901
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
06f5f1e
Add stub code
74a3d0f
Fix parsing
b80cda8
Fix parsing
add68de
Fix displaying
1f12482
Merge remote-tracking branch 'other-repo/henrydai/ImplementCRUDforCha…
aeb58e6
Fix commands
1636d5d
Add tests
b9696af
Merge remote-tracking branch 'other-repo/henrydai/ImplementCRUDforCha…
b26a3b2
Fix style
1a9b886
Merge remote-tracking branch 'other-repo/henrydai/ImplementCRUDforCha…
ea95cc0
Rename cli extension module name
6e4bdaa
Merge remote-tracking branch 'other-repo/henrydai/ImplementCRUDforCha…
bdeffae
Fix linter
c50dfe8
Merge remote-tracking branch 'other-repo/henrydai/ImplementCRUDforCha…
78286dd
Fix linter
421d339
Merge remote-tracking branch 'other-repo/henrydai/ImplementCRUDforCha…
56b725b
Fix linter
d03e382
Merge remote-tracking branch 'other-repo/henrydai/ImplementCRUDforCha…
964371c
Fix module name
34d2514
Merge remote-tracking branch 'other-repo/henrydai/ImplementCRUDforCha…
3f5b4d7
add test scenarios
f0d9bdc
Merge remote-tracking branch 'other-repo/henrydai/ImplementCRUDforCha…
1578369
Fix style
7274b10
Merge remote-tracking branch 'other-repo/henrydai/ImplementCRUDforCha…
6c8d92c
Add service name
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,8 @@ | ||
| .. :changelog: | ||
|
|
||
| Release History | ||
| =============== | ||
|
|
||
| 1.0.0b1 | ||
| ++++++ | ||
| * Initial release. | ||
This file contains hidden or 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,49 @@ | ||
| # Azure CLI Change Safety Extension | ||
| Azure CLI extension for managing Change Safety `ChangeState` resources used to coordinate operational changes across Azure targets. | ||
|
|
||
| ## Installation | ||
| ```bash | ||
| az extension add --source <path-to-extension-dist> --yes | ||
| # or install the latest published build | ||
| az extension add --name azure-changesafety | ||
| ``` | ||
|
|
||
| ## Commands | ||
| ```bash | ||
| az changesafety changestate create # Create a ChangeState definition for one or more targets. | ||
| az changesafety changestate update # Update metadata, rollout configuration, or target definitions. | ||
| az changesafety changestate delete # Delete a ChangeState resource. | ||
| az changesafety changestate show # Display details for a ChangeState resource. | ||
| ``` | ||
|
|
||
| Run `az changesafety changestate -h` to see full parameter details and examples. | ||
|
|
||
| ## Examples | ||
| Create a ChangeState describing a web app rollout: | ||
| ```bash | ||
| az changesafety changestate create \ | ||
| -g MyResourceGroup \ | ||
| -n webAppRollout01 \ | ||
| --change-type AppDeployment \ | ||
| --rollout-type Normal \ | ||
| --targets "resourceId=/subscriptions/<subId>/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/myApp,operation=create" \ | ||
| --links name=Runbook uri=https://contoso.com/runbook | ||
| ``` | ||
|
|
||
| Update the rollout type and add a comment: | ||
| ```bash | ||
| az changesafety changestate update \ | ||
| -g MyResourceGroup \ | ||
| -n webAppRollout01 \ | ||
| --rollout-type Emergency \ | ||
| --comments "Escalated due to customer impact" | ||
| ``` | ||
|
|
||
| Delete a ChangeState: | ||
| ```bash | ||
| az changesafety changestate delete -g MyResourceGroup -n webAppRollout01 --yes | ||
| ``` | ||
|
|
||
| ## Additional Information | ||
| - View command documentation: `az changesafety changestate -h` | ||
| - Remove the extension when no longer needed: `az extension remove --name azure-changesafety` |
This file contains hidden or 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,42 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from azure.cli.core import AzCommandsLoader | ||
| from azext_changesafety._help import helps # pylint: disable=unused-import | ||
|
|
||
|
|
||
| class ChangeStateCommandsLoader(AzCommandsLoader): | ||
|
|
||
| def __init__(self, cli_ctx=None): | ||
| from azure.cli.core.commands import CliCommandType | ||
| custom_command_type = CliCommandType( | ||
| operations_tmpl='azext_changesafety.custom#{}') | ||
| super().__init__(cli_ctx=cli_ctx, | ||
| custom_command_type=custom_command_type) | ||
|
|
||
| def load_command_table(self, args): | ||
| from azext_changesafety.commands import load_command_table | ||
| from azure.cli.core.aaz import load_aaz_command_table | ||
| try: | ||
| from . import aaz | ||
| except ImportError: | ||
| aaz = None | ||
| if aaz: | ||
| load_aaz_command_table( | ||
| loader=self, | ||
| aaz_pkg_name=aaz.__name__, | ||
| args=args | ||
| ) | ||
| load_command_table(self, args) | ||
| return self.command_table | ||
|
|
||
| def load_arguments(self, command): | ||
| from azext_changesafety._params import load_arguments | ||
| load_arguments(self, command) | ||
|
|
||
|
|
||
| COMMAND_LOADER_CLS = ChangeStateCommandsLoader |
This file contains hidden or 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,103 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: disable=line-too-long | ||
| # pylint: disable=too-many-lines | ||
|
|
||
| from knack.help_files import helps # pylint: disable=unused-import | ||
|
|
||
| helps['changesafety'] = """ | ||
| type: group | ||
| short-summary: Manage Change Safety resources. | ||
| """ | ||
|
|
||
| helps['changesafety changestate'] = """ | ||
| type: group | ||
| short-summary: Manage ChangeState resources that describe planned changes across targets. | ||
| """ | ||
|
|
||
| helps['changesafety changestate create'] = """ | ||
| type: command | ||
| short-summary: Create a ChangeState resource. | ||
| long-summary: > | ||
| Provide at least one target definition to describe which resources or operations the ChangeState | ||
| will affect. Targets are expressed as comma or semicolon separated key=value pairs such as | ||
| resourceId=RESOURCE_ID,operation=DELETE. The command is also available through the alias | ||
| `az change-safety change-state`. | ||
| parameters: | ||
| - name: --targets | ||
| short-summary: > | ||
| One or more target definitions expressed as key=value pairs (for example | ||
| resourceId=RESOURCE_ID,operation=CREATE,resourceType=Microsoft.Compute/virtualMachines). | ||
| - name: --change-type | ||
| short-summary: Classify the change such as AppDeployment, Config, ManualTouch, or PolicyDeployment. | ||
| - name: --rollout-type | ||
| short-summary: Specify the rollout urgency (Normal, Hotfix, or Emergency). | ||
| - name: --stage-map | ||
| short-summary: Reference an existing StageMap resource using resource-id=RESOURCE_ID and optional parameters key=value pairs. | ||
| - name: --links | ||
| short-summary: Add supporting links by repeating --links name=NAME uri=URL [description=TEXT]. | ||
| examples: | ||
| - name: Create with StageMap reference and status link | ||
| text: |- | ||
| az changesafety changestate create -g MyResourceGroup -n changestate002 --change-type ManualTouch --rollout-type Normal --stage-map "{resource-id:/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.ChangeSafety/stageMaps/rolloutStageMap}" --targets "resourceId=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm,operation=PATCH" --links "[{name:status,uri:'https://contoso.com/change/rollout-002'}]" | ||
| az changesafety changestate delete -g MyResourceGroup -n changestate002 --yes | ||
| - name: Create a change state for a VM rollout | ||
| text: |- | ||
| az changesafety changestate create -g MyResourceGroup -n changestate001 --change-type AppDeployment --rollout-type Normal --targets "resourceId=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm,operation=PUT" | ||
| - name: Create with staging rollout configuration | ||
| text: |- | ||
| az changesafety changestate create -g MyResourceGroup -n opsChange01 --rollout-type Hotfix --targets "resourceId=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/myApp,operation=POST" | ||
| """ | ||
|
|
||
| helps['changesafety changestate update'] = """ | ||
| type: command | ||
| short-summary: Update an existing ChangeState resource. | ||
| long-summary: > | ||
| Use this command to modify descriptive metadata, rollout settings, or replace targets for an | ||
| existing ChangeState. When you pass --targets, the supplied definitions overwrite the previous set. | ||
| This command is also available through the alias `az change-safety change-state`. | ||
| parameters: | ||
| - name: --targets | ||
| short-summary: > | ||
| Optional target definitions to replace the existing list. Provide key=value pairs such as | ||
| resourceId=RESOURCE_ID,operation=DELETE. | ||
| - name: --comments | ||
| short-summary: Provide notes about the latest update to the change state. | ||
| - name: --anticipated-start-time | ||
| short-summary: Update the expected start time in ISO 8601 format. | ||
| - name: --anticipated-end-time | ||
| short-summary: Update the expected completion time in ISO 8601 format. | ||
| examples: | ||
| - name: Adjust rollout type and add a comment | ||
| text: |- | ||
| az changesafety changestate update -g MyResourceGroup -n changestate001 --rollout-type Emergency --comments "Escalated to emergency rollout" | ||
| - name: Update scheduling window | ||
| text: |- | ||
| az changesafety changestate update -g MyResourceGroup -n changestate001 --anticipated-start-time "2024-09-01T08:00:00Z" --anticipated-end-time "2024-09-01T12:00:00Z" | ||
| - name: Replace the target definition | ||
| text: |- | ||
| az changesafety changestate update -g MyResourceGroup -n changestate001 --targets "resourceId=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Sql/servers/myServer,operation=PATCH" | ||
| """ | ||
|
|
||
| helps['changesafety changestate delete'] = """ | ||
| type: command | ||
| short-summary: Delete a ChangeState resource. | ||
| examples: | ||
| - name: Delete a change state without confirmation | ||
| text: |- | ||
| az changesafety changestate delete -g MyResourceGroup -n changestate001 --yes | ||
| """ | ||
|
|
||
| helps['changesafety changestate show'] = """ | ||
| type: command | ||
| short-summary: Show details for a ChangeState resource. | ||
| examples: | ||
| - name: Show a change state | ||
| text: |- | ||
| az changesafety changestate show -g MyResourceGroup -n changestate001 | ||
| """ |
This file contains hidden or 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,13 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: disable=too-many-lines | ||
| # pylint: disable=too-many-statements | ||
|
|
||
|
|
||
| def load_arguments(self, _): # pylint: disable=unused-argument | ||
| pass |
This file contains hidden or 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,6 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- |
10 changes: 10 additions & 0 deletions
10
src/azure-changesafety/azext_changesafety/aaz/latest/__init__.py
This file contains hidden or 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,10 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
23 changes: 23 additions & 0 deletions
23
src/azure-changesafety/azext_changesafety/aaz/latest/change_safety/__cmd_group.py
This file contains hidden or 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,23 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from azure.cli.core.aaz import * | ||
|
|
||
|
|
||
| @register_command_group( | ||
| "changesafety", | ||
| ) | ||
| class __CMDGroup(AAZCommandGroup): | ||
| """Manage Change Safety | ||
| """ | ||
| pass | ||
|
|
||
|
|
||
| __all__ = ["__CMDGroup"] |
11 changes: 11 additions & 0 deletions
11
src/azure-changesafety/azext_changesafety/aaz/latest/change_safety/__init__.py
This file contains hidden or 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,11 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from .__cmd_group import * |
23 changes: 23 additions & 0 deletions
23
...zure-changesafety/azext_changesafety/aaz/latest/change_safety/change_state/__cmd_group.py
This file contains hidden or 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,23 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from azure.cli.core.aaz import * | ||
|
|
||
|
|
||
| @register_command_group( | ||
| "changesafety changestate", | ||
| ) | ||
| class __CMDGroup(AAZCommandGroup): | ||
| """Manage Change State | ||
| """ | ||
| pass | ||
|
|
||
|
|
||
| __all__ = ["__CMDGroup"] |
15 changes: 15 additions & 0 deletions
15
src/azure-changesafety/azext_changesafety/aaz/latest/change_safety/change_state/__init__.py
This file contains hidden or 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,15 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from .__cmd_group import * | ||
| from ._create import * | ||
| from ._delete import * | ||
| from ._show import * | ||
| from ._update import * |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.