-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Core] Update local context on/off status to global user level #13277
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
Conversation
|
local context |
|
I would prefer title
|
| self.initialize() | ||
|
|
||
| def initialize(self): | ||
| self.username = _get_current_username(self.cli_ctx) |
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.
_get_current_username [](start = 24, length = 21)
what about sp and msi
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.
As discussed in the review meeting, username here changed to system account.
|
|
||
| def _load_local_context_file(self): | ||
| current_dir = os.getcwd() | ||
| current_dir = self.current_dir |
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.
current_dir = self.current_dir [](start = 8, length = 30)
do you need a local current_dir?
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.
As you can see, os.getcwd may throw an exception and the value may be frequently used in get/set function.
The benefits to add a local current_dir may contain these:
- control to print working directory warning only once easily. (If
set/_load_callos.getcwddirectly, it may be a little complex to make it print the warning message only once becauseset/_loadmay be called multi times in one command) - may have very little performance advantages.
| logger.debug('The working directory has been deleted or recreated. Local context is ignored.') | ||
|
|
||
| self.local_context_file = None | ||
| if self.is_on and self.current_dir: |
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.
move to _load_local_context_file()?
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.
There are some logic updates here. _load_local_context_file update to _load_local_context_files, it may also be called if local context is off (show/delete command when local context is off). Also update self.local_context_file to self._local_context_file, it is loaded only once(when local context is on) and only used for get/set for local context parameter value.
src/azure-cli/azure/cli/command_modules/configure/tests/latest/test_configure.py
Outdated
Show resolved
Hide resolved
qianwens
left a comment
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.
![]()
Description
This PR is to support below features for local context:
show/deletecommand foraz local-contextLocalContextScenarioTestclass in testsdk. All test cases for local context should extend it and it will do turn on/off work automatically.Testing Guide
az local-context onaz group create -g myGroup -l eastasiaaz network vnet create -n myVNet --subnet-name mySubnetaz local-context showaz local-context show --name vnet_name subnet_nameaz local-context delete --name resource_group_nameaz local-context showaz local-context delete --allaz local-context delete --all --purgeaz local-context offHistory Notes
[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change.
[Component Name 2] az command b: Add some customer-facing feature.
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.