Skip to content

Commit

Permalink
feat: added menu driven logger for ksctl creds
Browse files Browse the repository at this point in the history
Signed-off-by: Dipankar Das <[email protected]>
  • Loading branch information
dipankardas011 committed Aug 1, 2024
1 parent 3d509d5 commit 074083a
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 13 deletions.
25 changes: 13 additions & 12 deletions cli/cmd/credentials.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package cmd

import (
"fmt"
"os"

"github.com/ksctl/cli/logger"
"github.com/ksctl/ksctl/pkg/controllers"
"github.com/ksctl/ksctl/pkg/types"
"github.com/pterm/pterm"

"github.com/ksctl/ksctl/pkg/helpers/consts"
"github.com/spf13/cobra"
Expand All @@ -25,19 +25,20 @@ var credCmd = &cobra.Command{
}
cli.Client.Metadata.StateLocation = consts.KsctlStore(storage)

log.Print(ctx, `
1> AWS (EKS)
2> Azure (AKS)
3> Civo (K3s)
`)
cloudMap := map[string]int{
"Amazon Web Services": 1,
"Azure": 2,
"Civo": 3,
}
var options []string
for k := range cloudMap {
options = append(options, k)
}
log.Print(ctx, "Select the cloud provider")

choice := 0
selectedOption, _ := pterm.DefaultInteractiveSelect.WithOptions(options).Show()

_, err := fmt.Scanf("%d", &choice)
if err != nil {
panic(err.Error())
}
if provider, ok := cloud[choice]; ok {
if provider, ok := cloud[cloudMap[selectedOption]]; ok {
cli.Client.Metadata.Provider = consts.KsctlCloud(provider)
} else {
log.Error("invalid provider")
Expand Down
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ require (
github.com/Delta456/box-cli-maker/v2 v2.3.0
github.com/fatih/color v1.17.0
github.com/ksctl/ksctl v1.2.5
github.com/pterm/pterm v0.12.79
github.com/rodaine/table v1.2.0
github.com/spf13/cobra v1.8.1
)

require (
atomicgo.dev/cursor v0.2.0 // indirect
atomicgo.dev/keyboard v0.2.9 // indirect
atomicgo.dev/schedule v0.1.0 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.6.0 // indirect
Expand Down Expand Up @@ -53,6 +57,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/civo/civogo v0.3.69 // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/containerd/containerd v1.7.12 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
Expand Down Expand Up @@ -110,6 +115,7 @@ require (
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/lithammer/fuzzysearch v1.1.8 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand Down Expand Up @@ -138,7 +144,7 @@ require (
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rubenv/sql-migrate v1.5.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
Expand Down
Loading

0 comments on commit 074083a

Please sign in to comment.