initrd/tools/testconf/main.go
2024-01-20 16:41:54 +01:00

38 lines
514 B
Go

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