Skip to content

Commit

Permalink
[FAB-1615] Configuration template proto and tool
Browse files Browse the repository at this point in the history
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 <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Jan 13, 2017
1 parent c53d2e0 commit ed33fec
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 52 deletions.
58 changes: 58 additions & 0 deletions orderer/tools/configtemplate/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright IBM Corp. 2016 All Rights Reserved.
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 main

import (
"flag"
"io/ioutil"

"github.com/hyperledger/fabric/common/flogging"
"github.com/hyperledger/fabric/orderer/common/bootstrap/provisional"
"github.com/hyperledger/fabric/orderer/localconfig"
cb "github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/utils"

logging "github.com/op/go-logging"
)

var logger = logging.MustGetLogger("orderer/tools/baseconfig")

const defaultOutputFile = "orderer.template"

func main() {
var outputFile string
flag.StringVar(&outputFile, "outputFile", defaultOutputFile, "The file to write the configuration templatee to")
flag.Parse()

conf := config.Load()
flogging.InitFromSpec(conf.General.LogLevel)

logger.Debugf("Initializing generator")
generator := provisional.New(conf)

logger.Debugf("Producing template items")
templateItems := generator.TemplateItems()

logger.Debugf("Encoding configuration template")
outputData := utils.MarshalOrPanic(&cb.ConfigurationTemplate{
Items: templateItems,
})

logger.Debugf("Writing configuration to disk")
ioutil.WriteFile(outputFile, outputData, 0644)

}
4 changes: 4 additions & 0 deletions protos/common/chain-config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 72 additions & 51 deletions protos/common/configuration.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions protos/common/configuration.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ message ConfigurationEnvelope {
repeated SignedConfigurationItem Items = 1;
}

// ConfigurationTemplate is used as a serialization format to share configuration templates
// The orderer supplies a configuration template to the user to use when constructing a new
// chain creation transaction, so this is used to facilitate that.
message ConfigurationTemplate {
repeated ConfigurationItem Items = 1;
}

// This message may change slightly depending on the finalization of signature schemes for transactions
message SignedConfigurationItem {
bytes ConfigurationItem = 1;
Expand Down
2 changes: 1 addition & 1 deletion protos/orderer/configuration.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ed33fec

Please sign in to comment.