Browse Source

Support zuul.d directories

Change-Id: I3a0cba537043ffbc554f1bb1cfe951d86587b014
Monty Taylor 1 year ago
parent
commit
645c3d684d
No account linked to committer's email address
1 changed files with 15 additions and 2 deletions
  1. 15
    2
      zuul_sphinx/zuul.py

+ 15
- 2
zuul_sphinx/zuul.py View File

@@ -35,7 +35,7 @@ class ZuulDirective(Directive):
35 35
     def find_zuul_yaml(self):
36 36
         root = self.state.document.settings.env.relfn2path('.')[1]
37 37
         while root:
38
-            for fn in ['zuul.yaml', '.zuul.yaml']:
38
+            for fn in ['zuul.yaml', '.zuul.yaml', 'zuul.d', '.zuul.d']:
39 39
                 path = os.path.join(root, fn)
40 40
                 if os.path.exists(path):
41 41
                     return path
@@ -51,11 +51,24 @@ class ZuulDirective(Directive):
51 51
                 layout.jobs.append(obj['job'])
52 52
         return layout
53 53
 
54
+    def parse_zuul_d(self, path):
55
+        layout = Layout()
56
+        for conf in os.listdir(path):
57
+            with open(os.path.join(path, conf)) as f:
58
+                data = yaml.safe_load(f)
59
+            for obj in data:
60
+                if 'job' in obj:
61
+                    layout.jobs.append(obj['job'])
62
+        return layout
63
+
54 64
     def _parse_zuul_layout(self):
55 65
         env = self.state.document.settings.env
56 66
         if not env.domaindata['zuul']['layout']:
57 67
             path = self.find_zuul_yaml()
58
-            layout = self.parse_zuul_yaml(path)
68
+            if path.endswith('zuul.d'):
69
+                layout = self.parse_zuul_d(path)
70
+            else:
71
+                layout = self.parse_zuul_yaml(path)
59 72
             env.domaindata['zuul']['layout_path'] = path
60 73
             env.domaindata['zuul']['layout'] = layout
61 74
 

Loading…
Cancel
Save