Skip to content

Commit 780fca9

Browse files
committed
fixed golinter
1 parent eb7319d commit 780fca9

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

npm/pkg/controlplane/translation/translatePolicy.go

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

npm/pkg/controlplane/translation/translatePolicy_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,6 @@ func TestDirectPeerAndPortAllowRule(t *testing.T) {
16271627
}
16281628

16291629
for _, tt := range tests {
1630-
tt := tt
16311630
npmLiteToggle := true
16321631
t.Run(tt.name, func(t *testing.T) {
16331632
t.Parallel()

0 commit comments

Comments
 (0)