Allow json output

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-06-30 19:07:03 +02:00
parent c3bb19a780
commit 3f70047f72
4 changed files with 91 additions and 11 deletions

View File

@@ -29,6 +29,7 @@ var (
func main() {
outputPath := flag.String("output", "/etc/probod/config.yml", "output path for the generated config file")
format := flag.String("format", "yaml", "output format for the generated config file (yaml or json)")
showVersion := flag.Bool("version", false, "print version and exit")
flag.Parse()
@@ -38,6 +39,17 @@ func main() {
return
}
var configFormat bootstrap.Format
switch *format {
case "yaml":
configFormat = bootstrap.FormatYAML
case "json":
configFormat = bootstrap.FormatJSON
default:
fmt.Fprintf(os.Stderr, "error: unsupported format %q, must be yaml or json\n", *format)
os.Exit(1)
}
builder := bootstrap.NewBuilder(bootstrap.NewResolver(nil))
cfg, err := builder.Build()
@@ -46,7 +58,7 @@ func main() {
os.Exit(1)
}
if err := bootstrap.WriteConfig(cfg, *outputPath); err != nil {
if err := bootstrap.WriteConfig(cfg, *outputPath, configFormat); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}