Skip to content

Commit a98838e

Browse files
loft-botmfranczy
andauthored
fix: vcluster version command (#3752) (#3755)
(cherry picked from commit ca14769) Signed-off-by: Marcin Franczyk <marcin0franczyk@gmail.com> Co-authored-by: Marcin Franczyk <marcin0franczyk@gmail.com>
1 parent b0ee24f commit a98838e

6 files changed

Lines changed: 25 additions & 9 deletions

File tree

cmd/vcluster/cmd/root.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/loft-sh/vcluster/cmd/vcluster/cmd/debug"
1111
"github.com/loft-sh/vcluster/cmd/vcluster/cmd/node"
1212
"github.com/loft-sh/vcluster/cmd/vcluster/cmd/snapshot"
13-
"github.com/loft-sh/vcluster/pkg/telemetry"
1413
"github.com/loft-sh/vcluster/pkg/util/osutil"
1514
"github.com/spf13/cobra"
1615
"k8s.io/klog/v2"
@@ -65,11 +64,9 @@ func RunRoot() {
6564
func BuildRoot() *cobra.Command {
6665
rootCmd := NewRootCmd()
6766

68-
// Set version for --version flag
69-
rootCmd.Version = telemetry.SyncerVersion
70-
7167
// add top level commands
7268
rootCmd.AddCommand(NewStartCommand())
69+
rootCmd.AddCommand(NewVersionCommand())
7370
rootCmd.AddCommand(snapshot.NewSnapshotCommand())
7471
rootCmd.AddCommand(snapshot.NewRestoreCommand())
7572
rootCmd.AddCommand(NewPortForwardCommand())

cmd/vcluster/cmd/snapshot/restore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var (
1515
func NewRestoreCommand() *cobra.Command {
1616
cmd := &cobra.Command{
1717
Use: "restore",
18-
Short: "restore a vCluster",
18+
Short: "Restore a vCluster",
1919
Args: cobra.NoArgs,
2020
RunE: func(cmd *cobra.Command, _ []string) error {
2121
envOptions, err := snapshot.ParseOptionsFromEnv()

cmd/vcluster/cmd/snapshot/snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func NewSnapshotCommand() *cobra.Command {
1111
cmd := &cobra.Command{
1212
Use: "snapshot",
13-
Short: "snapshot a vCluster",
13+
Short: "Manage vCluster snapshots",
1414
Args: cobra.NoArgs,
1515
RunE: func(cmd *cobra.Command, _ []string) error {
1616
client := &snapshot.Client{}

cmd/vcluster/cmd/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func NewStartCommand() *cobra.Command {
3636
startOptions := &StartOptions{}
3737
cmd := &cobra.Command{
3838
Use: "start",
39-
Short: "Execute the vcluster",
39+
Short: "Start a vCluster",
4040
Args: cobra.NoArgs,
4141
RunE: func(cobraCmd *cobra.Command, _ []string) (err error) {
4242
// execute command

cmd/vcluster/cmd/version.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/loft-sh/vcluster/pkg/telemetry"
7+
8+
"github.com/spf13/cobra"
9+
)
10+
11+
func NewVersionCommand() *cobra.Command {
12+
return &cobra.Command{
13+
Use: "version",
14+
Short: "Print the vCluster version",
15+
Args: cobra.NoArgs,
16+
Run: func(cmd *cobra.Command, args []string) {
17+
fmt.Fprintln(cmd.OutOrStdout(), telemetry.SyncerVersion)
18+
},
19+
}
20+
}

cmd/vclusterctl/cmd/version.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import (
66

77
var versionCmd = &cobra.Command{
88
Use: "version",
9-
Short: "Print the version number of vcluster",
10-
Long: `All software has versions. This is Vcluster's.`,
9+
Short: "Print the vCluster version",
1110
Run: func(cmd *cobra.Command, _ []string) {
1211
root := cmd.Root()
1312
root.SetArgs([]string{"--version"})

0 commit comments

Comments
 (0)