Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address golangci-lint v1.60.3 errors #999

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading