initrd/tools/testconf/main.go

38 lines
514 B
Go
Raw Permalink Normal View History

2023-12-17 12:48:18 +00:00
package main
import (
"bytes"
"flag"
2024-01-20 15:41:54 +00:00
"fmt"
2023-12-17 12:48:18 +00:00
"os"
"gopkg.in/yaml.v3"
config "novit.tech/direktil/pkg/bootstrapconfig"
)
func main() {
flag.Parse()
for _, arg := range flag.Args() {
2024-01-20 15:41:54 +00:00
fmt.Println("testing", arg)
2023-12-17 12:48:18 +00:00
cfgBytes, err := os.ReadFile(arg)
2024-01-20 15:41:54 +00:00
fail(err)
2023-12-17 12:48:18 +00:00
cfg := config.Config{}
dec := yaml.NewDecoder(bytes.NewBuffer(cfgBytes))
dec.KnownFields(true)
err = dec.Decode(&cfg)
2024-01-20 15:41:54 +00:00
fail(err)
}
}
func fail(err error) {
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
2023-12-17 12:48:18 +00:00
}
}