Skip to content

Commit 461a108

Browse files
Merge pull request #42 from cert-manager/global_set_additionalProperties_false
Update global section to not have "additionalProperties: false"
2 parents b230556 + 1fc8483 commit 461a108

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

schema/render.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ func (t *treeLevel) Type() parser.Type {
5050
return parser.TypeUnknown
5151
}
5252

53-
func (t *treeLevel) add(path paths.Path, property parser.Property) error {
53+
func (t *treeLevel) add(path paths.Path, property parser.Property, pruneBranch bool) error {
5454
if path.Equal(t.Path) {
5555
t.Property = &property
56+
if pruneBranch {
57+
t.Children = nil
58+
}
5659
return nil
5760
}
5861

@@ -62,14 +65,14 @@ func (t *treeLevel) add(path paths.Path, property parser.Property) error {
6265

6366
for i, child := range t.Children {
6467
if child.Path.IsSubPathOf(path) {
65-
child.add(path, property)
68+
child.add(path, property, pruneBranch)
6669
t.Children[i] = child
6770
return nil
6871
}
6972
}
7073

7174
t.Children = append(t.Children, treeLevel{Path: t.Path.Expand(path, 1)})
72-
t.Children[len(t.Children)-1].add(path, property)
75+
t.Children[len(t.Children)-1].add(path, property, pruneBranch)
7376
return nil
7477
}
7578

@@ -88,14 +91,12 @@ func buildTree(document *parser.Document) (treeLevel, error) {
8891

8992
root := treeLevel{}
9093
for _, property := range allProperties {
91-
if err := root.add(property.Path, property); err != nil {
94+
if err := root.add(property.Path, property, false); err != nil {
9295
return treeLevel{}, err
9396
}
9497
}
9598

9699
// Add a global section to the root, as this is a special case.
97-
// TODO: also handle the case where there is a global section in the
98-
// values.yaml file.
99100
root.add(paths.Path{}.WithProperty("global"), parser.Property{
100101
Type: parser.TypeUnknown,
101102
Description: parser.Comment{
@@ -108,7 +109,7 @@ func buildTree(document *parser.Document) (treeLevel, error) {
108109
},
109110
},
110111
},
111-
})
112+
}, true)
112113

113114
return root, nil
114115
}

0 commit comments

Comments
 (0)