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

{Core} Use knack 0.8.0rc2 #16301

Merged
merged 9 commits into from
Dec 30, 2020
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
18 changes: 18 additions & 0 deletions src/azure-cli-core/azure/cli/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def __init__(self, **kwargs):

self.progress_controller = None

_configure_knack()

def refresh_request_id(self):
"""Assign a new random GUID as x-ms-client-request-id

Expand Down Expand Up @@ -851,3 +853,19 @@ def get_default_cli():
logging_cls=AzCliLogging,
output_cls=AzOutputProducer,
help_cls=AzCliHelp)


def _configure_knack():
"""Override consts defined in knack to make them Azure CLI-specific."""

# Customize status tag messages.
from knack.util import status_tag_messages
ref_message = "Reference and support levels: https://aka.ms/CLI_refstatus"
# Override the preview message.
status_tag_messages['preview'] = "{} is in preview and under development. " + ref_message
# Override the experimental message.
status_tag_messages['experimental'] = "{} is experimental and under development. " + ref_message

# Allow logs from 'azure' logger to be displayed.
from knack.log import cli_logger_names
cli_logger_names.append("azure")
9 changes: 9 additions & 0 deletions src/azure-cli-core/azure/cli/core/azlogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ def __init__(self, name, cli_ctx=None):
self.cli_ctx.register_event(EVENT_INVOKER_PRE_CMD_TBL_TRUNCATE, AzCliLogging.init_command_file_logging)
self.cli_ctx.register_event(EVENT_CLI_POST_EXECUTE, AzCliLogging.deinit_cmd_metadata_logging)

def configure(self, args):
super(AzCliLogging, self).configure(args)
from knack.log import CliLogLevel
if self.log_level == CliLogLevel.DEBUG:
# As azure.core.pipeline.policies.http_logging_policy is a redacted version of
# azure.core.pipeline.policies._universal, disable azure.core.pipeline.policies.http_logging_policy
# when debug log is shown.
logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(logging.CRITICAL)

def get_command_log_dir(self):
return self.command_log_dir

Expand Down
6 changes: 3 additions & 3 deletions src/azure-cli-core/azure/cli/core/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ def _resolve_preview_and_deprecation_warnings(self, cmd, parsed_args):
deprecate_kwargs['object_type'] = 'command'
del deprecate_kwargs['_get_tag']
del deprecate_kwargs['_get_message']
deprecations.append(ImplicitDeprecated(**deprecate_kwargs))
deprecations.append(ImplicitDeprecated(cli_ctx=self.cli_ctx, **deprecate_kwargs))

previews = [] + getattr(parsed_args, '_argument_previews', [])
if cmd.preview_info:
Expand All @@ -776,7 +776,7 @@ def _resolve_preview_and_deprecation_warnings(self, cmd, parsed_args):
preview_kwargs['object_type'] = 'command'
del preview_kwargs['_get_tag']
del preview_kwargs['_get_message']
previews.append(ImplicitPreviewItem(**preview_kwargs))
previews.append(ImplicitPreviewItem(cli_ctx=self.cli_ctx, **preview_kwargs))

experimentals = [] + getattr(parsed_args, '_argument_experimentals', [])
if cmd.experimental_info:
Expand All @@ -794,7 +794,7 @@ def _resolve_preview_and_deprecation_warnings(self, cmd, parsed_args):
experimental_kwargs['object_type'] = 'command'
del experimental_kwargs['_get_tag']
del experimental_kwargs['_get_message']
experimentals.append(ImplicitExperimentalItem(**experimental_kwargs))
experimentals.append(ImplicitExperimentalItem(cli_ctx=self.cli_ctx, **experimental_kwargs))

if not self.cli_ctx.only_show_errors:
for d in deprecations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def _prepare_client_kwargs_track2(cli_ctx):
client_kwargs['logging_enable'] = True

# Disable ARMHttpLoggingPolicy which logs only allowed headers
from azure.core.pipeline.policies import SansIOHTTPPolicy
client_kwargs['http_logging_policy'] = SansIOHTTPPolicy()
# from azure.core.pipeline.policies import SansIOHTTPPolicy
# client_kwargs['http_logging_policy'] = SansIOHTTPPolicy()

# Prepare User-Agent header, used by UserAgentPolicy
client_kwargs['user_agent'] = get_az_user_agent()
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
'colorama~=0.4.1',
'humanfriendly>=4.7,<9.0',
'jmespath',
'knack==0.7.2',
'knack==0.8.0rc2',
'msal~=1.0.0',
'msal-extensions~=0.1.3',
'msrestazure>=0.6.3',
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ isodate==0.6.0
Jinja2==2.10.1
jmespath==0.9.5
jsmin==2.2.2
knack==0.7.2
knack==0.8.0rc2
MarkupSafe==1.1.1
mock==4.0.2
msrest==0.6.18
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ isodate==0.6.0
Jinja2==2.10.1
jmespath==0.9.5
jsmin==2.2.2
knack==0.7.2
knack==0.8.0rc2
MarkupSafe==1.1.1
mock==4.0.2
msrest==0.6.18
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ isodate==0.6.0
Jinja2==2.10.1
jmespath==0.9.5
jsmin==2.2.2
knack==0.7.2
knack==0.8.0rc2
MarkupSafe==1.1.1
mock==4.0.2
msrest==0.6.18
Expand Down