crowdsec/cmd/crowdsec-cli/console_table.go

50 lines
1.2 KiB
Go
Raw Permalink Normal View History

package main
import (
"io"
"github.com/aquasecurity/table"
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
"github.com/crowdsecurity/crowdsec/pkg/emoji"
)
2024-02-12 10:45:58 +00:00
func cmdConsoleStatusTable(out io.Writer, consoleCfg csconfig.ConsoleConfig) {
t := newTable(out)
t.SetRowLines(false)
t.SetHeaders("Option Name", "Activated", "Description")
t.SetHeaderAlignment(table.AlignLeft, table.AlignLeft, table.AlignLeft)
for _, option := range csconfig.CONSOLE_CONFIGS {
activated := emoji.CrossMark
2024-02-12 10:45:58 +00:00
switch option {
case csconfig.SEND_CUSTOM_SCENARIOS:
2024-02-12 10:45:58 +00:00
if *consoleCfg.ShareCustomScenarios {
activated = emoji.CheckMarkButton
}
case csconfig.SEND_MANUAL_SCENARIOS:
2024-02-12 10:45:58 +00:00
if *consoleCfg.ShareManualDecisions {
activated = emoji.CheckMarkButton
}
case csconfig.SEND_TAINTED_SCENARIOS:
2024-02-12 10:45:58 +00:00
if *consoleCfg.ShareTaintedScenarios {
activated = emoji.CheckMarkButton
}
case csconfig.SEND_CONTEXT:
2024-02-12 10:45:58 +00:00
if *consoleCfg.ShareContext {
activated = emoji.CheckMarkButton
}
case csconfig.CONSOLE_MANAGEMENT:
2024-02-12 10:45:58 +00:00
if *consoleCfg.ConsoleManagement {
activated = emoji.CheckMarkButton
}
}
2024-02-12 10:45:58 +00:00
t.AddRow(option, activated, csconfig.CONSOLE_CONFIGS_HELP[option])
}
t.Render()
}