keyvault: make commands work in cloud shell or vms with identity#6319
Merged
Conversation
|
View a preview at https://prompt.ws/r/Azure/azure-cli/6319 |
yugangw-msft
commented
May 9, 2018
| 'The vault may not exist or you may need to flush your DNS cache ' | ||
| 'and try again later.') | ||
| raise CLIError(ex) | ||
| else: |
Contributor
Author
There was a problem hiding this comment.
@tjprescott, this is an optional change, if you feel it has side impact, I can revert/improve. So far this error handler swallows exceptions and hides the real issue.
| from azure.cli.core._profile import Profile | ||
| try: | ||
| return Profile(cli_ctx=cli_ctx).get_login_credentials(resource)[0]._token_retriever() # pylint: disable=protected-access | ||
| return Profile(cli_ctx=cli_ctx).get_raw_token(resource)[0] |
Contributor
Author
There was a problem hiding this comment.
I didn't write tests in this PR as i feel the existing testbed should be sufficient to capture potential regressions
tjprescott
reviewed
May 9, 2018
Member
tjprescott
left a comment
There was a problem hiding this comment.
LGTM. Would like @schaabs to review.
tjprescott
reviewed
May 10, 2018
| 'and try again later.') | ||
| raise CLIError(ex) | ||
| else: | ||
| raise ex |
Contributor
Author
There was a problem hiding this comment.
See below. I can still throw non CLIError, but need confirmation/encourage from your guys to proceed
@ResourceGroupPreparer(name_prefix='cli_test_kv_cert_issuer')
def test_keyvault_certificate_issuers(self, resource_group):
.....
# test admin commands
self.cmd('keyvault certificate issuer admin add --vault-name {kv} --issuer-name issuer1 --email test@test.com --first-name Test --last-name Admin --phone 123-456-7890', checks=[
...
])
# ---> fail below which i guess caused by adding dupe issuers<-----
self.cmd('keyvault certificate issuer admin add --vault-name {kv} --issuer-name issuer1 --email test@test.com') File "d:\sdk\azure-cli\src\command_modules\azure-cli-keyvault\azure\cli\command_modules\keyvault\_command_type.py", line 118, in keyvault_command_handler
return keyvault_exception_handler(ex)
File "d:\sdk\azure-cli\src\command_modules\azure-cli-keyvault\azure\cli\command_modules\keyvault\_command_type.py", line 47, in keyvault_exception_handler
raise ex
File "d:\sdk\azure-cli\src\command_modules\azure-cli-keyvault\azure\cli\command_modules\keyvault\_command_type.py", line 98, in keyvault_command_handler
result = op(**command_args)
File "d:\sdk\azure-cli\src\command_modules\azure-cli-keyvault\azure\cli\command_modules\keyvault\custom.py", line 800, in add_certificate_issuer_admin
raise CLIError("admin '{}' already exists".format(email))
knack.util.CLIError: admin 'test@test.com' already exists
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix #6313
The PR has modified HISTORY.rst describing any customer-facing, functional changes. Note that this does not include changes only to help content. (see Modifying change log).
I adhere to the Command Guidelines.