diff --git a/Makefile b/Makefile index 66a36ae3bf..fdbb99ce99 100644 --- a/Makefile +++ b/Makefile @@ -148,7 +148,6 @@ providers/proto: .PHONY: providers/config providers/config: go run ./providers-sdk/v1/util/configure/configure.go -f providers.yaml -o providers/builtin_dev.go - gofmt -w providers/builtin.go .PHONY: providers/lr providers/lr: diff --git a/providers-sdk/v1/util/configure/configure.go b/providers-sdk/v1/util/configure/configure.go index 676d396c45..da0becf68e 100644 --- a/providers-sdk/v1/util/configure/configure.go +++ b/providers-sdk/v1/util/configure/configure.go @@ -5,6 +5,7 @@ package main import ( "fmt" + "go/format" "os" "os/exec" "regexp" @@ -47,8 +48,11 @@ var rootCmd = &cobra.Command{ } builtinGo, err := genBuiltinGo(conf) + if err != nil { + log.Fatal().Err(err).Str("path", confPath).Msg("failed to generate builtin go") + } - if err = os.WriteFile(outPath, []byte(builtinGo), 0o644); err != nil { + if err = os.WriteFile(outPath, builtinGo, 0o644); err != nil { log.Fatal().Err(err).Str("path", outPath).Msg("failed to write output") } log.Info().Str("path", outPath).Strs("providers", conf.Builtin).Msg("(1/3) configured builtin providers") @@ -61,7 +65,7 @@ var rootCmd = &cobra.Command{ }, } -func genBuiltinGo(conf ProvidersConf) (string, error) { +func genBuiltinGo(conf ProvidersConf) ([]byte, error) { var imports string var infos string var configs string @@ -87,7 +91,8 @@ func genBuiltinGo(conf ProvidersConf) (string, error) { `, provider, provider, provider, provider, provider, provider, provider) } - return fmt.Sprintf(template, imports, infos, configs), nil + res := fmt.Sprintf(template, imports, infos, configs) + return format.Source([]byte(res)) } const template = `// Copyright (c) Mondoo, Inc. diff --git a/providers/builtin_dev.go b/providers/builtin_dev.go index 1829f46ae4..4deeebda87 100644 --- a/providers/builtin_dev.go +++ b/providers/builtin_dev.go @@ -26,4 +26,5 @@ func init() { // }, // Config: &osconf.Config, // } + }