allow yaml parser to handle secret values

Secrets are encrypted and base64 encoded and tagged with
'!encrypted/pkcs1-oaep'. This change allows us to read those values
without decrypting them, although the emitted representation no longer
matches. We at least get a patch instead of a traceback.

Change-Id: Ief533421faf9066f22d8b09c813832b75b6007fe
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-08-18 19:01:07 -04:00
parent 9d54a1224f
commit d8d8bd2661

View File

@ -22,11 +22,15 @@ def none_representer(dumper, data):
class YAML(object):
def __init__(self):
self.yaml = ruamel.yaml.YAML()
self.yaml = ruamel.yaml.YAML(typ='rt')
self.yaml.width = 256
self.yaml.allow_duplicate_keys = True
self.yaml.representer.add_representer(type(None), none_representer)
self.yaml.indent(mapping=2, sequence=4, offset=2)
self.yaml.Constructor.add_constructor(
'!encrypted/pkcs1-oaep',
ruamel.yaml.SafeConstructor.construct_yaml_seq,
)
def load(self, stream):
return self.yaml.load(stream)