Skip to content

Commit

Permalink
[FAB-1174] set orderer config path via env var
Browse files Browse the repository at this point in the history
use ORDERER_CONFIG_PATH env var to set
path to orderer.yaml

Change-Id: I5b179352d5fec1ff7331bfee20af71f92bc571e7
Signed-off-by: tuand27613 <tdang@us.ibm.com>
  • Loading branch information
tuand27613 committed Nov 21, 2016
1 parent 2e1e2cb commit b0e902e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions images/orderer/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM hyperledger/fabric-baseimage:_BASE_TAG_
ENV ORDERER_CFG_PATH /etc/hyperledger/fabric
RUN mkdir -p /var/hyperledger/db /etc/hyperledger/fabric
COPY payload/orderer /usr/local/bin
COPY payload/orderer.yaml /etc/hyperledger/fabric
WORKDIR /etc/hyperledger/fabric
COPY payload/orderer.yaml $ORDERER_CFG_PATH
EXPOSE 7050
CMD orderer
31 changes: 18 additions & 13 deletions orderer/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,25 +192,30 @@ func (c *TopLevel) completeInitialization() {
func Load() *TopLevel {
config := viper.New()

config.SetConfigName("orderer")
alternativeCfgPath := os.Getenv("ORDERER_CFG_PATH")
if alternativeCfgPath != "" {
logger.Infof("User defined config file path: %s", alternativeCfgPath)
config.AddConfigPath(alternativeCfgPath) // Path to look for the config file in
} else {
config.AddConfigPath("./")
config.AddConfigPath("../../.")
config.AddConfigPath("../orderer/")
config.AddConfigPath("../../orderer/")
// Path to look for the config file in based on GOPATH
gopath := os.Getenv("GOPATH")
for _, p := range filepath.SplitList(gopath) {
ordererPath := filepath.Join(p, "src/github.com/hyperledger/fabric/orderer/")
config.AddConfigPath(ordererPath)
}
}

// for environment variables
config.SetEnvPrefix(Prefix)
config.AutomaticEnv()
replacer := strings.NewReplacer(".", "_")
config.SetEnvKeyReplacer(replacer)

config.SetConfigName("orderer")
config.AddConfigPath("./")
config.AddConfigPath("../../.")
config.AddConfigPath("../orderer/")
config.AddConfigPath("../../orderer/")
config.AddConfigPath("/etc/hyperledger/fabric/")
// Path to look for the config file in based on GOPATH
gopath := os.Getenv("GOPATH")
for _, p := range filepath.SplitList(gopath) {
ordererPath := filepath.Join(p, "src/github.com/hyperledger/fabric/orderer/")
config.AddConfigPath(ordererPath)
}

err := config.ReadInConfig()
if err != nil {
panic(fmt.Errorf("Error reading %s plugin config: %s", Prefix, err))
Expand Down

0 comments on commit b0e902e

Please sign in to comment.