Skip to content

Commit

Permalink
Merge pull request #421 from nerdalize/fix-cluster-list
Browse files Browse the repository at this point in the history
Show short name if cluster name is empty
  • Loading branch information
advanderveer committed Jun 13, 2018
2 parents 9cebcf6 + edf75d9 commit eeb1964
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 47 deletions.
3 changes: 3 additions & 0 deletions cmd/cluster_list.go
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion cmd/cluster_use.go
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions cmd/errors.go
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"context"
"fmt"
"strings"

"github.com/nerdalize/nerd/pkg/kubevisor"
transferstore "github.com/nerdalize/nerd/pkg/transfer/store"
Expand Down Expand Up @@ -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
}
Expand All @@ -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):
Expand Down
62 changes: 16 additions & 46 deletions spec.json
Expand Up @@ -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
},
{
Expand Down Expand Up @@ -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
},
{
Expand All @@ -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.",
Expand All @@ -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
},
{
Expand Down Expand Up @@ -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
},
{
Expand All @@ -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
},
{
Expand Down Expand Up @@ -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
},
{
Expand Down Expand Up @@ -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
},
{
Expand Down Expand Up @@ -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
},
{
Expand Down Expand Up @@ -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
},
{
Expand All @@ -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
},
{
Expand Down Expand Up @@ -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
},
{
Expand All @@ -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
},
{
Expand Down Expand Up @@ -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
},
{
Expand Down Expand Up @@ -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
},
{
Expand Down Expand Up @@ -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
},
{
Expand Down

0 comments on commit eeb1964

Please sign in to comment.