Skip to content

Commit 468d084

Browse files
committed
Add golangci
1 parent 1c5bd9e commit 468d084

File tree

3 files changed

+80
-7
lines changed

3 files changed

+80
-7
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: golangci-lint
19+
on:
20+
push:
21+
branches:
22+
- main
23+
pull_request:
24+
25+
permissions:
26+
contents: read
27+
checks: write
28+
jobs:
29+
golangci:
30+
name: lint
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: actions/setup-go@v5
35+
with:
36+
go-version: '1.19'
37+
- name: golangci-lint
38+
uses: golangci/golangci-lint-action@v6

.golangci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
linters-settings:
2+
goheader:
3+
template: |-
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
21+
22+
linters:
23+
enable:
24+
- goheader
25+
- gosec
26+
- gosimple
27+
- govet
28+
- ineffassign
29+
- misspell
30+
- staticcheck
31+
- typecheck
32+
- unused
33+
34+
run:
35+
modules-download-mode: readonly
36+
issues-exit-code: 1

cloudstack_loadbalancer.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,10 @@ func (cs *CSCloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName st
299299
if err != nil {
300300
klog.Errorf("Error parsing port: %v", err)
301301
} else {
302-
lb.deleteFirewallRule(lbRule.Publicipid, int(port), protocol)
302+
_, err = lb.deleteFirewallRule(lbRule.Publicipid, int(port), protocol)
303+
if err != nil {
304+
klog.Errorf("Error deleting firewall rule: %v", err)
305+
}
303306
}
304307

305308
klog.V(4).Infof("Deleting load balancer rule: %v", lbRule.Name)
@@ -657,10 +660,7 @@ func compareStringSlice(x, y []string) bool {
657660
delete(diff, _y)
658661
}
659662
}
660-
if len(diff) == 0 {
661-
return true
662-
}
663-
return false
663+
return len(diff) == 0
664664
}
665665

666666
func ruleToString(rule *cloudstack.FirewallRule) string {
@@ -699,7 +699,7 @@ func rulesToString(rules []*cloudstack.FirewallRule) string {
699699
func rulesMapToString(rules map[*cloudstack.FirewallRule]bool) string {
700700
ls := &strings.Builder{}
701701
first := true
702-
for rule, _ := range rules {
702+
for rule := range rules {
703703
if first {
704704
first = false
705705
} else {
@@ -740,7 +740,6 @@ func (lb *loadBalancer) updateFirewallRule(publicIpId string, publicPort int, pr
740740
for _, rule := range r.FirewallRules {
741741
if rule.Protocol == protocol.IPProtocol() && rule.Startport == publicPort && rule.Endport == publicPort {
742742
filtered[rule] = true
743-
} else {
744743
}
745744
}
746745
klog.V(4).Infof("Matching rules for %v: %v", lb.ipAddr, rulesMapToString(filtered))

0 commit comments

Comments
 (0)