Skip to content

Commit

Permalink
[FAB-10186] suppress repetitive config WARNs
Browse files Browse the repository at this point in the history
- move it to initialization of endpoint config


Change-Id: I7078e2949b2590cc198501d16deb4220ee1d47e3
Signed-off-by: Sudesh Shetty <[email protected]>
  • Loading branch information
sudeshrshetty committed May 17, 2018
1 parent 2933804 commit e3515e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/fab/channel/transactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ func orderersFromChannelCfg(ctx context.Client, cfg fab.ChannelCfg) ([]fab.Order
return nil, err
}
if len(orderers) > 0 {
logger.Warn("Getting orderers from endpoint config channels.orderer is deprecated, use entity matchers to override orderer configuration")
logger.Warn("visit https://github.com/hyperledger/fabric-sdk-go/blob/master/test/fixtures/config/overrides/local_entity_matchers.yaml for samples")

return orderers, nil
}

Expand Down
21 changes: 21 additions & 0 deletions pkg/fab/endpointconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ func ConfigFromBackend(coreBackend ...core.ConfigBackend) (fab.EndpointConfig, e
return nil, errors.WithMessage(err, "cert pool load failed")
}

//print deprecated warning
detectDeprecatedNetworkConfig(config)

return config, nil
}

Expand Down Expand Up @@ -1141,3 +1144,21 @@ func setDefault(dataMap map[string]interface{}, key string, defaultVal bool) {
dataMap[key] = true
}
}

//detectDeprecatedConfigOptions detects deprecated config options and prints warnings
// currently detects: if channels.orderers are defined
func detectDeprecatedNetworkConfig(endpointConfig *EndpointConfig) {

if endpointConfig.networkConfig == nil {
return
}

//detect if channels orderers are mentioned
for _, v := range endpointConfig.networkConfig.Channels {
if len(v.Orderers) > 0 {
logger.Warn("Getting orderers from endpoint config channels.orderer is deprecated, use entity matchers to override orderer configuration")
logger.Warn("visit https://github.com/hyperledger/fabric-sdk-go/blob/master/test/fixtures/config/overrides/local_entity_matchers.yaml for samples")
break
}
}
}

0 comments on commit e3515e5

Please sign in to comment.