-
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-4350] Add version cmd to configtxgen
Adds a version cmd to configtxgen. Version info is added to the binary using both - make configtxgen - make release[-all] Change-Id: Ifc881edc7dc4f0802d67403fb06eaec732ef355a Signed-off-by: Nao Nishijima <nao.nishijima@hal.hitachi.com>
- Loading branch information
Nao Nishijima
committed
Jun 7, 2017
1 parent
7de874d
commit 6f876ad
Showing
3 changed files
with
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Copyright 2017 Hitachi America | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package metadata | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
) | ||
|
||
// Package version | ||
var Version string | ||
|
||
// Program name | ||
const ProgramName = "configtxgen" | ||
|
||
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)) | ||
} |
36 changes: 36 additions & 0 deletions
36
common/configtx/tool/configtxgen/metadata/metadata_test.go
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,36 @@ | ||
/* | ||
Copyright 2017 Hitachi America | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package metadata_test | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
"testing" | ||
|
||
"github.com/hyperledger/fabric/common/configtx/tool/configtxgen/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()) | ||
} |