forked from hyperledger/fabric
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
54 lines (45 loc) · 1.27 KB
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package version
import (
"fmt"
"runtime"
"github.com/hyperledger/fabric/common/metadata"
"github.com/spf13/cobra"
)
// Program name
const ProgramName = "peer"
// Cmd returns the Cobra Command for Version
func Cmd() *cobra.Command {
return cobraCommand
}
var cobraCommand = &cobra.Command{
Use: "version",
Short: "Print fabric peer version.",
Long: `Print current version of the fabric peer server.`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 0 {
return fmt.Errorf("trailing args detected")
}
// Parsing of the command line is done so silence cmd usage
cmd.SilenceUsage = true
fmt.Print(GetInfo())
return nil
},
}
// GetInfo returns version information for the peer
func GetInfo() string {
ccinfo := fmt.Sprintf(" Base Docker Namespace: %s\n"+
" Base Docker Label: %s\n"+
" Docker Namespace: %s\n",
metadata.BaseDockerNamespace,
metadata.BaseDockerLabel,
metadata.DockerNamespace)
return fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n Go version: %s\n"+
" OS/Arch: %s\n"+
" Chaincode:\n%s\n",
ProgramName, metadata.Version, metadata.CommitSHA, runtime.Version(),
fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), ccinfo)
}