Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
fix: add timeout for handling version messages
Browse files Browse the repository at this point in the history
  • Loading branch information
myishay committed May 11, 2021
1 parent 7c0cf3a commit cb83fed
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions bl/versionMessage.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package bl

import (
"time"

"github.com/datreeio/datree/pkg/cliClient"
"github.com/datreeio/datree/pkg/deploymentConfig"
"github.com/datreeio/datree/pkg/printer"
Expand All @@ -20,9 +22,13 @@ func PopulateVersionMessageChan(cliVersion string) chan *cliClient.VersionMessag
}

func HandleVersionMessage(messageChannel chan *cliClient.VersionMessage) {
msg := <-messageChannel
if msg != nil {
p := printer.CreateNewPrinter()
p.PrintVersionMessage(msg.MessageText+"\n", msg.MessageColor)
select {
case msg := <-messageChannel:
if msg != nil {
p := printer.CreateNewPrinter()
p.PrintVersionMessage(msg.MessageText+"\n", msg.MessageColor)
}
case <-time.After(10 * time.Second):
break
}
}

0 comments on commit cb83fed

Please sign in to comment.