CI / contracts (push) Canceled after 0s
Website / deploy (push) Canceled after 0s
CI / test (macos-latest) (push) Canceled after 0s
CI / test (ubuntu-24.04) (push) Canceled after 0s
CI / test (ubuntu-24.04-arm) (push) Canceled after 0s
CI / test (windows-latest) (push) Canceled after 0s
CI / Compact real-tool fixtures (ubuntu-24.04) (push) Canceled after 0s
CI / Compact real-tool fixtures (ubuntu-24.04-arm) (push) Canceled after 0s
CI / Code analysis fixtures (ubuntu-24.04) (push) Canceled after 0s
CI / Code analysis fixtures (ubuntu-24.04-arm) (push) Canceled after 0s
CI / Web engine fixtures (ubuntu-24.04) (push) Canceled after 0s
CI / Web engine fixtures (ubuntu-24.04-arm) (push) Canceled after 0s
CI / Chromium operation fixtures (ubuntu-24.04) (push) Canceled after 0s
CI / Chromium operation fixtures (ubuntu-24.04-arm) (push) Canceled after 0s
CI / operation-readiness (push) Canceled after 0s
CI / Supply chain fixtures (ubuntu-24.04) (push) Canceled after 0s
CI / Supply chain fixtures (ubuntu-24.04-arm) (push) Canceled after 0s
38 lines
672 B
Go
38 lines
672 B
Go
// Package schemas embeds CYBOT's canonical JSON Schemas into the executable.
|
|
package schemas
|
|
|
|
import (
|
|
"embed"
|
|
"fmt"
|
|
"sort"
|
|
)
|
|
|
|
//go:embed *.json
|
|
var files embed.FS
|
|
|
|
func Names() []string {
|
|
entries, _ := files.ReadDir(".")
|
|
out := make([]string, 0, len(entries))
|
|
for _, e := range entries {
|
|
if !e.IsDir() {
|
|
out = append(out, e.Name()[:len(e.Name())-5])
|
|
}
|
|
}
|
|
sort.Strings(out)
|
|
return out
|
|
}
|
|
func Get(name string) ([]byte, error) {
|
|
b, err := files.ReadFile(name + ".json")
|
|
if err != nil {
|
|
return nil, fmt.Errorf("unknown schema %q", name)
|
|
}
|
|
return b, nil
|
|
}
|
|
func Must(name string) []byte {
|
|
b, err := Get(name)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return b
|
|
}
|