From 924f82a6f1b08d24c2b97196fd14a984e080d42e Mon Sep 17 00:00:00 2001 From: Emeline Gaulard Date: Wed, 13 Jun 2018 12:33:14 +0200 Subject: [PATCH 1/3] Show short name if cluster name is empty --- cmd/cluster_list.go | 3 +++ spec.json | 62 ++++++++++++--------------------------------- 2 files changed, 19 insertions(+), 46 deletions(-) diff --git a/cmd/cluster_list.go b/cmd/cluster_list.go index 84951e1b2..00e3c4130 100644 --- a/cmd/cluster_list.go +++ b/cmd/cluster_list.go @@ -72,6 +72,9 @@ func (cmd *ClusterList) Execute(args []string) (err error) { hdr := []string{"ID", "CLUSTER NAME", "VCPUS", "MEMORY", "PODS"} rows := [][]string{} for x, cluster := range clusters.Clusters { + if cluster.Name == "" { + cluster.Name = cluster.ShortName + } id := strconv.Itoa(x + 1) rows = append(rows, []string{ id, diff --git a/spec.json b/spec.json index ee039be79..163794f88 100644 --- a/spec.json +++ b/spec.json @@ -9,9 +9,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -53,9 +51,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -70,7 +66,7 @@ "Options": [] } }, - "cluster set-default": { + "cluster use": { "usage": "nerd cluster set-default NAME [OPTIONS]", "synopsis": "Set a specific cluster as the current one to use.", "description": "Set a specific cluster as the current one to use.", @@ -97,9 +93,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -131,9 +125,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -157,9 +149,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -191,9 +181,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -230,9 +218,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -296,9 +282,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -330,9 +314,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -356,9 +338,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -390,9 +370,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -416,9 +394,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -490,9 +466,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -590,9 +564,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { @@ -625,9 +597,7 @@ { "long_name": "kubeconfig", "description": "file at which Nerd will look for Kubernetes credentials", - "default_value": [ - "~/.kube/config" - ], + "default_value": null, "choices": null }, { From ad91d1c93e4b4067b93f15a27a62b44a46f9e588 Mon Sep 17 00:00:00 2001 From: Emeline Gaulard Date: Wed, 13 Jun 2018 16:25:22 +0200 Subject: [PATCH 2/3] return specific error for invalid refresh token --- cmd/errors.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/errors.go b/cmd/errors.go index 2c419cf64..9a49b21a3 100644 --- a/cmd/errors.go +++ b/cmd/errors.go @@ -3,6 +3,7 @@ package cmd import ( "context" "fmt" + "strings" "github.com/nerdalize/nerd/pkg/kubevisor" transferstore "github.com/nerdalize/nerd/pkg/transfer/store" @@ -30,6 +31,7 @@ type errShowUsage string func (e errShowUsage) Error() string { return string(e) } func renderServiceError(err error, format string, args ...interface{}) error { + if err == nil { return nil } @@ -40,6 +42,8 @@ func renderServiceError(err error, format string, args ...interface{}) error { } switch { + case strings.Contains(err.Error(), "failed to refresh token"): + return errors.Errorf("Please check your permissions or try to login again.") case kubevisor.IsInvalidNameErr(err): return errors.Errorf("%s: invalid name, must consist of alphanumeric characters, '-' or '.'", fmt.Errorf(format, args...)) case kubevisor.IsDeadlineErr(err): From edf75d910d63a67a3cb1ee1dc1fdd346ddf178d3 Mon Sep 17 00:00:00 2001 From: Emeline Gaulard Date: Wed, 13 Jun 2018 16:30:09 +0200 Subject: [PATCH 3/3] add nerdalizing message --- cmd/cluster_use.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/cluster_use.go b/cmd/cluster_use.go index 33e30c5fb..3ade2ab32 100644 --- a/cmd/cluster_use.go +++ b/cmd/cluster_use.go @@ -134,12 +134,13 @@ func (cmd *ClusterUse) Execute(args []string) (err error) { return err } if !ok { - cmd.out.Info("Cluster is not nerd compliant, installing dependencies...") + cmd.out.Info("Cluster is not nerd compliant, nerdalizing cluster...") // TODO move this to a new command err = kube.AddNerdDependencies(ctx, &svc.AddNerdDependenciesInput{Dependencies: nerdDependencies}) if err != nil { return err } + cmd.out.Info("Cluster is now nerdalized. It can take a few minutes before you can use it.") } } name := cluster.Name