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
[Core] Update core for latest knack #8940
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,23 +121,10 @@ def __init__(self, loader, name, handler, description=None, table_transformer=No | |
self.command_kwargs = kwargs | ||
|
||
def _resolve_default_value_from_cfg_file(self, arg, overrides): | ||
from azure.cli.core._config import DEFAULTS_SECTION | ||
from azure.cli.core.commands.validators import DefaultStr | ||
|
||
if not hasattr(arg.type, 'required_tooling'): | ||
required = arg.type.settings.get('required', False) | ||
setattr(arg.type, 'required_tooling', required) | ||
if 'configured_default' in overrides.settings: | ||
def_config = overrides.settings.pop('configured_default', None) | ||
setattr(arg.type, 'default_name_tooling', def_config) | ||
# same blunt mechanism like we handled id-parts, for create command, no name default | ||
if self.name.split()[-1] == 'create' and overrides.settings.get('metavar', None) == 'NAME': | ||
return | ||
config_value = self.cli_ctx.config.get(DEFAULTS_SECTION, def_config, None) | ||
if config_value: | ||
logger.info("Configured default '%s' for arg %s", config_value, arg.name) | ||
overrides.settings['default'] = DefaultStr(config_value) | ||
overrides.settings['required'] = False | ||
# same blunt mechanism like we handled id-parts, for create command, no name default | ||
if self.name.split()[-1] == 'create' and overrides.settings.get('metavar', None) == 'NAME': | ||
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. Did we ignore defaults for create commands previously? |
||
return | ||
super(AzCliCommand, self)._resolve_default_value_from_cfg_file(arg, overrides) | ||
|
||
def load_arguments(self): | ||
super(AzCliCommand, self).load_arguments() | ||
|
@@ -154,19 +141,6 @@ def load_arguments(self): | |
help='Do not wait for the long-running operation to finish.'))) | ||
self.arguments.update(cmd_args) | ||
|
||
def update_argument(self, param_name, argtype): | ||
from azure.cli.core.commands.validators import DefaultStr, DefaultInt | ||
arg = self.arguments[param_name] | ||
self._resolve_default_value_from_cfg_file(arg, argtype) | ||
arg.type.update(other=argtype) | ||
arg_default = arg.type.settings.get('default', None) | ||
if isinstance(arg_default, str): | ||
arg_default = DefaultStr(arg_default) | ||
elif isinstance(arg_default, int): | ||
arg_default = DefaultInt(arg_default) | ||
if arg_default: | ||
arg.type.settings['default'] = arg_default | ||
|
||
def __call__(self, *args, **kwargs): | ||
return self.handler(*args, **kwargs) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
from azure.cli.core.profiles import ResourceType | ||
|
||
from knack.log import get_logger | ||
from knack.validators import DefaultStr, DefaultInt # pylint: disable=unused-import | ||
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. Avoid the breaking change to core that would occur if these were removed. |
||
|
||
logger = get_logger(__name__) | ||
|
||
|
@@ -118,19 +119,3 @@ def _dest_to_option(dest): | |
forbidden_string = ', '.join(_dest_to_option(x) for x in included_forbidden) | ||
error = '{}\n\tnot applicable: {}'.format(error, forbidden_string) | ||
raise CLIError(error) | ||
|
||
|
||
class DefaultStr(str): | ||
|
||
def __new__(cls, *args, **kwargs): | ||
instance = str.__new__(cls, *args, **kwargs) | ||
instance.is_default = True | ||
return instance | ||
|
||
|
||
class DefaultInt(int): | ||
|
||
def __new__(cls, *args, **kwargs): | ||
instance = int.__new__(cls, *args, **kwargs) | ||
instance.is_default = True | ||
return instance |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ | |
'colorama>=0.3.9', | ||
'humanfriendly>=4.7', | ||
'jmespath', | ||
'knack>=0.5.3', | ||
'knack>=0.5.4', | ||
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. While we're at it, should we use the |
||
'msrest>=0.4.4', | ||
'msrestazure>=0.4.25', | ||
'paramiko>=2.0.8', | ||
|
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.
I guess this is a "breaking change" but I suppose it can't be helped.