func findSecurityRule(rules []network.SecurityRule, rule network.SecurityRule) bool {
	for _, existingRule := range rules {
		if !strings.EqualFold(*existingRule.Name, *rule.Name) {
			continue
		}
		if existingRule.Protocol != rule.Protocol {
			continue
		}
		if !strings.EqualFold(*existingRule.SourcePortRange, *rule.SourcePortRange) {
			continue
		}
		if !strings.EqualFold(*existingRule.DestinationPortRange, *rule.DestinationPortRange) {
			continue
		}
		if !strings.EqualFold(*existingRule.SourceAddressPrefix, *rule.SourceAddressPrefix) {
			continue
		}
		if !allowsConsolidation(existingRule) && !allowsConsolidation(rule) {
			if !strings.EqualFold(*existingRule.DestinationAddressPrefix, *rule.DestinationAddressPrefix) {
				continue
			}
		}
		if existingRule.Access != rule.Access {
			continue
		}
		if existingRule.Direction != rule.Direction {
			continue
		}
		return true
	}
	return false
}
// This compares rule's Name, Protocol, SourcePortRange, DestinationPortRange, SourceAddressPrefix, Access, and Direction.
// Note that it compares rule's DestinationAddressPrefix only when it's not consolidated rule as such rule does not have DestinationAddressPrefix defined.
// We intentionally do not compare DestinationAddressPrefixes in consolidated case because reconcileSecurityRule has to consider the two rules equal,
// despite different DestinationAddressPrefixes, in order to give it a chance to consolidate the two rules.
This compares rule's Name, Protocol, SourcePortRange, DestinationPortRange, SourceAddressPrefix, Access, and Direction.
Note that it compares rule's DestinationAddressPrefix only when it's not consolidated rule as such rule does not have DestinationAddressPrefix defined.
We intentionally do not compare DestinationAddressPrefixes in consolidated case because reconcileSecurityRule has to consider the two rules equal,
despite different DestinationAddressPrefixes, in order to give it a chance to consolidate the two rules.
// This compares rule ' s Name Protocol SourcePortRange DestinationPortRange SourceAddressPrefix Access and Direction . // Note that it compares rule ' s DestinationAddressPrefix only when it ' s not consolidated rule as such rule does not have DestinationAddressPrefix defined . // We intentionally do not compare DestinationAddressPrefixes in consolidated case because reconcileSecurityRule has to consider the two rules equal // despite different DestinationAddressPrefixes in order to give it a chance to consolidate the two rules .
func findSecurityRule(rules []network.SecurityRule, rule network.SecurityRule) bool {
	for _, existingRule := range rules {
		if !strings.EqualFold(*existingRule.Name, *rule.Name) {
			continue
		}
		if existingRule.Protocol != rule.Protocol {
			continue
		}
		if !strings.EqualFold(*existingRule.SourcePortRange, *rule.SourcePortRange) {
			continue
		}
		if !strings.EqualFold(*existingRule.DestinationPortRange, *rule.DestinationPortRange) {
			continue
		}
		if !strings.EqualFold(*existingRule.SourceAddressPrefix, *rule.SourceAddressPrefix) {
			continue
		}
		if !allowsConsolidation(existingRule) && !allowsConsolidation(rule) {
			if !strings.EqualFold(*existingRule.DestinationAddressPrefix, *rule.DestinationAddressPrefix) {
				continue
			}
		}
		if existingRule.Access != rule.Access {
			continue
		}
		if existingRule.Direction != rule.Direction {
			continue
		}
		return true
	}
	return false
}
func findSecurityRule ( rules [ ] network . SecurityRule , rule network . SecurityRule ) bool { for _ , existingRule := range rules { if ! strings . EqualFold ( * existingRule . Name , * rule . Name ) { continue } if existingRule . Protocol != rule . Protocol { continue } if ! strings . EqualFold ( * existingRule . SourcePortRange , * rule . SourcePortRange ) { continue } if ! strings . EqualFold ( * existingRule . DestinationPortRange , * rule . DestinationPortRange ) { continue } if ! strings . EqualFold ( * existingRule . SourceAddressPrefix , * rule . SourceAddressPrefix ) { continue } if ! allowsConsolidation ( existingRule ) && ! allowsConsolidation ( rule ) { if ! strings . EqualFold ( * existingRule . DestinationAddressPrefix , * rule . DestinationAddressPrefix ) { continue } } if existingRule . Access != rule . Access { continue } if existingRule . Direction != rule . Direction { continue } return true } return false }
This compares rule's Name, Protocol, SourcePortRange, DestinationPortRange, SourceAddressPrefix, Access, and Direction.
This compares rule ' s Name Protocol SourcePortRange DestinationPortRange SourceAddressPrefix Access and Direction .