add panic info + fix color

mine
derailed 2019-05-29 17:59:37 -06:00
parent a5245a98de
commit 3c038026ce
2 changed files with 7 additions and 3 deletions

View File

@ -67,7 +67,7 @@ func run(cmd *cobra.Command, args []string) {
log.Error().Msg(string(debug.Stack()))
printLogo(printer.ColorRed)
fmt.Printf(printer.Colorize("Boom!! ", printer.ColorRed))
fmt.Println(printer.Colorize(fmt.Sprintf("%v.", err), printer.ColorDarkGray))
fmt.Println(printer.Colorize(fmt.Sprintf("%v.", err), printer.ColorWhite))
}
}()
@ -94,6 +94,10 @@ func loadConfiguration() *config.Config {
k9sCfg.Refine(k8sFlags)
k9sCfg.SetConnection(k8s.InitConnectionOrDie(k8sCfg, log.Logger))
// Try to access server version if that fail. Connectivity issue?
if _, err := k9sCfg.GetConnection().ServerVersion(); err != nil {
log.Panic().Err(err).Msg("K9s can't connect to cluster")
}
log.Info().Msg("✅ Kubernetes connectivity")
k9sCfg.Save()

View File

@ -66,13 +66,13 @@ func NewInformer(client k8s.Connection, ns string) *Informer {
ns, err := client.Config().CurrentNamespaceName()
// User did not lock NS. Check all ns access if not bail
if err != nil && !nsAccess {
log.Panic().Msg("Unauthorized access to list namespaces. Please specify a namespace")
log.Panic().Msg("Unauthorized: Unable to list ALL namespaces. Missing verbs ['list', 'watch']. Please specify a namespace or correct RBAC")
}
// Namespace is locked in. check if user has auth for this ns access.
if ns != AllNamespaces && !nsAccess {
if !i.client.CanIAccess("", ns, "namespaces", []string{"get", "watch"}) {
log.Panic().Msgf("Unauthorized access to namespace %q", ns)
log.Panic().Msgf("Unauthorized: Access to namespace %q is missing verbs ['get', 'watch']", ns)
}
i.init(ns)
} else {