Skip to content

Commit

Permalink
switch version now also outputs the supported backing stores
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfoehrKn committed Apr 18, 2024
1 parent 4a3882a commit b508a3a
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions cmd/switcher/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ package switcher
import (
"fmt"
"runtime"
"slices"

"github.com/danielfoehrkn/kubeswitch/types"

"github.com/spf13/cobra"
)
Expand All @@ -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)
}

0 comments on commit b508a3a

Please sign in to comment.