add panic info + fix color
parent
a5245a98de
commit
3c038026ce
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue