github.com/ewagmig/fabric@v2.1.1+incompatible/common/channelconfig/logsanitychecks.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package channelconfig
     8  
     9  import (
    10  	"github.com/hyperledger/fabric/common/policies"
    11  )
    12  
    13  func LogSanityChecks(res Resources) {
    14  	pm := res.PolicyManager()
    15  	for _, policyName := range []string{policies.ChannelReaders, policies.ChannelWriters} {
    16  		_, ok := pm.GetPolicy(policyName)
    17  		if !ok {
    18  			logger.Warningf("Current configuration has no policy '%s', this will likely cause problems in production systems", policyName)
    19  		} else {
    20  			logger.Debugf("As expected, current configuration has policy '%s'", policyName)
    21  		}
    22  	}
    23  	if _, ok := pm.Manager([]string{policies.ApplicationPrefix}); ok {
    24  		// Check for default application policies if the application component is defined
    25  		for _, policyName := range []string{
    26  			policies.ChannelApplicationReaders,
    27  			policies.ChannelApplicationWriters,
    28  			policies.ChannelApplicationAdmins} {
    29  			_, ok := pm.GetPolicy(policyName)
    30  			if !ok {
    31  				logger.Warningf("Current configuration has no policy '%s', this will likely cause problems in production systems", policyName)
    32  			} else {
    33  				logger.Debugf("As expected, current configuration has policy '%s'", policyName)
    34  			}
    35  		}
    36  	}
    37  	if _, ok := pm.Manager([]string{policies.OrdererPrefix}); ok {
    38  		for _, policyName := range []string{
    39  			policies.BlockValidation,
    40  			policies.ChannelOrdererAdmins,
    41  			policies.ChannelOrdererWriters,
    42  			policies.ChannelOrdererReaders} {
    43  			_, ok := pm.GetPolicy(policyName)
    44  			if !ok {
    45  				logger.Warningf("Current configuration has no policy '%s', this will likely cause problems in production systems", policyName)
    46  			} else {
    47  				logger.Debugf("As expected, current configuration has policy '%s'", policyName)
    48  			}
    49  		}
    50  	}
    51  }