-
Notifications
You must be signed in to change notification settings - Fork 104
/
main.go
41 lines (34 loc) · 828 Bytes
/
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
package main
import (
"bytes"
"encoding/json"
"flag"
"log"
"os"
"github.com/invopop/jsonschema"
"chainguard.dev/apko/pkg/build/types"
)
var (
outputFlag = flag.String("o", "", "output path")
)
func main() {
flag.Parse()
if *outputFlag == "" {
log.Fatal("output path is required")
}
r := new(jsonschema.Reflector)
if err := r.AddGoComments("chainguard.dev/apko/pkg/build", "../../pkg/build/types"); err != nil {
log.Fatal(err)
}
schema := r.Reflect(types.ImageConfiguration{})
b := new(bytes.Buffer)
enc := json.NewEncoder(b)
enc.SetIndent("", " ")
if err := enc.Encode(schema); err != nil {
log.Fatal(err)
}
//nolint:gosec // gosec wants us to use 0600, but making this globally readable is preferred.
if err := os.WriteFile(*outputFlag, b.Bytes(), 0644); err != nil {
log.Fatal(err)
}
}