Add golangci-lint workflow (#4999)

* fix lint workflow

* add golang lint

* close http response body
This commit is contained in:
andrew_li
2022-06-29 11:58:36 +08:00
committed by GitHub
parent f1e06466df
commit f289795312
141 changed files with 311 additions and 592 deletions

View File

@@ -28,6 +28,8 @@ import (
)
var sf *sonyflake.Sonyflake
//nolint:unused
var upperMachineID uint16
func init() {

View File

@@ -62,7 +62,9 @@ func (m DefaultMetrics) Install(c *restful.Container) {
}
func (m DefaultMetrics) registerMetrics() {
//nolint:staticcheck
RawMustRegister(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}))
//nolint:staticcheck
RawMustRegister(prometheus.NewGoCollector())
}

View File

@@ -20,10 +20,6 @@ package reposcache
import (
"context"
"errors"
"fmt"
"io/ioutil"
"os"
"path"
"strings"
"sync"
@@ -130,20 +126,6 @@ func (c *cachedRepos) deleteRepo(repo *v1alpha1.HelmRepo) {
}
}
func loadBuiltinChartData(name, version string) ([]byte, error) {
fName := path.Join(WorkDir, "chart", fmt.Sprintf("%s-%s.tgz", name, version))
f, err := os.Open(fName)
if err != nil {
return nil, err
}
data, err := ioutil.ReadAll(f)
if err != nil {
klog.Errorf("read index failed, error: %s", err)
return nil, err
}
return data, nil
}
func (c *cachedRepos) DeleteRepo(repo *v1alpha1.HelmRepo) error {
c.Lock()
defer c.Unlock()

View File

@@ -32,7 +32,7 @@ func Parse(reader io.Reader, namespace, rlsName string, local bool) ([]*resource
klog.Infof("parse resources, namespace: %s, release: %s", namespace, rlsName)
start := time.Now()
defer func() {
klog.Infof("parse resources end, namespace: %s, release: %s, cost: %v", namespace, rlsName, time.Now().Sub(start))
klog.Infof("parse resources end, namespace: %s, release: %s, cost: %v", namespace, rlsName, time.Since(start))
}()
}
@@ -41,7 +41,7 @@ func Parse(reader io.Reader, namespace, rlsName string, local bool) ([]*resource
f := cmdutil.NewFactory(matchVersionKubeConfigFlags)
builder := f.NewBuilder().Unstructured().NamespaceParam(namespace).ContinueOnError().Stream(reader, rlsName).Flatten()
if local == true {
if local {
builder = builder.Local()
}
r := builder.Do()
@@ -50,7 +50,7 @@ func Parse(reader io.Reader, namespace, rlsName string, local bool) ([]*resource
return nil, err
}
if local == false {
if !local {
for i := range infos {
infos[i].Namespace = namespace
err := infos[i].Get()