This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/cloudstack-kubernetes-provider.git
The following commit(s) were added to refs/heads/main by this push:
new 77c26882 Add golangci (#62)
77c26882 is described below
commit 77c2688241dc803be50e326ac9b1b0176f40011d
Author: Vishesh <[email protected]>
AuthorDate: Fri May 31 14:05:21 2024 +0530
Add golangci (#62)
---
.github/workflows/golangci-lint.yml | 38 ++++++++++++++++++++++++++
.golangci.yml | 53 +++++++++++++++++++++++++++++++++++++
cloudstack_loadbalancer.go | 13 +++++----
3 files changed, 97 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/golangci-lint.yml
b/.github/workflows/golangci-lint.yml
new file mode 100644
index 00000000..7f8d7aa6
--- /dev/null
+++ b/.github/workflows/golangci-lint.yml
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: golangci-lint
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+
+permissions:
+ contents: read
+ checks: write
+jobs:
+ golangci:
+ name: lint
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-go@v5
+ with:
+ go-version: '1.19'
+ - name: golangci-lint
+ uses: golangci/golangci-lint-action@v6
diff --git a/.golangci.yml b/.golangci.yml
new file mode 100644
index 00000000..5bc9b136
--- /dev/null
+++ b/.golangci.yml
@@ -0,0 +1,53 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+linters-settings:
+ goheader:
+ template: |-
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
+linters:
+ enable:
+ - goheader
+ - gosec
+ - gosimple
+ - govet
+ - ineffassign
+ - misspell
+ - staticcheck
+ - typecheck
+ - unused
+
+run:
+ modules-download-mode: readonly
+ timeout: 5m
+ issues-exit-code: 1
diff --git a/cloudstack_loadbalancer.go b/cloudstack_loadbalancer.go
index ccd268d2..09011127 100644
--- a/cloudstack_loadbalancer.go
+++ b/cloudstack_loadbalancer.go
@@ -299,7 +299,10 @@ func (cs *CSCloud) EnsureLoadBalancerDeleted(ctx
context.Context, clusterName st
if err != nil {
klog.Errorf("Error parsing port: %v", err)
} else {
- lb.deleteFirewallRule(lbRule.Publicipid,
int(port), protocol)
+ _, err =
lb.deleteFirewallRule(lbRule.Publicipid, int(port), protocol)
+ if err != nil {
+ klog.Errorf("Error deleting firewall
rule: %v", err)
+ }
}
klog.V(4).Infof("Deleting load balancer rule: %v",
lbRule.Name)
@@ -657,10 +660,7 @@ func compareStringSlice(x, y []string) bool {
delete(diff, _y)
}
}
- if len(diff) == 0 {
- return true
- }
- return false
+ return len(diff) == 0
}
func ruleToString(rule *cloudstack.FirewallRule) string {
@@ -699,7 +699,7 @@ func rulesToString(rules []*cloudstack.FirewallRule) string
{
func rulesMapToString(rules map[*cloudstack.FirewallRule]bool) string {
ls := &strings.Builder{}
first := true
- for rule, _ := range rules {
+ for rule := range rules {
if first {
first = false
} else {
@@ -740,7 +740,6 @@ func (lb *loadBalancer) updateFirewallRule(publicIpId
string, publicPort int, pr
for _, rule := range r.FirewallRules {
if rule.Protocol == protocol.IPProtocol() && rule.Startport ==
publicPort && rule.Endport == publicPort {
filtered[rule] = true
- } else {
}
}
klog.V(4).Infof("Matching rules for %v: %v", lb.ipAddr,
rulesMapToString(filtered))