From dc6150dd4907902f8f8699aafce97cdee5643d38 Mon Sep 17 00:00:00 2001 From: alitari Date: Mon, 3 Sep 2018 18:47:09 +0200 Subject: [PATCH] fix: continue to connect after a failure --- backend.go | 4 +++- config.go | 30 +++++++++++++++++------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/backend.go b/backend.go index cb34e21..bd7769a 100644 --- a/backend.go +++ b/backend.go @@ -156,7 +156,9 @@ func newBackend(context contextType) *backendType { } response, err := client.Do(req) - tracelog.Printf("rest call: %s %s , response status: %s", httpMethod, url, response.Status) + if err == nil { + tracelog.Printf("rest call: %s %s , response status: %s", httpMethod, url, response.Status) + } return response, err }, diff --git a/config.go b/config.go index 8b63210..f97c8a3 100644 --- a/config.go +++ b/config.go @@ -829,6 +829,7 @@ func (c *configType) createContexts() *configType { mess := fmt.Sprintf("try connecting context '%s', cluster: '%s' ...", ct.Name, cluster.Name) fmt.Println(mess) infolog.Print(mess) + var skip = false if ct.user.token == "" { fmt.Print("retrieving token from secret ...") infolog.Print("retrieving token from secret ...") @@ -837,23 +838,26 @@ func (c *configType) createContexts() *configType { mess := fmt.Sprintf("Skipping context %s, due to error: %s", ct.Name, err.Error()) fmt.Println(mess) warninglog.Print(mess) - break + skip = true } } - err = c.isAvailable(ct) - if err != nil { - mess := fmt.Sprintf("Skipping context %s, due to error: %s", ct.Name, err.Error()) + if !skip { + err = c.isAvailable(ct) + if err != nil { + mess := fmt.Sprintf("Skipping context %s, due to error: %s", ct.Name, err.Error()) + fmt.Println(mess) + warninglog.Print(mess) + skip = true + } + } + if !skip { + colorIndex := len(cs) % 4 + ct.color = contextColors[colorIndex] + cs = append(cs, ct) + mess = fmt.Sprintf("created context no %d with name '%s' ", i+1, ct.Name) fmt.Println(mess) - warninglog.Print(mess) - break + infolog.Print(mess) } - - colorIndex := len(cs) % 4 - ct.color = contextColors[colorIndex] - cs = append(cs, ct) - mess = fmt.Sprintf("created context no %d with name '%s' ", i+1, ct.Name) - fmt.Println(mess) - infolog.Print(mess) } if len(cs) == 0 { fatalStderrlog.Fatalf("No contexts created for configfile '%s'. See logfile '%s' for details.", c.configFile, *logFilePath)