def _UploadFileToGcs(source, function_ref, stage_bucket):
    remote_zip_file = _GenerateRemoteZipFileName(function_ref.RelativeName())
    gcs_url = storage.BuildRemoteDestination(stage_bucket, remote_zip_file)
    if storage.Upload(source, gcs_url) != 0:
        raise exceptions.FunctionsError(
            'Failed to upload the function source code to the bucket {0}'.
            format(stage_bucket))
    return gcs_url
Beispiel #2
0
 def _PrepareSourcesOnGcs(self, args):
     remote_zip_file = self._GenerateFileName(args)
     # args.bucket is not None: Enforced in _CheckArgs().
     gcs_url = storage.BuildRemoteDestination(args.bucket, remote_zip_file)
     with file_utils.TemporaryDirectory() as tmp_dir:
         zip_file = self._CreateZipFile(tmp_dir, args)
         if self._UploadFile(zip_file, gcs_url) != 0:
             raise exceptions.FunctionsError('Function upload failed.')
     return gcs_url
Beispiel #3
0
 def _PrepareSourcesOnGcs(self, args):
     remote_zip_file = self._GenerateRemoteZipFileName(args)
     gcs_url = storage.BuildRemoteDestination(args.stage_bucket,
                                              remote_zip_file)
     with file_utils.TemporaryDirectory() as tmp_dir:
         zip_file = self._CreateZipFile(tmp_dir, args)
         if self._UploadFile(zip_file, gcs_url) != 0:
             raise exceptions.FunctionsError(
                 'Failed to upload the function source code to the bucket {0}'
                 .format(args.stage_bucket))
     return gcs_url
 def _PrepareSourcesOnGcs(self, args):
   remote_zip_file = self._GenerateRemoteZipFileName(args)
   if args.bucket is None:  # double check
     raise exceptions.FunctionsError('Missing bucket parameter'
                                     ' for function sources.')
   gcs_url = storage.BuildRemoteDestination(args.bucket, remote_zip_file)
   with file_utils.TemporaryDirectory() as tmp_dir:
     zip_file = self._CreateZipFile(tmp_dir, args)
     if self._UploadFile(zip_file, gcs_url) != 0:
       raise exceptions.FunctionsError('Function upload failed.')
   return gcs_url