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 16
16
package cmd
17
17
18
18
import (
19
+ "context"
19
20
"crypto/sha256"
20
21
"fmt"
21
22
"hash"
22
23
"io"
23
24
"os"
24
25
26
+ pb "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1"
25
27
"github.com/spf13/cobra"
26
28
)
27
29
@@ -38,8 +40,30 @@ func NewVersionCmd() *cobra.Command {
38
40
return & cobra.Command {
39
41
Use : "version" ,
40
42
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
43
67
},
44
68
}
45
69
}
You can’t perform that action at this time.
0 commit comments