fix: add missing vault yaml tag (#113)

This commit is contained in:
Robert Kaussow 2021-04-13 22:27:26 +02:00 committed by GitHub
parent a85c54287c
commit 5dae0a6976
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -20,6 +20,7 @@ from ansiblelater.exceptions import LaterError
from ansiblelater.utils import Singleton
from ansiblelater.utils import sysexit_with_message
from ansiblelater.utils.yamlhelper import UnsafeTag
from ansiblelater.utils.yamlhelper import VaultTag
from ansiblelater.utils.yamlhelper import action_tasks
from ansiblelater.utils.yamlhelper import normalize_task
from ansiblelater.utils.yamlhelper import normalized_yaml
@ -223,6 +224,9 @@ class StandardBase(object, metaclass=StandardExtendedMeta):
yaml.add_constructor(
UnsafeTag.yaml_tag, UnsafeTag.yaml_constructor, Loader=yaml.SafeLoader
)
yaml.add_constructor(
VaultTag.yaml_tag, VaultTag.yaml_constructor, Loader=yaml.SafeLoader
)
content = yaml.safe_load(f)
except yaml.YAMLError as e:
errors.append(
@ -244,6 +248,9 @@ class StandardBase(object, metaclass=StandardExtendedMeta):
yaml.add_constructor(
UnsafeTag.yaml_tag, UnsafeTag.yaml_constructor, Loader=yaml.SafeLoader
)
yaml.add_constructor(
VaultTag.yaml_tag, VaultTag.yaml_constructor, Loader=yaml.SafeLoader
)
yaml.safe_load(f)
for problem in linter.run(f, YamlLintConfig(options)):

View File

@ -593,3 +593,16 @@ class UnsafeTag:
@staticmethod
def yaml_constructor(loader, node):
return loader.construct_scalar(node)
class VaultTag:
"""Handle custom yaml vault tag."""
yaml_tag = u"!vault"
def __init__(self, value):
self.unsafe = value
@staticmethod
def yaml_constructor(loader, node):
return loader.construct_scalar(node)