github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/common/channelconfig/logsanitychecks.go (about) 1 /* 2 Copyright hechain. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package channelconfig 8 9 import ( 10 "github.com/hechain20/hechain/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 } { 30 _, ok := pm.GetPolicy(policyName) 31 if !ok { 32 logger.Warningf("Current configuration has no policy '%s', this will likely cause problems in production systems", policyName) 33 } else { 34 logger.Debugf("As expected, current configuration has policy '%s'", policyName) 35 } 36 } 37 } 38 if _, ok := pm.Manager([]string{policies.OrdererPrefix}); ok { 39 for _, policyName := range []string{ 40 policies.BlockValidation, 41 policies.ChannelOrdererAdmins, 42 policies.ChannelOrdererWriters, 43 policies.ChannelOrdererReaders, 44 } { 45 _, ok := pm.GetPolicy(policyName) 46 if !ok { 47 logger.Warningf("Current configuration has no policy '%s', this will likely cause problems in production systems", policyName) 48 } else { 49 logger.Debugf("As expected, current configuration has policy '%s'", policyName) 50 } 51 } 52 } 53 }