Skip to content

Commit

Permalink
[FAB-5901] Init viper when dev config path missing
Browse files Browse the repository at this point in the history
You: Want to use `configtxgen` but you don't have the FABRIC_CFG_PATH
environment variable set. You know how the configuration path searching
works, and you are thinking that if you have a `configtx.yaml` file in
your CWD you should be good to go.

You: Are mistaken.

If there is no $GOPATH/src/github.com/hyperledger/fabric/sampleconfig
(a.k.a. `DevConfigPath`) present in your system, you will get an
"unsupported config type" error, and be unable to use `configtxgen`.

The reason: The viper-based configuration layer is not initialized
properly when the `DevConfigPath` is missing (`InitViper` exits early).

This seems:
1. Wrong logically; I should be able to roll with just the CWD.
2. Inconsistent with our treatment of the `/etc/hyperledger/fabric`
configuration path (a.k.a. `OfficialPath`); if the `OfficialPath` does
not exist, we go on with the initialization as usual.

This changeset removes the error check for the presence of
`DevConfigPath` and the respective early-termination path of the
configuration layer.

Change-Id: I31ed6de163625d48e861e7ad1fd2c41dadf5e3e4
Signed-off-by: Kostas Christidis <kostas@christidis.io>
  • Loading branch information
kchristidis committed Feb 14, 2018
1 parent 9b65d81 commit ea5971a
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions core/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ func InitViper(v *viper.Viper, configName string) error {
addConfigPath(v, "./")

// DevConfigPath
err := AddDevConfigPath(v)
if err != nil {
return err
}
AddDevConfigPath(v)

// And finally, the official path
if dirExists(OfficialPath) {
Expand Down

0 comments on commit ea5971a

Please sign in to comment.