Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Bump aws-sam-translator #1043

Merged
merged 1 commit into from Mar 7, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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