-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Config] Rename local-context to config param-persist #15068
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
63d02a9
[Config] Rename local-context to config parampersist
arrownj 03856d7
update warning message
arrownj 4cdebc8
fix sytle/linter error
arrownj 3eba829
fix style/linter error
arrownj 86e9ba8
udpate some message
arrownj e0db83e
update some message
arrownj c3ecb91
update help message
arrownj 4398f6b
update to param-persist
arrownj 4b4226f
fix test
arrownj 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,13 @@ def load_arguments(self, _): | |
c.argument('local', action='store_true', | ||
help='Include local configuration. Scan from the working directory up to the root drive, then the global configuration ' | ||
'and unset the first occurrence.') | ||
|
||
with self.argument_context('config param-persist show') as c: | ||
c.positional('name', nargs='*', help='Space-separated list of parameter persistence names.') | ||
|
||
with self.argument_context('config param-persist delete') as c: | ||
c.positional('name', nargs='*', help='Space-separated list of parameter persistence names. Either positional name argument or --all can be specified.') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Support no value here. |
||
c.argument('all', help='Clear all parameter persistence data. Either positional name argument or --all can be specified.', action='store_true') | ||
c.argument('yes', options_list=['--yes', '-y'], help='Do not prompt for confirmation. Only available when --all is specified.', action='store_true') | ||
c.argument('purge', help='Delete parameter persistence file from working directory. Only available when --all is specified.', action='store_true') | ||
c.argument('recursive', help='Indicate this is recursive delete of parameter persistence. Only available when --all is specified.', action='store_true') |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we change the file name
local_context.py
to avoid inconsistency?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as I described in the PR description, this PR is only attempted to update the UE part, actually the internal class / persist file / test framework are still called
Local Context
(az local-context is marked deprecated but not totally removed yet). Let's leave the internal renaming work to totally removeaz local-context
command.