summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-04-12 19:44:46 +0000
committerGerrit Code Review <review@openstack.org>2018-04-12 19:44:46 +0000
commit2516aeff565513e5e45303e128aa13d0f267a7dc (patch)
treea054b1abacc42dfcadc43b3d2b4fa5da944e1c88
parent80cffd198728c4c111b88e63c8943879e1127539 (diff)
parent3ef1afe17ee74f5420247463652efd71e6f1e406 (diff)
Merge "Make the yaml parser aware of '!encrypted/' tags"0.2.2
-rw-r--r--zuul_sphinx/zuul.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/zuul_sphinx/zuul.py b/zuul_sphinx/zuul.py
index 95d69cb..a140988 100644
--- a/zuul_sphinx/zuul.py
+++ b/zuul_sphinx/zuul.py
@@ -26,6 +26,17 @@ from docutils import nodes
26import yaml 26import yaml
27 27
28 28
29class ZuulSafeLoader(yaml.SafeLoader):
30
31 def __init__(self, *args, **kwargs):
32 super(ZuulSafeLoader, self).__init__(*args, **kwargs)
33 self.add_multi_constructor('!encrypted/', self.construct_encrypted)
34
35 @classmethod
36 def construct_encrypted(cls, loader, tag_suffix, node):
37 return loader.construct_sequence(node)
38
39
29class ProjectTemplate(object): 40class ProjectTemplate(object):
30 def __init__(self, conf): 41 def __init__(self, conf):
31 self.name = conf['name'] 42 self.name = conf['name']
@@ -72,7 +83,7 @@ class ZuulDirective(Directive):
72 83
73 def parse_zuul_yaml(self, path): 84 def parse_zuul_yaml(self, path):
74 with open(path) as f: 85 with open(path) as f:
75 data = yaml.safe_load(f) 86 data = yaml.load(f, Loader=ZuulSafeLoader)
76 layout = Layout() 87 layout = Layout()
77 for obj in data: 88 for obj in data:
78 if 'job' in obj: 89 if 'job' in obj:
@@ -86,7 +97,7 @@ class ZuulDirective(Directive):
86 layout = Layout() 97 layout = Layout()
87 for conf in os.listdir(path): 98 for conf in os.listdir(path):
88 with open(os.path.join(path, conf)) as f: 99 with open(os.path.join(path, conf)) as f:
89 data = yaml.safe_load(f) 100 data = yaml.load(f, Loader=ZuulSafeLoader)
90 for obj in data: 101 for obj in data:
91 if 'job' in obj: 102 if 'job' in obj:
92 layout.jobs.append(obj['job']) 103 layout.jobs.append(obj['job'])