Skip to content

Commit

Permalink
change for cloudlens version command
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaysomani07 committed Feb 22, 2023
1 parent 3e91f8c commit a3b691e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var rootCmd = &cobra.Command{
}

var (
profile, region string
profile, region, version string
)

func init() {
Expand Down Expand Up @@ -70,7 +70,7 @@ func run(cmd *cobra.Command, args []string) {
app := view.NewApp()

// TODO pass the AWS session instead of profiles and regions
if err := app.Init(ctx, profiles, regions); err != nil {
if err := app.Init(ctx, profiles, regions, version); err != nil {
panic(fmt.Sprintf("app init failed -- %v", err))
}
if err := app.Run(); err != nil {
Expand Down
28 changes: 28 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

//var short bool

var command = &cobra.Command{
Use: "version",
Short: "Print version/build info",
Long: "Print version/build information",
Run: func(cmd *cobra.Command, args []string) {
printVersion("version")
},
}

//command.PersistentFlags().BoolVarP(&short, "short", "s", false, "Prints K9s version info in short format")

func init() {
rootCmd.AddCommand(command)
}

func printVersion(fmat string) {
fmt.Println("v0.0.8")
}
4 changes: 3 additions & 1 deletion internal/view/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type App struct {
cancelFn context.CancelFunc
showHeader bool
IsPageContentSorted bool
version string
}

func NewApp() *App {
Expand All @@ -42,7 +43,8 @@ func NewApp() *App {
}

// TODO keep context param at first place always
func (a *App) Init(ctx context.Context,profiles, regions []string) error {
func (a *App) Init(ctx context.Context, profiles, regions []string, version string) error {
a.version = version
ctx = context.WithValue(ctx, internal.KeyActiveProfile, profiles[0])
ctx = context.WithValue(ctx, internal.KeyActiveRegion, regions[0])
ctx = context.WithValue(ctx, internal.KeyApp, a)
Expand Down

0 comments on commit a3b691e

Please sign in to comment.