Skip to content

Commit 9eea5a9

Browse files
committed
chore: update output schema
1 parent a7e033b commit 9eea5a9

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

main.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ type Service struct {
2121
Patterns []string `json:"patterns,omitempty"`
2222
}
2323

24-
type CompiledGroup struct {
25-
Name Description `json:"name"`
26-
Services map[string]Service `json:"services"`
24+
type CompiledOutput struct {
25+
Groups map[string]Description `json:"groups"`
26+
Services map[string]Service `json:"services"`
2727
}
2828

2929
func main() {
@@ -33,12 +33,9 @@ func main() {
3333
os.Exit(1)
3434
}
3535

36-
compiled := make(map[string]*CompiledGroup, len(groups))
37-
for id, name := range groups {
38-
compiled[id] = &CompiledGroup{
39-
Name: name,
40-
Services: make(map[string]Service),
41-
}
36+
compiled := CompiledOutput{
37+
Groups: groups,
38+
Services: make(map[string]Service),
4239
}
4340

4441
entries, err := os.ReadDir("services")
@@ -68,13 +65,12 @@ func main() {
6865

6966
serviceID := strings.TrimSuffix(e.Name(), ".json")
7067

71-
group, ok := compiled[svc.Group]
72-
if !ok {
68+
if _, ok := groups[svc.Group]; !ok {
7369
fmt.Fprintf(os.Stderr, "unknown group %q in %s\n", svc.Group, e.Name())
7470
os.Exit(1)
7571
}
7672

77-
group.Services[serviceID] = svc
73+
compiled.Services[serviceID] = svc
7874
fmt.Printf("compiled: %s -> %s\n", serviceID, svc.Group)
7975
}
8076

@@ -91,7 +87,7 @@ func main() {
9187
os.Exit(1)
9288
}
9389

94-
fmt.Printf("successfully compiled %d services in %d groups to services.json\n", cnt, len(compiled))
90+
fmt.Printf("successfully compiled %d services in %d groups to services.json\n", cnt, len(compiled.Groups))
9591
}
9692

9793
func loadGroups(path string) (map[string]Description, error) {

0 commit comments

Comments
 (0)