Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "gateway-reporter", Short: "Report on Geneos Gateway XML files", Long: rootCmdDescription, SilenceUsage: true, CompletionOptions: cobra.CompletionOptions{ DisableDefaultCmd: true, }, Version: cordial.VERSION, DisableAutoGenTag: true, DisableSuggestions: true, DisableFlagsInUseLine: true, RunE: func(cmd *cobra.Command, args []string) (err error) { initLogging(execname, "/tmp/reporter.log") zerolog.SetGlobalLevel(zerolog.DebugLevel) log.Debug().Msg("logging") setupFile := os.Getenv("_SETUP") validateType := os.Getenv("_VALIDATE_TYPE") if setupFile == "" || (validateType != "Validate" && validateType != "Command") { return nil } in, err := os.Open(setupFile) if err != nil { fmt.Print(` <validation> <issues> <issue> <severity>Error</severity> <path>/gateway</path> <message>Cannot open setup file ` + setupFile + `</message> </issue> </issues> </validation> `) return err } defer in.Close() savedXML := new(bytes.Buffer) input := io.TeeReader(in, savedXML) gateway, entities, probes, err := processInputFile(input) if err != nil { fmt.Printf(` <validation> <issues> <issue> <severity>Error</severity> <path>/gateway</path> <message>Error reading setup: %s</message> </issue> </issues> </validation> `, err) return err } dir := cf.GetString("output.directory") _ = os.MkdirAll(dir, 0775) for format, filename := range cf.GetStringMap("output.formats") { if filename == "" { continue } switch format { case "json": if err = outputJSON(cf, gateway, entities, probes); err != nil { break } case "csv": if err = outputCSVZip(cf, gateway, entities, probes); err != nil { break } case "csvdir": if _, _, err = outputCSVDir(cf, gateway, entities, probes); err != nil { break } case "xlsx": if err = outputXLSX(cf, gateway, entities, probes); err != nil { break } case "xml": if err = outputXML(cf, gateway, savedXML); err != nil { break } default: } } if err != nil { fmt.Printf(` <validation> <issues> <issue> <severity>Error</severity> <path>/gateway</path> <message>Error encoding report results: %s</message> </issue> </issues> </validation> `, err) return err } fmt.Printf(` <validation> <issues> <issue> <severity>None</severity> <path>/gateway</path> <message>Report file(s) written to %q</message> </issue> </issues> </validation> `, cf.GetString("output.directory")) return nil }, }
RootCmd represents the base command when called without any subcommands
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.