Skip to content

Commit

Permalink
Merge pull request #80 from lachmanfrantisek/correct-env-check
Browse files Browse the repository at this point in the history
Correct env_var check
  • Loading branch information
jpopelka authored Apr 11, 2018
2 parents 2e1953b + f2b309d commit 1589944
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions colin/checks/abstract/envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@ def __init__(self, name, message, description, reference_url, tags, env_var, req

def check(self, target):
env_vars = target.instance.get_metadata()["Config"]["Env"]
present = env_vars is not None and self.env_var in env_vars

env_vars_dict = {}
if env_vars:
for key_value in env_vars:
key, value = key_value.split("=")
env_vars_dict[key] = value
present = self.env_var in env_vars_dict
else:
present = False

if present:

if self.required and not self.value_regex:
passed = True
elif self.value_regex:
pattern = re.compile(self.value_regex)
passed = bool(pattern.match(env_vars[self.env_var]))
passed = bool(pattern.match(env_vars_dict[self.env_var]))
else:
passed = False

Expand Down

0 comments on commit 1589944

Please sign in to comment.