Skip to content
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

[Storage] fix bug with --auth-mode #462

Merged
merged 1 commit into from
Jan 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix bug with --auth-mode
  • Loading branch information
williexu committed Dec 31, 2018
commit 24832713d1ddb1a9c645f14c0edc1cf4ac738404
4 changes: 4 additions & 0 deletions src/storage-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.2.1 (tbd)
+++++++++++
* fixed missing `--auth-mode` from data-plane commands

0.2.0 (2018-12-14)
++++++++++++++++++
* created HISTORY.rst
Expand Down
11 changes: 8 additions & 3 deletions src/storage-preview/azext_storage_preview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,14 @@ def _register_data_plane_account_arguments(self, command_name):
def _register_data_plane_oauth_arguments(self, command_name):
from azure.cli.core.commands.parameters import get_enum_type

# workaround to allow use of AzArgumentContext.extra()
self.command_loader.command_name = command_name
with self.command_loader.argument_context(command_name) as c:
# The CLI's argument registration methods assume command table has finished loading and contain checks
# that reflect the state of the CLI at that point in time.
# The following code bypasses those checks, as these arguments are registered in tandem with commands.
if command_name not in self.command_loader.command_table:
return
self.command_loader.cli_ctx.invocation.data['command_string'] = command_name

with self.command_loader.argument_context(command_name, min_api='2017-11-09') as c:
c.extra('auth_mode', arg_type=get_enum_type(['login', 'key']),
help='The mode in which to run the command. "login" mode will directly use your login credentials '
'for the authentication. The legacy "key" mode will attempt to query for '
Expand Down
16 changes: 10 additions & 6 deletions src/storage-preview/azext_storage_preview/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@

from .profiles import CUSTOM_DATA_STORAGE, CUSTOM_MGMT_STORAGE, CUSTOM_MGMT_PREVIEW_STORAGE

NO_CREDENTIALS_ERROR_MESSAGE = """
No credentials specified to access storage service. Please provide any of the following:
MISSING_CREDENTIALS_ERROR_MESSAGE = """
Missing credentials to access storage service. The following variations are accepted:
(1) account name and key (--account-name and --account-key options or
set AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_KEY environment variables)
(2) connection string (--connection-string option or
set AZURE_STORAGE_CONNECTION_STRING environment variable)
(3) account name and SAS token (--sas-token option used with either the --account-name
(2) account name and SAS token (--sas-token option used with either the --account-name
option or AZURE_STORAGE_ACCOUNT environment variable)
(3) account name (--account-name option or AZURE_STORAGE_ACCOUNT environment variable;
this will make calls to query for a storage account key using login credentials)
(4) connection string (--connection-string option or
set AZURE_STORAGE_CONNECTION_STRING environment variable); some shells will require
quoting to preserve literal character interpretation.
"""


logger = get_logger(__name__)


Expand Down Expand Up @@ -69,7 +73,7 @@ def generic_data_service_factory(cli_ctx, service, name=None, key=None, connecti
'common._error#_ERROR_STORAGE_MISSING_INFO')
message = str(val_exception)
if message == _ERROR_STORAGE_MISSING_INFO:
message = NO_CREDENTIALS_ERROR_MESSAGE
message = MISSING_CREDENTIALS_ERROR_MESSAGE
raise CLIError(message)


Expand Down
2 changes: 1 addition & 1 deletion src/storage-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open
from setuptools import setup, find_packages

VERSION = "0.2.0"
VERSION = "0.2.1"

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand Down