Skip to content

Commit

Permalink
Chore: Bump aws-sam-translator to 1.10.0 (#1043)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfuss authored and sanathkr committed Mar 7, 2019
1 parent cb798df commit c2ebb38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
2 changes: 1 addition & 1 deletion requirements/base.txt
Expand Up @@ -6,7 +6,7 @@ Flask~=1.0.2
boto3~=1.9, >=1.9.56
PyYAML~=3.12
cookiecutter~=1.6.0
aws-sam-translator==1.9.1
aws-sam-translator==1.10.0
docker>=3.3.0
dateparser~=0.7
python-dateutil~=2.6
Expand Down
25 changes: 3 additions & 22 deletions samcli/commands/validate/lib/sam_template_validator.py
Expand Up @@ -59,29 +59,10 @@ def is_valid(self):

self._replace_local_codeuri()

# In the Paser class, within the SAM Translator, they log a warning for when the template
# does not match the schema. The logger they use is the root logger instead of one scoped to
# their module. Currently this does not cause templates to fail, so we will suppress this
# by patching the logging.warning method that is used in that class.
class WarningSuppressLogger(object):

def __init__(self, obj_to_patch):
self.obj_to_patch = obj_to_patch

def __enter__(self):
self.obj_to_patch.warning = self.warning

def __exit__(self, exc_type, exc_val, exc_tb):
self.obj_to_patch.warning = self.obj_to_patch.warning

def warning(self, message):
pass

try:
with WarningSuppressLogger(parser.logging):
template = sam_translator.translate(sam_template=self.sam_template,
parameter_values={})
LOG.debug("Translated template is:\n%s", yaml_dump(template))
template = sam_translator.translate(sam_template=self.sam_template,
parameter_values={})
LOG.debug("Translated template is:\n%s", yaml_dump(template))
except InvalidDocumentException as e:
raise InvalidSamDocumentException(
functools.reduce(lambda message, error: message + ' ' + str(error), e.causes, str(e)))
Expand Down

0 comments on commit c2ebb38

Please sign in to comment.