Skip to content
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
2 changes: 1 addition & 1 deletion src/spring/azext_spring/_buildservices_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def build_and_get_result(self, total_steps, **kwargs):
logger.warning("[1/{}] Requesting for upload URL.".format(total_steps))
upload_info = self._get_upload_info()
logger.warning("[2/{}] Uploading package to blob.".format(total_steps))
uploader_selector(upload_url=upload_info.upload_url, **kwargs).upload_and_build(**kwargs)
uploader_selector(cli_ctx=self.cmd.cli_ctx, upload_url=upload_info.upload_url, **kwargs).upload_and_build(**kwargs)
logger.warning("[3/{}] Creating or Updating build '{}'.".format(total_steps, kwargs['app']))
build_result_id = self._queue_build(upload_info.relative_path, **kwargs)
logger.warning("[4/{}] Waiting for building docker image to finish. This may take a few minutes.".format(total_steps))
Expand Down
4 changes: 2 additions & 2 deletions src/spring/azext_spring/_deployment_deployable_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def build_deployable_path(self, **kwargs):
return upload_info.relative_path

def _get_uploader(self, upload_url=None):
return FileUpload(upload_url=upload_url)
return FileUpload(upload_url=upload_url, cli_ctx=self.cmd.cli_ctx)


class SourceBuildDeployableBuilder(UploadDeployableBuilder):
Expand All @@ -82,7 +82,7 @@ def build_deployable_path(self, **kwargs):
return relative_path

def _get_uploader(self, upload_url=None):
return FolderUpload(upload_url=upload_url)
return FolderUpload(upload_url=upload_url, cli_ctx=self.cmd.cli_ctx)

def get_source_type(self, **_):
return 'Source'
Expand Down
12 changes: 7 additions & 5 deletions src/spring/azext_spring/_deployment_uploadable_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import tempfile
import uuid
from azure.cli.core.azclierror import InvalidArgumentValueError
from .azure_storage_file import FileService
from azure.cli.core.profiles import ResourceType, get_sdk
from ._utils import (get_azure_files_info, _pack_source_code)


Expand All @@ -22,20 +22,22 @@ class FileUpload:
'''
Upload a file in local file system to upload url
'''
def __init__(self, upload_url):
def __init__(self, upload_url, cli_ctx):
account_name, endpoint_suffix, share_name, relative_name, sas_token = get_azure_files_info(upload_url)
self.account_name = account_name
self.endpoint_suffix = endpoint_suffix
self.share_name = share_name
self.relative_name = relative_name
self.sas_token = sas_token
self.cli_ctx = cli_ctx

def upload_and_build(self, artifact_path, **_):
if not artifact_path:
raise InvalidArgumentValueError('--artifact-path is not set.')
self._upload(artifact_path)

def _upload(self, artifact_path):
FileService = get_sdk(self.cli_ctx, ResourceType.DATA_STORAGE, 'file#FileService')
file_service = FileService(self.account_name, sas_token=self.sas_token, endpoint_suffix=self.endpoint_suffix)
file_service.create_file_from_path(self.share_name, None, self.relative_name, artifact_path)

Expand All @@ -56,9 +58,9 @@ def _compress_folder(self, folder):
return file_path


def uploader_selector(source_path=None, artifact_path=None, upload_url=None, **_):
def uploader_selector(cli_ctx, source_path=None, artifact_path=None, upload_url=None, **_):
if source_path:
return FolderUpload(upload_url)
return FolderUpload(upload_url, cli_ctx)
if artifact_path:
return FileUpload(upload_url)
return FileUpload(upload_url, cli_ctx)
return Empty()
26 changes: 0 additions & 26 deletions src/spring/azext_spring/azure_storage_file/__init__.py

This file was deleted.

11 changes: 0 additions & 11 deletions src/spring/azext_spring/azure_storage_file/_constants.py

This file was deleted.

Loading