diff --git a/cmd/version.go b/cmd/version.go index 2ab41147..cc31bae3 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -9,8 +9,10 @@ import ( "github.com/gin-gonic/gin" "github.com/spf13/cobra" + "golang.org/x/exp/slices" "akvorado/common/reporter" + "akvorado/common/schema" ) var ( @@ -28,10 +30,32 @@ var versionCmd = &cobra.Command{ Use: "version", Short: "Print version", Long: `Display version and build information about akvorado.`, - Run: func(cmd *cobra.Command, args []string) { + RunE: func(cmd *cobra.Command, args []string) error { cmd.Printf("akvorado %s\n", Version) cmd.Printf(" Build date: %s\n", BuildDate) cmd.Printf(" Built with: %s\n", runtime.Version()) + cmd.Println() + + sch, err := schema.New(schema.DefaultConfiguration()) + if err != nil { + return err + } + cmd.Println("Can be disabled:") + for k := schema.ColumnTimeReceived; k < schema.ColumnLast; k++ { + column, ok := sch.LookupColumnByKey(k) + if ok && !column.Disabled && !column.NoDisable && !slices.Contains(sch.ClickHousePrimaryKeys(), column.Name) { + cmd.Printf("- %s\n", column.Name) + } + } + cmd.Println() + cmd.Println("Can be enabled:") + for k := schema.ColumnTimeReceived; k < schema.ColumnLast; k++ { + column, ok := sch.LookupColumnByKey(k) + if ok && column.Disabled { + cmd.Printf("- %s\n", column.Name) + } + } + return nil }, } diff --git a/cmd/version_test.go b/cmd/version_test.go index b13078c8..7a59457c 100644 --- a/cmd/version_test.go +++ b/cmd/version_test.go @@ -29,7 +29,7 @@ func TestVersion(t *testing.T) { fmt.Sprintf(" Built with: %s", runtime.Version()), "", } - got := strings.Split(buf.String(), "\n") + got := strings.Split(buf.String(), "\n")[:len(want)] if diff := helpers.Diff(got, want); diff != "" { t.Errorf("`version` (-got, +want):\n%s", diff) } diff --git a/console/data/docs/02-configuration.md b/console/data/docs/02-configuration.md index 544558a3..0179dd8b 100644 --- a/console/data/docs/02-configuration.md +++ b/console/data/docs/02-configuration.md @@ -360,6 +360,9 @@ schema: - DstVlan ``` +You can get the list of columns you can enable or disable with `akvorado +version`. + ### HTTP The builtin HTTP server serves various pages. Its configuration