From 7810477b7ece0e1609625d53bf56eabaaa9df145 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Fri, 26 Jun 2020 10:53:41 -0700 Subject: [PATCH] cmd/aws-k8s-tester: print out node group bodies Signed-off-by: Gyuho Lee --- CHANGELOG/CHANGELOG-1.4.md | 1 + cmd/aws-k8s-tester/eks/create-cluster.go | 19 ++++++++++++++++--- cmd/aws-k8s-tester/eks/create-config.go | 19 ++++++++++++++++--- cmd/aws-k8s-tester/eks/delete.go | 19 ++++++++++++++++--- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/CHANGELOG/CHANGELOG-1.4.md b/CHANGELOG/CHANGELOG-1.4.md index 689344483..66736fa81 100644 --- a/CHANGELOG/CHANGELOG-1.4.md +++ b/CHANGELOG/CHANGELOG-1.4.md @@ -19,6 +19,7 @@ See [code changes](https://github.com/aws/aws-k8s-tester/compare/v1.3.9...v1.4.0 - [`aws-k8s-tester --auto-path` now automatically uses the generated cluster name for local file paths, instead of random string](https://github.com/aws/aws-k8s-tester/commit/53b51d38b1aa4e6ea1454cc631c9511dcbe4267a). - Remove [`--block` flags](https://github.com/aws/aws-k8s-tester/commit/cdf83863700a4fb52a38484b56fedeb7c6b1eb78). +- Print [JSON body for (managed) node groups](https://github.com/aws/aws-k8s-tester/commit/). ### `ec2` diff --git a/cmd/aws-k8s-tester/eks/create-cluster.go b/cmd/aws-k8s-tester/eks/create-cluster.go index 202c4f674..98725c048 100644 --- a/cmd/aws-k8s-tester/eks/create-cluster.go +++ b/cmd/aws-k8s-tester/eks/create-cluster.go @@ -1,6 +1,7 @@ package eks import ( + "encoding/json" "fmt" "io/ioutil" "os" @@ -70,9 +71,21 @@ func createClusterFunc(cmd *cobra.Command, args []string) { fmt.Fprintf(os.Stderr, "failed to read configuration %q (%v)\n", path, err) os.Exit(1) } - println() - fmt.Println(string(txt)) - println() + fmt.Printf("\n\n%q:\n\n%s\n\n\n", path, string(txt)) + if cfg.IsEnabledAddOnNodeGroups() { + body, err := json.MarshalIndent(cfg.AddOnNodeGroups, "", " ") + if err != nil { + panic(err) + } + fmt.Printf("AddOnNodeGroups:\n\n%s\n\n\n", string(body)) + } + if cfg.IsEnabledAddOnManagedNodeGroups() { + body, err := json.MarshalIndent(cfg.AddOnManagedNodeGroups, "", " ") + if err != nil { + panic(err) + } + fmt.Printf("AddOnManagedNodeGroups:\n\n%s\n\n\n", string(body)) + } if enablePrompt { prompt := promptui.Select{ diff --git a/cmd/aws-k8s-tester/eks/create-config.go b/cmd/aws-k8s-tester/eks/create-config.go index 1c28b580d..2e8ab5984 100644 --- a/cmd/aws-k8s-tester/eks/create-config.go +++ b/cmd/aws-k8s-tester/eks/create-config.go @@ -1,6 +1,7 @@ package eks import ( + "encoding/json" "fmt" "io/ioutil" "os" @@ -51,9 +52,21 @@ func createConfigFunc(cmd *cobra.Command, args []string) { fmt.Fprintf(os.Stderr, "failed to read configuration %q (%v)\n", path, err) os.Exit(1) } - println() - fmt.Println(string(txt)) - println() + fmt.Printf("\n\n%q:\n\n%s\n\n\n", path, string(txt)) + if cfg.IsEnabledAddOnNodeGroups() { + body, err := json.MarshalIndent(cfg.AddOnNodeGroups, "", " ") + if err != nil { + panic(err) + } + fmt.Printf("AddOnNodeGroups:\n\n%s\n\n\n", string(body)) + } + if cfg.IsEnabledAddOnManagedNodeGroups() { + body, err := json.MarshalIndent(cfg.AddOnManagedNodeGroups, "", " ") + if err != nil { + panic(err) + } + fmt.Printf("AddOnManagedNodeGroups:\n\n%s\n\n\n", string(body)) + } fmt.Printf("\n*********************************\n") fmt.Printf("'aws-k8s-tester eks create config --path %q' success\n", path) diff --git a/cmd/aws-k8s-tester/eks/delete.go b/cmd/aws-k8s-tester/eks/delete.go index c4a621637..e6e3e0e4a 100644 --- a/cmd/aws-k8s-tester/eks/delete.go +++ b/cmd/aws-k8s-tester/eks/delete.go @@ -1,6 +1,7 @@ package eks import ( + "encoding/json" "fmt" "io/ioutil" "os" @@ -47,9 +48,21 @@ func deleteClusterFunc(cmd *cobra.Command, args []string) { fmt.Fprintf(os.Stderr, "failed to read configuration %q (%v)\n", path, err) os.Exit(1) } - println() - fmt.Println(string(txt)) - println() + fmt.Printf("\n\n%q:\n\n%s\n\n\n", path, string(txt)) + if cfg.IsEnabledAddOnNodeGroups() { + body, err := json.MarshalIndent(cfg.AddOnNodeGroups, "", " ") + if err != nil { + panic(err) + } + fmt.Printf("AddOnNodeGroups:\n\n%s\n\n\n", string(body)) + } + if cfg.IsEnabledAddOnManagedNodeGroups() { + body, err := json.MarshalIndent(cfg.AddOnManagedNodeGroups, "", " ") + if err != nil { + panic(err) + } + fmt.Printf("AddOnManagedNodeGroups:\n\n%s\n\n\n", string(body)) + } if enablePrompt { prompt := promptui.Select{