Skip to content

Commit

Permalink
fix bug with --auth-mode (Azure#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
williexu authored Jan 1, 2019
1 parent 104b802 commit 87d322d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
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

0 comments on commit 87d322d

Please sign in to comment.