From 03f40b9c47826e6f7a4a38f97b5783be58c1756a Mon Sep 17 00:00:00 2001 From: derailed Date: Fri, 24 Jan 2020 22:13:52 -0700 Subject: [PATCH] cleaning up --- internal/client/config.go | 2 -- internal/model/cluster_info.go | 4 ++++ internal/ui/indicator.go | 2 ++ internal/view/app.go | 6 ++---- internal/view/cluster_info.go | 2 ++ 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/client/config.go b/internal/client/config.go index 2f2e406d..1ba0f5f8 100644 --- a/internal/client/config.go +++ b/internal/client/config.go @@ -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 diff --git a/internal/model/cluster_info.go b/internal/model/cluster_info.go index cfc14e10..b0e19e1d 100644 --- a/internal/model/cluster_info.go +++ b/internal/model/cluster_info.go @@ -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) } diff --git a/internal/ui/indicator.go b/internal/ui/indicator.go index d54bcb88..012259f0 100644 --- a/internal/ui/indicator.go +++ b/internal/ui/indicator.go @@ -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( diff --git a/internal/view/app.go b/internal/view/app.go index aeee999b..d7fc1f9f 100644 --- a/internal/view/app.go +++ b/internal/view/app.go @@ -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() } diff --git a/internal/view/cluster_info.go b/internal/view/cluster_info.go index 7999b4d1..81b4253f 100644 --- a/internal/view/cluster_info.go +++ b/internal/view/cluster_info.go @@ -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