/
main.go
75 lines (61 loc) · 1.9 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
import (
"encoding/json"
"fmt"
"os"
"sort"
"strings"
"golang.org/x/exp/maps"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
func printDocForSchema(schema map[string]any, indentLevel int) {
indentStr := strings.Repeat(" ", indentLevel)
names := maps.Keys(schema)
sort.Slice(names, func(a, b int) bool {
if names[a] == "global" {
return true
}
if names[b] == "global" {
return false
}
return names[a] < names[b]
})
for _, name := range names {
value := schema[name].(map[string]any)
desc := ""
if descAny, ok := value["description"]; ok {
desc = " " + descAny.(string)
}
typeStr := value["type"].(string)
if typeStr == "object" {
typeStr = ""
} else {
typeStr = " (_" + cases.Title(language.AmericanEnglish).String(typeStr) + "_)"
}
fmt.Printf("%s- `%s`%s:%s\n", indentStr, name, typeStr, desc)
if value["type"].(string) == "object" {
printDocForSchema(value["properties"].(map[string]any), indentLevel+1)
}
}
}
func main() {
fmt.Printf(`# Korifi Helm chart
This documents the [Helm](https://helm.sh/) chart for [Korifi](https://github.com/cloudfoundry/korifi).
The configuration for each individual component is nested under a top-level key named after the component itself.
Values at the top-level apply to all components.
Each component can be excluded from the deployment by the setting its %[1]sinclude%[1]s value to %[1]sfalse%[1]s.
See [_Customizing the Chart Before Installing_](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing) for details on how to specify values when installing a Helm chart.
Here are all the values that can be set for the chart:
`, "`")
bs, err := os.ReadFile("helm/korifi/values.schema.json")
if err != nil {
panic(err)
}
var schema map[string]any
err = json.Unmarshal(bs, &schema)
if err != nil {
panic(err)
}
printDocForSchema(schema["properties"].(map[string]any), 0)
}