File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed
Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change 1616package cmd
1717
1818import (
19+ "context"
1920 "crypto/sha256"
2021 "fmt"
2122 "hash"
2223 "io"
2324 "os"
2425
26+ pb "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1"
2527 "github.com/spf13/cobra"
2628)
2729
@@ -38,8 +40,30 @@ func NewVersionCmd() *cobra.Command {
3840 return & cobra.Command {
3941 Use : "version" ,
4042 Short : "Command line version" ,
41- Run : func (cmd * cobra.Command , args []string ) {
42- fmt .Printf ("%s version %s\n " , appName , Version )
43+ RunE : func (_ * cobra.Command , _ []string ) error {
44+ var version = struct {
45+ Client string `json:"client"`
46+ Server string `json:"server"`
47+ }{
48+ Client : Version ,
49+ Server : "unknown" ,
50+ }
51+
52+ if actionOpts .CPConnection != nil {
53+ res , err := pb .NewStatusServiceClient (actionOpts .CPConnection ).Infoz (context .Background (), & pb.InfozRequest {})
54+ if err == nil {
55+ version .Server = res .Version
56+ }
57+ }
58+
59+ if flagOutputFormat == formatJSON {
60+ return encodeJSON (version )
61+ }
62+
63+ fmt .Printf ("Client Version: %s\n " , version .Client )
64+ fmt .Printf ("Server Version: %s\n " , version .Server )
65+
66+ return nil
4367 },
4468 }
4569}
You can’t perform that action at this time.
0 commit comments