Skip to content

Commit 44d9065

Browse files
Merge pull request #43 from cert-manager/global_set_additionalProperties_false
Update global section to not have "additionalProperties: false"
2 parents 461a108 + 882069d commit 44d9065

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

schema/render.go

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

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

@@ -65,14 +62,14 @@ func (t *treeLevel) add(path paths.Path, property parser.Property, pruneBranch b
6562

6663
for i, child := range t.Children {
6764
if child.Path.IsSubPathOf(path) {
68-
child.add(path, property, pruneBranch)
65+
child.add(path, property)
6966
t.Children[i] = child
7067
return nil
7168
}
7269
}
7370

7471
t.Children = append(t.Children, treeLevel{Path: t.Path.Expand(path, 1)})
75-
t.Children[len(t.Children)-1].add(path, property, pruneBranch)
72+
t.Children[len(t.Children)-1].add(path, property)
7673
return nil
7774
}
7875

@@ -91,7 +88,7 @@ func buildTree(document *parser.Document) (treeLevel, error) {
9188

9289
root := treeLevel{}
9390
for _, property := range allProperties {
94-
if err := root.add(property.Path, property, false); err != nil {
91+
if err := root.add(property.Path, property); err != nil {
9592
return treeLevel{}, err
9693
}
9794
}
@@ -109,7 +106,7 @@ func buildTree(document *parser.Document) (treeLevel, error) {
109106
},
110107
},
111108
},
112-
}, true)
109+
})
113110

114111
return root, nil
115112
}
@@ -165,7 +162,12 @@ func Render(document *parser.Document) (string, error) {
165162
}
166163

167164
newSchema.SchemaProps.Properties = properties
168-
if len(level.Children) > 0 {
165+
// For objects that we know the properties of, we disallow additional properties. Only when the
166+
// object is part of the "global" section do we allow additional properties. This is because this
167+
// "global" section is a special Helm section that is shared between all charts and subcharts and
168+
// thus might contain properties relevant only to other charts.
169+
// See https://helm.sh/docs/chart_template_guide/subcharts_and_globals/#global-chart-values for more information.
170+
if len(level.Children) > 0 && !(paths.Path{}).WithProperty("global").IsSubPathOf(level.Path) {
169171
newSchema.SchemaProps.AdditionalProperties = &spec.SchemaOrBool{Allows: false}
170172
}
171173
}

0 commit comments

Comments
 (0)