def load_yaml(self, filename, serialization, k8s=False):
try:
# XXX This is a bit of a hack -- yaml.safe_load_all returns a
# generator, and if we don't use list() here, any exception
# dealing with the actual object gets deferred
ocount = 1
for obj in yaml.safe_load_all(serialization):
if k8s:
self.prep_k8s(filename, ocount, obj)
else:
self.objects_to_process.append((filename, ocount, obj))
ocount += 1
except Exception as e:
# No sense letting one attribute with bad YAML take down the whole
# gateway, so post the error but keep any objects we were able to
# parse before hitting the error.
self.filename = filename
self.ocount = ocount
self.post_error(RichStatus.fromError("%s: could not parse YAML" % filename))
评论列表
文章目录