From b508a3a794ee0e088ee36c259dcd697de3e4dbb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20F=C3=B6hr?= <33809186+danielfoehrKn@users.noreply.github.com> Date: Thu, 18 Apr 2024 16:28:06 -0400 Subject: [PATCH] switch version now also outputs the supported backing stores --- cmd/switcher/version.go | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/cmd/switcher/version.go b/cmd/switcher/version.go index 42735d82..cd652e07 100644 --- a/cmd/switcher/version.go +++ b/cmd/switcher/version.go @@ -16,6 +16,9 @@ package switcher import ( "fmt" "runtime" + "slices" + + "github.com/danielfoehrkn/kubeswitch/types" "github.com/spf13/cobra" ) @@ -28,18 +31,30 @@ var ( Example: "switch version", RunE: func(cmd *cobra.Command, args []string) error { fmt.Printf(`Switch: - version : %s - build date : %s - go version : %s - go compiler : %s - platform : %s/%s -`, version, buildDate, runtime.Version(), runtime.Compiler, runtime.GOOS, runtime.GOARCH) + version : %s + build date : %s + go version : %s + go compiler : %s + platform : %s/%s + backing-stores: %s +`, version, buildDate, runtime.Version(), runtime.Compiler, runtime.GOOS, runtime.GOARCH, getSupportedStores()) return nil }, } ) +// getSupportedStores returns a string of supported backing stores +func getSupportedStores() string { + validStoreKinds := types.ValidStoreKinds.List() + slices.Sort(validStoreKinds) + validStoreKindsString := "[" + for _, kind := range validStoreKinds { + validStoreKindsString = fmt.Sprintf("%s %s", validStoreKindsString, kind) + } + return fmt.Sprintf("%s ]", validStoreKindsString) +} + func init() { rootCommand.AddCommand(versionCmd) }