|
| 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 | +} |
0 commit comments