Jose Diaz-Gonzalez

Require that environment exist before indexing it

...@@ -18,6 +18,7 @@ import yaml ...@@ -18,6 +18,7 @@ import yaml
18 import time 18 import time
19 import os 19 import os
20 import shutil 20 import shutil
21 +import sys
21 22
22 import kappa.function 23 import kappa.function
23 import kappa.restapi 24 import kappa.restapi
...@@ -48,6 +49,12 @@ class Context(object): ...@@ -48,6 +49,12 @@ class Context(object):
48 self._load_cache() 49 self._load_cache()
49 self.config = yaml.load(config_file) 50 self.config = yaml.load(config_file)
50 self.environment = environment 51 self.environment = environment
52 +
53 + if self.environment not in self.config.get('environments', {}):
54 + LOG.error('Invalid environment {0} specified'.format(
55 + self.environment))
56 + sys.exit(1)
57 +
51 profile = self.config['environments'][self.environment]['profile'] 58 profile = self.config['environments'][self.environment]['profile']
52 region = self.config['environments'][self.environment]['region'] 59 region = self.config['environments'][self.environment]['region']
53 self.session = kappa.awsclient.create_session(profile, region) 60 self.session = kappa.awsclient.create_session(profile, region)
......