Skip to content

Commit

Permalink
[FAB-1956] Automatically generate orderer template
Browse files Browse the repository at this point in the history
https://jira.hyperledger.org/browse/FAB-1956

It's easy to accidentally let the orderer template get out of sync, so
this CR causes the orderer unit tests to update the orderer.template
file in common/configtx/test.  Other automatic template generation
coming in the near future.

Change-Id: I5709bff35b724e4751c01d6e04392698afcf9c7a
Signed-off-by: Jason Yellick <[email protected]>
  • Loading branch information
Jason Yellick committed Feb 5, 2017
1 parent a8486dc commit d1e939f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
13 changes: 8 additions & 5 deletions orderer/tools/configtemplate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ 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()

func writeTemplate(outputFile string) {
conf := config.Load()
flogging.InitFromSpec(conf.General.LogLevel)

Expand All @@ -54,5 +50,12 @@ func main() {

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

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

writeTemplate(outputFile)
}
25 changes: 25 additions & 0 deletions orderer/tools/configtemplate/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Copyright IBM Corp. 2017 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 (
"testing"
)

func TestUpdateTemplate(t *testing.T) {
writeTemplate("../../../common/configtx/test/orderer.template")
}

0 comments on commit d1e939f

Please sign in to comment.