Skip to content

Commit

Permalink
Address golangci-lint v1.60.3 errors
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Pantelis <[email protected]>
  • Loading branch information
tpantelis committed Aug 28, 2024
1 parent ecd0591 commit ae658ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ linters:
- bidichk
- bodyclose
- contextcheck
- copyloopvar
# - cyclop # This is equivalent to gocyclo
# - depguard # depguard now denies by default, it should only be enabled if we actually use it
- dogsled
Expand All @@ -64,7 +65,6 @@ linters:
- errname
- exhaustive
# - exhaustivestruct # Not recommended for general use - meant to be used only for special cases
- exportloopref
# - forbidigo # We don't forbid any statements
# - forcetypeassert # There are many unchecked type assertions that would be the result of a programming error so the
# reasonable recourse would be to panic anyway if checked so this doesn't seem useful
Expand Down
28 changes: 16 additions & 12 deletions pkg/azure/cloud_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ import (
)

const (
internalSecurityGroupSuffix = "-nsg"
externalSecurityGroupSuffix = "-submariner-external-sg"
internalSecurityRulePrefix = "Submariner-Internal-"
externalSecurityRulePrefix = "Submariner-External-"
publicIPNameSuffix = "-pub"
allNetworkCIDR = "0.0.0.0/0"
basePriorityInternal = 2500
baseExternalInternal = 3500
internalSecurityGroupSuffix = "-nsg"
externalSecurityGroupSuffix = "-submariner-external-sg"
internalSecurityRulePrefix = "Submariner-Internal-"
externalSecurityRulePrefix = "Submariner-External-"
publicIPNameSuffix = "-pub"
allNetworkCIDR = "0.0.0.0/0"
basePriorityInternal int32 = 2500
baseExternalInternal int32 = 3500
)

type CloudInfo struct {
Expand Down Expand Up @@ -94,11 +94,13 @@ func (c *CloudInfo) openInternalPorts(infraID string, ports []api.PortSpec, nsgC
}

for i, port := range ports {
p := int32(i) //nolint:gosec // Ignore integer overflow conversion

nwSecurityGroup.Properties.SecurityRules = append(nwSecurityGroup.Properties.SecurityRules,
c.createSecurityRule(internalSecurityRulePrefix, armnetwork.SecurityRuleProtocol(port.Protocol), port.Port,
int32(basePriorityInternal+i), armnetwork.SecurityRuleDirectionInbound),
basePriorityInternal+p, armnetwork.SecurityRuleDirectionInbound),
c.createSecurityRule(internalSecurityRulePrefix, armnetwork.SecurityRuleProtocol(port.Protocol), port.Port,
int32(basePriorityInternal+i), armnetwork.SecurityRuleDirectionOutbound))
basePriorityInternal+p, armnetwork.SecurityRuleDirectionOutbound))
}

poller, err := nsgClient.BeginCreateOrUpdate(ctx, c.BaseGroupName, groupName, nwSecurityGroup.SecurityGroup, nil)
Expand Down Expand Up @@ -186,12 +188,14 @@ func (c *CloudInfo) createGWSecurityGroup(groupName string, ports []api.PortSpec
}

securityRules := []*armnetwork.SecurityRule{}

for i, port := range ports {
p := int32(i) //nolint:gosec // Ignore integer overflow conversion
securityRules = append(securityRules,
c.createSecurityRule(externalSecurityRulePrefix, armnetwork.SecurityRuleProtocol(port.Protocol), port.Port,
int32(baseExternalInternal+i), armnetwork.SecurityRuleDirectionInbound),
baseExternalInternal+p, armnetwork.SecurityRuleDirectionInbound),
c.createSecurityRule(externalSecurityRulePrefix, armnetwork.SecurityRuleProtocol(port.Protocol), port.Port,
int32(baseExternalInternal+i), armnetwork.SecurityRuleDirectionOutbound))
baseExternalInternal+p, armnetwork.SecurityRuleDirectionOutbound))
}

nwSecurityGroup := armnetwork.SecurityGroup{
Expand Down

0 comments on commit ae658ca

Please sign in to comment.