github.com/letsencrypt/boulder@v0.20251208.0/cmd/log-validator/main.go (about) 1 package notmain 2 3 import ( 4 "context" 5 "flag" 6 7 "github.com/letsencrypt/boulder/cmd" 8 "github.com/letsencrypt/boulder/log/validator" 9 ) 10 11 type Config struct { 12 Files []string `validate:"min=1,dive,required"` 13 DebugAddr string `validate:"omitempty,hostname_port"` 14 Syslog cmd.SyslogConfig 15 OpenTelemetry cmd.OpenTelemetryConfig 16 } 17 18 func main() { 19 debugAddr := flag.String("debug-addr", "", "Debug server address override") 20 configFile := flag.String("config", "", "File path to the configuration file for this service") 21 checkFile := flag.String("check-file", "", "File path to a file to directly validate, if this argument is provided the config will not be parsed and only this file will be inspected") 22 flag.Parse() 23 24 if *checkFile != "" { 25 err := validator.ValidateFile(*checkFile) 26 cmd.FailOnError(err, "validation failed") 27 return 28 } 29 30 var config Config 31 err := cmd.ReadConfigFile(*configFile, &config) 32 cmd.FailOnError(err, "Reading JSON config file into config structure") 33 34 if *debugAddr != "" { 35 config.DebugAddr = *debugAddr 36 } 37 38 stats, logger, oTelShutdown := cmd.StatsAndLogging(config.Syslog, config.OpenTelemetry, config.DebugAddr) 39 defer oTelShutdown(context.Background()) 40 logger.Info(cmd.VersionString()) 41 42 v := validator.New(config.Files, logger, stats) 43 defer v.Shutdown() 44 45 cmd.WaitForSignal() 46 } 47 48 func init() { 49 cmd.RegisterCommand("log-validator", main, &cmd.ConfigValidator{Config: &Config{}}) 50 }