Skip to content

Commit

Permalink
Show spinner on restart (#64)
Browse files Browse the repository at this point in the history
* Show spinner on restart

* Updated CHANGELOG.md
  • Loading branch information
applejag authored Nov 11, 2023
1 parent 2bf2f93 commit a08e806
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ This project tries to follow [SemVer 2.0.0](https://semver.org/).
The fix is just adding a small 150ms sleep, which is hopefully enough time
for tools like `kubectx` to finish writing the kubeconfig file. (#63)

- Added spinner when the watch restarts (either from `--watch-kubeconfig` or
from an error), to indicate that it's loading. (#64)

- Changed to Go 1.21.4 to resolve vulnerability [GO-2023-2186](https://pkg.go.dev/vuln/GO-2023-2186),
where `filepath.IsLocal` incorrectly treated reserved names as local. (#66)

Expand Down
8 changes: 8 additions & 0 deletions pkg/klock/klock.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,17 @@ func (w *Watcher) WatchLoop(ctx context.Context, restartChan <-chan struct{}) er
clearBeforePrinting = true
select {
case err := <-watchErrChan:
if cmd := w.Printer.Table.StartSpinner(); cmd != nil {
w.Program.Send(cmd())
}
w.errorChan <- fmt.Errorf("restart in 5s: %w", err)
time.Sleep(5 * time.Second)
w.Printer.Table.StopSpinner()
w.Printer.Table.SetError(nil)
case <-restartChan:
if cmd := w.Printer.Table.StartSpinner(); cmd != nil {
w.Program.Send(cmd())
}
// Prevent it from restarting too eagerly when we're told to restart
// so the filesystem has time to flush, such as in case of
// "kubectx" on bigger kubeconfigs.
Expand Down

0 comments on commit a08e806

Please sign in to comment.