update output

This commit is contained in:
alteredCoder 2021-10-07 15:40:14 +02:00
parent 0c32f2574b
commit 553e833d75
2 changed files with 23 additions and 5 deletions

View file

@ -2,6 +2,7 @@ package main
import (
"context"
"encoding/json"
"fmt"
"net/url"
@ -13,6 +14,7 @@ import (
"github.com/go-openapi/strfmt"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)
func NewConsoleCmd() *cobra.Command {
@ -153,10 +155,26 @@ Disable given information push to the central API.`,
Example: "status alerts-tainted",
DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("share decisions\t%t\n", *csConfig.API.Server.ConsoleConfig.ShareDecisions)
fmt.Printf("share tainted scenarios alerts\t%t\n", *csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios)
fmt.Printf("share custom scenarios alerts\t%t\n", *csConfig.API.Server.ConsoleConfig.ShareCustomScenarios)
fmt.Printf("share manual decisions\t%t\n", *csConfig.API.Server.ConsoleConfig.ShareManualDecisions)
switch csConfig.Cscli.Output {
case "human":
fmt.Printf("Sharing options enabled:\n")
fmt.Printf(" - Share Decisions : %t\n", *csConfig.API.Server.ConsoleConfig.ShareDecisions)
fmt.Printf(" - Share tainted scenarios alerts : %t\n", *csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios)
fmt.Printf(" - Share custom scenarios alerts : %t\n", *csConfig.API.Server.ConsoleConfig.ShareCustomScenarios)
fmt.Printf(" - Share manual decisions alerts : %t\n", *csConfig.API.Server.ConsoleConfig.ShareManualDecisions)
case "json":
data, err := json.MarshalIndent(csConfig.API.Server.ConsoleConfig, "", " ")
if err != nil {
log.Fatalf("failed to marshal configuration: %s", err)
}
fmt.Printf("%s\n", string(data))
case "raw":
data, err := yaml.Marshal(csConfig.API.Server.ConsoleConfig)
if err != nil {
log.Fatalf("failed to marshal configuration: %s", err)
}
fmt.Printf("%s\n", string(data))
}
},
}

View file

@ -64,7 +64,7 @@ func (c *LocalApiServerCfg) LoadConsoleConfig() error {
log.Debugf("no share_decisions scenarios found, setting to false")
c.ConsoleConfig.ShareDecisions = new(bool)
}
log.Infof("Console configuration '%s' loaded successfully", c.ConsoleConfigPath)
log.Debugf("Console configuration '%s' loaded successfully", c.ConsoleConfigPath)
return nil
}