Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Resolved Build issues on CLI style
  • Loading branch information
Kotasudhakarreddy committed Jan 28, 2021
commit 85fda3d44ff5f3e66e1fc0624bb74fb4f0821643
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def load_command_table(self, _):
g.custom_show_command('identity show', 'show_identity', validator=validate_app_or_slot_exists_in_rg)
g.custom_command('identity remove', 'remove_identity', validator=validate_app_or_slot_exists_in_rg)
g.custom_command('create-remote-connection', 'create_tunnel', exception_handler=ex_handler_factory())
g.custom_command('deploy', 'perform_onedeploy', validator= validate_onedeploy_params)
g.custom_command('deploy', 'perform_onedeploy', validator=validate_onedeploy_params)
g.generic_update_command('update', getter_name='get_webapp', setter_name='set_webapp', custom_func_name='update_webapp', command_type=appservice_custom)

with self.command_group('webapp traffic-routing') as g:
Expand Down
35 changes: 11 additions & 24 deletions src/azure-cli/azure/cli/command_modules/appservice/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4020,7 +4020,7 @@ def perform_onedeploy(cmd,

# Class for OneDeploy parameters
# pylint: disable=too-many-instance-attributes,too-few-public-methods
class OneDeployParams(object):
class OneDeployParams:
def __init__(self):
self.cmd = None
self.resource_group_name = None
Expand All @@ -4038,17 +4038,6 @@ def __init__(self):
# pylint: enable=too-many-instance-attributes,too-few-public-methods


#def _validate_onedeploy_params(params):
# if params.src_path and params.src_url:
# raise CLIError('Only one of --src-path and --src-url can be specified')

# if not params.src_path and not params.src_url:
# raise CLIError('Either of --src-path or --src-url must be specified')

# if params.src_url and not params.artifact_type:
# raise CLIError('Deployment type is mandatory when deploying from URLs. Use --type')


def _build_onedeploy_url(params):
scm_url = _get_scm_url(params.cmd, params.resource_group_name, params.webapp_name, params.slot)
deploy_url = scm_url + '/api/publish?type=' + params.artifact_type
Expand Down Expand Up @@ -4078,11 +4067,9 @@ def _get_onedeploy_status_url(params):

def _get_basic_headers(params):
import urllib3
from azure.cli.core.util import (
get_az_user_agent,
)

user_name, password = _get_site_credential(params.cmd.cli_ctx, params.resource_group_name, params.webapp_name, params.slot)
user_name, password = _get_site_credential(params.cmd.cli_ctx, params.resource_group_name,
params.webapp_name, params.slot)

if params.src_path:
content_type = 'application/octet-stream'
Expand All @@ -4101,15 +4088,15 @@ def _get_basic_headers(params):

def _get_onedeploy_request_body(params):
import os
import json

if params.src_path:
logger.info('Deploying from local path: %s', params.src_path)
try:
with open(os.path.realpath(os.path.expanduser(params.src_path)), 'rb') as fs:
body = fs.read()
except Exception as e:
raise CLIError("Either '{}' is not a valid local file path or you do not have permissions to access it".format(params.src_path)) from e
raise CLIError("Either '{}' is not a valid local file path or you do not have permissions to access it"
.format(params.src_path)) from e
elif params.src_url:
logger.info('Deploying from URL: %s', params.src_url)
body = json.dumps({
Expand Down Expand Up @@ -4164,7 +4151,8 @@ def _make_onedeploy_request(params):
if response.status_code == 202:
if poll_async_deployment_for_debugging:
logger.info('Polloing the status of async deployment')
response_body = _check_zip_deployment_status(params.cmd, params.resource_group_name, params.webapp_name, deployment_status_url, headers, params.timeout)
response_body = _check_zip_deployment_status(params.cmd, params.resource_group_name, params.webapp_name,
deployment_status_url, headers, params.timeout)
logger.info('Async deployment complete. Server response: %s', response_body)
return

Expand All @@ -4177,19 +4165,18 @@ def _make_onedeploy_request(params):

# check if there's an ongoing process
if response.status_code == 409:
raise CLIError("Another deployment is in progress. You can track the ongoing deployment at {}".format(deployment_status_url))
raise CLIError("Another deployment is in progress. You can track the ongoing deployment at {}"
.format(deployment_status_url))

# check if an error occured during deployment
if response.status_code:
raise CLIError("An error occured during deployment. Status Code: {}, Details: {}".format(response.status_code, response.text))
raise CLIError("An error occured during deployment. Status Code: {}, Details: {}"
.format(response.status_code, response.text))


# OneDeploy
def _perform_onedeploy_internal(params):

# Do basic paramter validation
# _validate_onedeploy_params(params)

# Update artifact type, if required
_update_artifact_type(params)

Expand Down