Skip to content

Commit 8de5a97

Browse files
committed
Merge pull request #22 from calebgroom/config
Add --config to override lambda.json path
2 parents 6c77536 + a5a4030 commit 8de5a97

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

lambda_uploader/config.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424

2525

2626
class Config(object):
27-
def __init__(self, pth):
27+
def __init__(self, pth, config_file=None):
2828
self._path = pth
2929
self._config = None
30-
self._load_config()
30+
self._load_config(config_file)
3131
self._set_defaults()
3232

3333
for param, clss in REQUIRED_PARAMS.iteritems():
@@ -81,12 +81,14 @@ def _validate(self, key, cls=None):
8181
% (key, cls, type(self._config[key])))
8282

8383
'''Load config ... called by init()'''
84-
def _load_config(self):
85-
config_file = path.join(self._path, 'lambda.json')
86-
if not path.isfile(config_file):
87-
raise Exception("lambda.json not found")
84+
def _load_config(self, lambda_file=None):
85+
if not lambda_file:
86+
lambda_file = path.join(self._path, 'lambda.json')
8887

89-
with open(config_file) as config_file:
88+
if not path.isfile(lambda_file):
89+
raise Exception("%s not found" % lambda_file)
90+
91+
with open(lambda_file) as config_file:
9092
self._config = json.load(config_file)
9193

9294
def __getattr__(self, key):

lambda_uploader/shell.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _print(txt):
4747
def _execute(args):
4848
pth = path.abspath(args.function_dir)
4949

50-
cfg = config.Config(pth)
50+
cfg = config.Config(pth, args.config)
5151

5252
_print('Building Package')
5353
pkg = package.build_package(pth, cfg.requirements)
@@ -89,7 +89,6 @@ def main(arv=None):
8989
parser.add_argument('--no-upload', dest='no_upload',
9090
action='store_const', help='dont upload the zipfile',
9191
const=True)
92-
9392
parser.add_argument('--no-clean', dest='no_clean',
9493
action='store_const',
9594
help='dont cleanup the temporary workspace',
@@ -105,6 +104,8 @@ def main(arv=None):
105104
default=None, help=alias_help)
106105
parser.add_argument('--alias-description', '-m', dest='alias_description',
107106
default=None, help='alias description')
107+
parser.add_argument('--config', help='Overrides lambda.json',
108+
default=None)
108109
parser.add_argument('function_dir', default=getcwd(), nargs='?',
109110
help='lambda function directory')
110111

0 commit comments

Comments
 (0)