()
| 50 | } |
| 51 | |
| 52 | func NewVersionCmd() *cobra.Command { |
| 53 | return &cobra.Command{ |
| 54 | Use: "version", |
| 55 | Short: "Command line version", |
| 56 | RunE: func(_ *cobra.Command, _ []string) error { |
| 57 | var version = struct { |
| 58 | Client string `json:"client"` |
| 59 | Server string `json:"server"` |
| 60 | }{ |
| 61 | Client: Version, |
| 62 | Server: "unknown", |
| 63 | } |
| 64 | |
| 65 | if ActionOpts.CPConnection != nil { |
| 66 | res, err := pb.NewStatusServiceClient(ActionOpts.CPConnection).Infoz(context.Background(), &pb.InfozRequest{}) |
| 67 | if err == nil { |
| 68 | version.Server = res.Version |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | if flagOutputFormat == output.FormatJSON { |
| 73 | return output.EncodeJSON(version) |
| 74 | } |
| 75 | |
| 76 | fmt.Printf("Client Version: %s\n", version.Client) |
| 77 | fmt.Printf("Server Version: %s\n", version.Server) |
| 78 | |
| 79 | return nil |
| 80 | }, |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | func executableInfo() (*info, error) { |
| 85 | h, err := executableDigest() |
no test coverage detected