-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-4351] Add version cmd to cryptogen
We need to print out the version info for cryptogen. This adds a version command: cryptogen version Note that the metadata package is self-contained in case we decide to move cryptogen to its own repo in the future. Change-Id: Icce83bb125cd9b8c7b8b6ae534fe330cf151e115 Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
- Loading branch information
1 parent
670be92
commit e776adc
Showing
4 changed files
with
71 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package metadata | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
) | ||
|
||
// package-scoped variables | ||
|
||
// Package version | ||
var Version string | ||
|
||
// package-scoped constants | ||
|
||
// Program name | ||
const ProgramName = "cryptogen" | ||
|
||
func GetVersionInfo() string { | ||
if Version == "" { | ||
Version = "development build" | ||
} | ||
|
||
return fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s", | ||
ProgramName, Version, runtime.Version(), | ||
fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) | ||
} |
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,26 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package metadata_test | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
"testing" | ||
|
||
"github.com/hyperledger/fabric/common/tools/cryptogen/metadata" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetVersionInfo(t *testing.T) { | ||
testVersion := "TestVersion" | ||
metadata.Version = testVersion | ||
|
||
expected := fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s", | ||
metadata.ProgramName, testVersion, runtime.Version(), | ||
fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) | ||
assert.Equal(t, expected, metadata.GetVersionInfo()) | ||
} |