Skip to content

Commit ed33fec

Browse files
author
Jason Yellick
committed
[FAB-1615] Configuration template proto and tool
https://jira.hyperledger.org/browse/FAB-1615 This changeset defines a proto to represent a configuration template. It also defines a tool in the orderer directory to produce this template for the orderer. Change-Id: I3b14a81fcc73a37029f50a9ae0da08e5642d2f4f Signed-off-by: Jason Yellick <[email protected]>
1 parent c53d2e0 commit ed33fec

File tree

5 files changed

+142
-52
lines changed

5 files changed

+142
-52
lines changed

orderer/tools/configtemplate/main.go

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
Copyright IBM Corp. 2016 All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"flag"
21+
"io/ioutil"
22+
23+
"github.com/hyperledger/fabric/common/flogging"
24+
"github.com/hyperledger/fabric/orderer/common/bootstrap/provisional"
25+
"github.com/hyperledger/fabric/orderer/localconfig"
26+
cb "github.com/hyperledger/fabric/protos/common"
27+
"github.com/hyperledger/fabric/protos/utils"
28+
29+
logging "github.com/op/go-logging"
30+
)
31+
32+
var logger = logging.MustGetLogger("orderer/tools/baseconfig")
33+
34+
const defaultOutputFile = "orderer.template"
35+
36+
func main() {
37+
var outputFile string
38+
flag.StringVar(&outputFile, "outputFile", defaultOutputFile, "The file to write the configuration templatee to")
39+
flag.Parse()
40+
41+
conf := config.Load()
42+
flogging.InitFromSpec(conf.General.LogLevel)
43+
44+
logger.Debugf("Initializing generator")
45+
generator := provisional.New(conf)
46+
47+
logger.Debugf("Producing template items")
48+
templateItems := generator.TemplateItems()
49+
50+
logger.Debugf("Encoding configuration template")
51+
outputData := utils.MarshalOrPanic(&cb.ConfigurationTemplate{
52+
Items: templateItems,
53+
})
54+
55+
logger.Debugf("Writing configuration to disk")
56+
ioutil.WriteFile(outputFile, outputData, 0644)
57+
58+
}

protos/common/chain-config.pb.go

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/common/configuration.pb.go

+72-51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/common/configuration.proto

+7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ message ConfigurationEnvelope {
4848
repeated SignedConfigurationItem Items = 1;
4949
}
5050

51+
// ConfigurationTemplate is used as a serialization format to share configuration templates
52+
// The orderer supplies a configuration template to the user to use when constructing a new
53+
// chain creation transaction, so this is used to facilitate that.
54+
message ConfigurationTemplate {
55+
repeated ConfigurationItem Items = 1;
56+
}
57+
5158
// This message may change slightly depending on the finalization of signature schemes for transactions
5259
message SignedConfigurationItem {
5360
bytes ConfigurationItem = 1;

protos/orderer/configuration.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)