This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from datreeio/DAT-3196-print-version-message
feat: print version message
- Loading branch information
Showing
10 changed files
with
204 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
run: | ||
go run -tags staging main.go test "./internal/fixtures/**/*.yaml" | ||
go run -tags staging -ldflags="-X github.com/datreeio/datree/cmd.CliVersion=0.0.1" main.go test ./internal/fixtures/**/*.yaml | ||
|
||
test: | ||
go test ./... | ||
|
||
create-bin: | ||
goreleaser --snapshot --skip-publish --rm-dist | ||
|
||
print-version: | ||
go run -tags=staging -ldflags="-X github.com/datreeio/datree/cmd.CliVersion=0.0.1" main.go version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package bl | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/datreeio/datree/pkg/cliClient" | ||
"github.com/datreeio/datree/pkg/deploymentConfig" | ||
"github.com/datreeio/datree/pkg/printer" | ||
) | ||
|
||
func PopulateVersionMessageChan(cliVersion string) chan *cliClient.VersionMessage { | ||
messageChannel := make(chan *cliClient.VersionMessage, 1) | ||
go func() { | ||
c := cliClient.NewCliClient(deploymentConfig.URL) | ||
msg, _ := c.GetVersionMessage(cliVersion) | ||
if msg != nil { | ||
messageChannel <- msg | ||
} | ||
close(messageChannel) | ||
}() | ||
return messageChannel | ||
} | ||
|
||
func HandleVersionMessage(messageChannel chan *cliClient.VersionMessage) { | ||
select { | ||
case msg := <-messageChannel: | ||
if msg != nil { | ||
p := printer.CreateNewPrinter() | ||
p.PrintVersionMessage(msg.MessageText+"\n", msg.MessageColor) | ||
} | ||
case <-time.After(600 * time.Millisecond): | ||
break | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
package main | ||
|
||
import "github.com/datreeio/datree/cmd" | ||
import ( | ||
"os" | ||
|
||
"github.com/datreeio/datree/cmd" | ||
) | ||
|
||
func main() { | ||
cmd.Execute() | ||
if err := cmd.Execute(); err != nil { | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters