@@ -373,37 +373,35 @@ func directPeerAndPortAllowRule(npmNetPol *policies.NPMNetworkPolicy, direction
373373 }
374374 npmNetPol .ACLs = append (npmNetPol .ACLs , acl )
375375 return nil
376- } else {
377- // handle each port separately
378- for i := range ports {
379- portKind , err := portType (ports [i ])
380- if err != nil {
381- return err
382- }
383-
384- err = checkForNamedPortType (npmNetPol , portKind , npmLiteToggle , direction , & ports [i ], cidr )
385- if err != nil {
386- return err
387- }
376+ }
377+ // handle each port separately
378+ for i := range ports {
379+ portKind , err := portType (ports [i ])
380+ if err != nil {
381+ return err
382+ }
388383
389- acl := policies .NewACLPolicy (policies .Allowed , direction )
384+ err = checkForNamedPortType (npmNetPol , portKind , npmLiteToggle , direction , & ports [i ], cidr )
385+ if err != nil {
386+ return err
387+ }
390388
391- // Set direct IP based on direction
392- if direction == policies .Ingress {
393- acl .SrcDirectIPs = []string {cidr }
394- } else {
395- acl .DstDirectIPs = []string {cidr }
396- }
389+ acl := policies .NewACLPolicy (policies .Allowed , direction )
397390
398- // Handle ports
399- if portKind == numericPortType {
400- portInfo , protocol := numericPortRule (& ports [i ])
401- acl .DstPorts = portInfo
402- acl .Protocol = policies .Protocol (protocol )
403- }
404- npmNetPol .ACLs = append (npmNetPol .ACLs , acl )
391+ // Set direct IP based on direction
392+ if direction == policies .Ingress {
393+ acl .SrcDirectIPs = []string {cidr }
394+ } else {
395+ acl .DstDirectIPs = []string {cidr }
396+ }
405397
398+ // Handle ports
399+ if portKind == numericPortType {
400+ portInfo , protocol := numericPortRule (& ports [i ])
401+ acl .DstPorts = portInfo
402+ acl .Protocol = policies .Protocol (protocol )
406403 }
404+ npmNetPol .ACLs = append (npmNetPol .ACLs , acl )
407405 }
408406 return nil
409407}
0 commit comments