Skip to content

Commit

Permalink
Fix tks for cluster
Browse files Browse the repository at this point in the history
- Add global flag for verbose feature
- Remove unneeded slice
  • Loading branch information
Jaesang committed Mar 15, 2022
1 parent 2a9ee7d commit 801da72
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
28 changes: 16 additions & 12 deletions cmd/cluster_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ tks cluster delete <CLUSTER_ID>`,
fmt.Println("Usage: tks cluster delete <CLUSTER_ID>")
os.Exit(1)
}

var conn *grpc.ClientConn
conn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil {
Expand All @@ -51,24 +52,27 @@ tks cluster delete <CLUSTER_ID>`,
defer conn.Close()

client := pb.NewClusterLcmServiceClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Minute)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()
data := make([]pb.IDRequest, 1)
data[0].Id = args[0]
data := pb.IDRequest{}
data.Id = args[0]
m := protojson.MarshalOptions{
Indent: " ",
UseProtoNames: true,
}
jsonBytes, _ := m.Marshal(&data[0])
fmt.Println("Proto Json data...")
fmt.Println(string(jsonBytes))
r, err := client.DeleteCluster(ctx, &data[0])
jsonBytes, _ := m.Marshal(&data)
verbose, err := rootCmd.PersistentFlags().GetBool("verbose")
if verbose {
fmt.Println("Proto Json data...")
fmt.Println(string(jsonBytes))
}
r, err := client.DeleteCluster(ctx, &data)
fmt.Println(r)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("The request to delete cluster ", args[0], " was accepted.")
}
if err != nil {
fmt.Println(err)
} else {
fmt.Println("The request to delete cluster ", args[0], " was accepted.")
}
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func init() {
// will be global for your application.

rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.tks-client.yaml)")

rootCmd.PersistentFlags().BoolP("verbose", "v", false, "verbose output")
// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/openinfradev/tks-proto v0.0.6-0.20220304011855-99ac351f420f
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.9.0
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.7.0 // indirect
golang.org/x/net v0.0.0-20211020060615-d418f374d309 // indirect
golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 // indirect
google.golang.org/genproto v0.0.0-20211021150943-2b146023228c // indirect
Expand Down

0 comments on commit 801da72

Please sign in to comment.