-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-4352] Add version cmd to configtxlator
Adds a version cmd to configtxlator. Modified configxtxlator to use kingpin as the CLI library as that's what is used in cryptogen as well. Version info is added to the binary using both make configtxlator make release[-all] (Note: this fixes the issue with make cryptogen not adding the version as well) Change-Id: I6bc52f12a09b4ea60dcab2693205cf151fb1b681 Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
- Loading branch information
1 parent
88d4845
commit b593425
Showing
4 changed files
with
94 additions
and
8 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 = "configtxlator" | ||
|
||
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()) | ||
} |