-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Config] Rename local-context to config param-persist (#15068)
* [Config] Rename local-context to config param-persist
- Loading branch information
Showing
10 changed files
with
168 additions
and
9 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
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
21 changes: 21 additions & 0 deletions
21
src/azure-cli/azure/cli/command_modules/config/_validators.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,21 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from knack.util import CLIError | ||
|
||
|
||
def validate_param_persist(cmd, namespace): # pylint: disable=unused-argument | ||
if not cmd.cli_ctx.local_context.username: | ||
raise CLIError('Can\'t get system user account. Parameter persist is ignored.') | ||
if not cmd.cli_ctx.local_context.current_dir: | ||
raise CLIError('The working directory has been deleted or recreated. You can change to another working ' | ||
'directory or reenter current one if it is recreated.') | ||
|
||
|
||
def validate_param_persist_for_delete(cmd, namespace): | ||
if (namespace.all and namespace.name) or (not namespace.all and not namespace.name): | ||
raise CLIError('Please specify either positional argument name or --all.') | ||
|
||
validate_param_persist(cmd, namespace) |
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
26 changes: 26 additions & 0 deletions
26
src/azure-cli/azure/cli/command_modules/config/tests/latest/test_param_persist.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,26 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# 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.testsdk import LocalContextScenarioTest | ||
|
||
|
||
class ParamPersistScenarioTest(LocalContextScenarioTest): | ||
|
||
def test_param_persist_commands(self): | ||
self.cmd('config param-persist show') | ||
self.cmd('config param-persist show resource_group_name vnet_name') | ||
self.cmd('config param-persist delete resource_group_name vnet_name') | ||
self.cmd('config param-persist delete --all -y') | ||
self.cmd('config param-persist delete --all --purge -y') | ||
self.cmd('config param-persist delete --all --purge -y --recursive') | ||
|
||
from knack.util import CLIError | ||
with self.assertRaises(CLIError): | ||
self.cmd('config param-persist delete resource_group_name --all') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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