cleaning up

mine
derailed 2020-01-24 22:13:52 -07:00
parent f74bd81dcb
commit 03f40b9c47
5 changed files with 10 additions and 6 deletions

View File

@ -287,11 +287,9 @@ func (c *Config) RESTConfig() (*restclient.Config, error) {
if c.restConfig, err = c.flags.ToRESTConfig(); err != nil {
return nil, err
}
log.Debug().Msgf("REST_CONFIG %#v", c.restConfig)
c.restConfig.QPS = defaultQPS
c.restConfig.Burst = defaultBurst
c.restConfig.Timeout = defaultTimeout
log.Debug().Msgf("Connecting to API Server %s", c.restConfig.Host)
return c.restConfig, nil

View File

@ -7,8 +7,12 @@ import (
"github.com/rs/zerolog/log"
)
// ClusterInfoListener registers a listener for model changes.
type ClusterInfoListener interface {
// ClusterInfoChanged notifies the cluster meta was changed.
ClusterInfoChanged(prev, curr ClusterMeta)
// ClusterInfoUpdated notifies the cluster meta was updated.
ClusterInfoUpdated(ClusterMeta)
}

View File

@ -47,6 +47,7 @@ func (s *StatusIndicator) StylesChanged(styles *config.Styles) {
const statusIndicatorFmt = "[orange::b]K9s [aqua::]%s [white::]%s:%s:%s [lawngreen::]%s%%[white::]::[darkturquoise::]%s%%"
// ClusterInfoUpdated notifies the cluster meta was updated.
func (s *StatusIndicator) ClusterInfoUpdated(data model.ClusterMeta) {
s.app.QueueUpdateDraw(func() {
s.SetPermanent(fmt.Sprintf(
@ -61,6 +62,7 @@ func (s *StatusIndicator) ClusterInfoUpdated(data model.ClusterMeta) {
})
}
// ClusterInfoChanged notifies the cluster meta was changed.
func (s *StatusIndicator) ClusterInfoChanged(prev, cur model.ClusterMeta) {
s.app.QueueUpdateDraw(func() {
s.SetPermanent(fmt.Sprintf(

View File

@ -195,8 +195,6 @@ func (a *App) clusterUpdater(ctx context.Context) {
func (a *App) refreshCluster() {
c := a.Content.Top()
// Check conns
if ok := a.Conn().CheckConnectivity(); ok {
if a.conRetry > 0 {
if c != nil {
@ -207,14 +205,14 @@ func (a *App) refreshCluster() {
a.conRetry = 0
} else {
a.conRetry++
log.Warn().Msgf("Conn check failed (%d)", a.conRetry)
log.Warn().Msgf("Conn check failed (%d/%d)", a.conRetry, maxConRetry)
if c != nil {
c.Stop()
}
a.Status(ui.FlashWarn, fmt.Sprintf("Dial K8s failed (%d)", a.conRetry))
}
if a.conRetry > maxConRetry {
if a.conRetry >= maxConRetry {
ExitStatus = fmt.Sprintf("Lost K8s connection (%d). Bailing out!", a.conRetry)
a.BailOut()
}

View File

@ -67,6 +67,7 @@ func (c *ClusterInfo) infoCell(t string) *tview.TableCell {
return cell
}
// ClusterInfoChanged notifies the cluster meta was updated.
func (c *ClusterInfo) ClusterInfoUpdated(data model.ClusterMeta) {
c.app.QueueUpdateDraw(func() {
var row int
@ -88,6 +89,7 @@ func (c *ClusterInfo) ClusterInfoUpdated(data model.ClusterMeta) {
})
}
// ClusterInfoChanged notifies the cluster meta was changed.
func (c *ClusterInfo) ClusterInfoChanged(prev, curr model.ClusterMeta) {
c.app.QueueUpdateDraw(func() {
var row int