-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.go
36 lines (27 loc) · 914 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
/*
Copyright 2024 Chainguard, Inc.
SPDX-License-Identifier: Apache-2.0
*/
//go:generate go run ./
package main
import (
"flag"
"log"
"path/filepath"
"github.com/chainguard-dev/terraform-infra-common/modules/github-events/internal/schemagen"
"github.com/chainguard-dev/terraform-infra-common/modules/github-events/schemas"
)
var base = flag.String("base", "./../../schemas", "base directory to write to")
func main() {
flag.Parse()
mustGenerate("pull_request.schema.json", schemas.Wrapper[schemas.PullRequestEvent]{})
mustGenerate("workflow_run.schema.json", schemas.Wrapper[schemas.WorkflowRunEvent]{})
}
func mustGenerate[T any](path string, w schemas.Wrapper[T]) {
if err := generate(path, w); err != nil {
log.Fatalf("Failed to generate %T -> %s: %v", w, path, err)
}
}
func generate[T any](fn string, w schemas.Wrapper[T]) error {
return schemagen.Generate(filepath.Join(*base, fn), w)
}