Exemple #1
0
 def _PrepareSourcesOnGcs(self, args):
   """Create a zip file and upload it to GCS as specified by args."""
   with file_utils.TemporaryDirectory() as tmp_dir:
     local_path = deploy_util.GetLocalPath(args)
     zip_file = deploy_util.CreateSourcesZipFile(
         tmp_dir, local_path, args.include_ignored_files)
     return deploy_util.UploadFile(zip_file, args.name, args.stage_bucket)
 def _CreateZipFile(self, tmp_dir, args):
     zip_file_name = os.path.join(tmp_dir, 'fun.zip')
     local_path = deploy_util.GetLocalPath(args)
     try:
         archive.MakeZipFromDir(zip_file_name, local_path)
     except ValueError as e:
         raise exceptions.FunctionsError(
             'Error creating a ZIP archive with the source code '
             'for directory {0}: {1}'.format(local_path, str(e)))
     return zip_file_name
Exemple #3
0
 def _ValidateUnpackedSourceSize(self, args):
     ignore_regex = deploy_util.GetIgnoreFilesRegex(
         args.include_ignored_files)
     path = deploy_util.GetLocalPath(args)
     size_b = file_utils.GetTreeSizeBytes(path, ignore_regex)
     size_limit_mb = 512
     size_limit_b = size_limit_mb * 2**20
     if size_b > size_limit_b:
         raise exceptions.OversizedDeployment(
             str(size_b) + 'B',
             str(size_limit_b) + 'B')
Exemple #4
0
 def _CreateZipFile(self, tmp_dir, args):
     zip_file_name = os.path.join(tmp_dir, 'fun.zip')
     local_path = deploy_util.GetLocalPath(args)
     try:
         if args.include_node_modules:
             archive.MakeZipFromDir(zip_file_name, local_path)
         else:
             log.info(
                 'Not including node_modules in deployed code. To include '
                 'node_modules in uploaded code use --include-node-modules '
                 'flag.')
             archive.MakeZipFromDir(
                 zip_file_name,
                 local_path,
                 skip_file_regex=re.escape('node_modules' + os.sep))
     except ValueError as e:
         raise exceptions.FunctionsError(
             'Error creating a ZIP archive with the source code '
             'for directory {0}: {1}'.format(local_path, str(e)))
     return zip_file_name