Skip to content

Commit abfac96

Browse files
authored
Merge pull request #30 from cert-manager/revert-29-add_global_to_json_schema
Add global value to JSON schema (2nd try)
2 parents 347d151 + 999acc1 commit abfac96

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

schema/render.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"encoding/json"
2121
"fmt"
2222

23+
"github.com/cert-manager/helm-tool/heuristics"
2324
"github.com/cert-manager/helm-tool/parser"
2425
"github.com/cert-manager/helm-tool/paths"
2526
"gopkg.in/yaml.v3"
@@ -92,6 +93,23 @@ func buildTree(document *parser.Document) (treeLevel, error) {
9293
}
9394
}
9495

96+
// 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.
99+
root.add(paths.Path{}.WithProperty("global"), parser.Property{
100+
Type: parser.TypeUnknown,
101+
Description: parser.Comment{
102+
CommentBlock: heuristics.CommentBlock{
103+
Segments: []heuristics.CommentBlockSegment{
104+
{
105+
Type: heuristics.ContentTypeText,
106+
Contents: []string{"Global values shared across all (sub)charts"},
107+
},
108+
},
109+
},
110+
},
111+
})
112+
95113
return root, nil
96114
}
97115

@@ -154,12 +172,6 @@ func Render(document *parser.Document) (string, error) {
154172
definitions[prefixName(level.Path.String())] = newSchema
155173
})
156174

157-
definitions["global"] = spec.Schema{
158-
SchemaProps: spec.SchemaProps{
159-
Description: "Global values shared across all (sub)charts",
160-
},
161-
}
162-
163175
type JsonSchema struct {
164176
Schema string `json:"$schema,omitempty"`
165177
Ref string `json:"$ref,omitempty"`

0 commit comments

Comments
 (0)