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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Example lambda.json file:
"handler": "function.lambda_handler",
"role": "arn:aws:iam::00000000000:role/lambda_basic_execution",
"requirements": ["pygithub"],
"ignore": ["circle.yml"],
"timeout": 30,
"memory": 512
}
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Example lambda.json file:
"handler": "function.lambda_handler",
"role": "arn:aws:iam::00000000000:role/lambda_basic_execution",
"requirements": ["pygithub"],
"ignore": ["circle.yml"],
"timeout": 30,
"memory": 512
}
Expand Down
7 changes: 7 additions & 0 deletions example/circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
machine:
python:
version: 2.7

test:
override:
- flake8 .
1 change: 1 addition & 0 deletions example/lambda.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"handler": "function.lambda_handler",
"role": "arn:aws:iam::00000000000:role/lambda_basic_execution",
"requirements": ["Jinja2==2.8"],
"ignore": ["circle.yml"],
"timeout": 30,
"memory": 512
}
9 changes: 5 additions & 4 deletions lambda_uploader/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
import json
from os import path

REQUIRED_PARAMS = {'name': basestring, 'description': basestring,
'region': basestring, 'handler': basestring,
'role': basestring, 'timeout': int, 'memory': int}
REQUIRED_PARAMS = {u'name': basestring, u'description': basestring,
u'region': basestring, u'handler': basestring,
u'role': basestring, u'timeout': int, u'memory': int}

DEFAULT_PARAMS = {u'requirements': [], u'publish': False,
u'alias': None, u'alias_description': None}
u'alias': None, u'alias_description': None,
u'ignore': []}


class Config(object):
Expand Down
10 changes: 6 additions & 4 deletions lambda_uploader/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
ZIPFILE_NAME = 'lambda_function.zip'


def build_package(path, requirements, virtualenv=None):
def build_package(path, requirements, virtualenv=None, ignore=[]):
pkg = Package(path, virtualenv)

pkg.clean_workspace()
Expand All @@ -40,7 +40,7 @@ def build_package(path, requirements, virtualenv=None):
LOG.info('Building new virtualenv and installing requirements')
pkg.prepare_virtualenv()
pkg.install_requirements(requirements)
pkg.package()
pkg.package(ignore)
return pkg


Expand Down Expand Up @@ -103,7 +103,7 @@ def install_requirements(self, requirements):
if prc.returncode is not 0:
raise Exception('pip returned unsuccessfully')

def package(self):
def package(self, ignore=[]):
package = os.path.join(self._temp_workspace, 'lambda_package')

# Copy site packages into package base
Expand All @@ -122,7 +122,9 @@ def package(self):
LOG.info('Copying lib64 site packages')
utils.copy_tree(lib64_path, package)

utils.copy_tree(self._path, package, ignore=[TEMP_WORKSPACE_NAME])
# Append the temp workspace to the ignore list
ignore.append("^%s/*" % self._temp_workspace)
utils.copy_tree(self._path, package, ignore)
self._create_zip(package)

def _create_zip(self, src):
Expand Down
3 changes: 2 additions & 1 deletion lambda_uploader/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def _execute(args):
cfg = config.Config(pth, args.config, role=args.role)

_print('Building Package')
pkg = package.build_package(pth, cfg.requirements, args.virtualenv)
pkg = package.build_package(pth, cfg.requirements,
args.virtualenv, cfg.ignore)

if not args.no_clean:
pkg.clean_workspace()
Expand Down
3 changes: 2 additions & 1 deletion lambda_uploader/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import shutil
import logging
import re


LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -45,6 +46,6 @@ def _ignore_file(path, ignore=[]):
if not ignore:
return False
for ign in ignore:
if ign in path:
if re.search(ign, path):
return True
return False
3 changes: 2 additions & 1 deletion test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
'bar/foo.py',
'bar/bar/foo.py',
'ignore/foo.py'
'ignore-me.py'
]

TEST_IGNORE = ['ignore/']
TEST_IGNORE = ['ignore/*', 'ignore-me.py']


def test_copy_tree():
Expand Down