1
0
mirror of https://github.com/k8sgpt-ai/k8sgpt.git synced 2025-05-10 17:16:06 +00:00

chore: linting improvements and catching false positives ()

* chore: linting improvements and catching false positives

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: linting improvements and catching false positives

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: linting improvements and catching false positives

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: increase linter time out

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
This commit is contained in:
Alex Jones 2024-01-23 07:46:01 +00:00 committed by GitHub
parent 335616c20f
commit 2effbb345a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 38 additions and 38 deletions

View File

@ -2,7 +2,7 @@ name: Run golangci-lint
on:
pull_request:
branches: [ main ]
branches: [main]
jobs:
golangci-lint:
@ -16,3 +16,5 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
golangci_lint_flags: "--timeout=120s"
level: warning

3
cmd/cache/add.go vendored
View File

@ -24,7 +24,8 @@ import (
)
var (
region string
region string
//nolint:unused
bucketName string
storageAccount string
containerName string

View File

@ -41,6 +41,7 @@ var GenerateCmd = &cobra.Command{
}
// override the default backend if a flag is provided
if backend != "" {
//nolint:all
backendType = backend
}
fmt.Println("")

View File

@ -37,7 +37,10 @@ func (GatewayAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error) {
gtwList := &gtwapi.GatewayList{}
gc := &gtwapi.GatewayClass{}
client := a.Client.CtrlClient
gtwapi.AddToScheme(client.Scheme())
err := gtwapi.AddToScheme(client.Scheme())
if err != nil {
return nil, err
}
if err := client.List(a.Context, gtwList, &ctrl.ListOptions{}); err != nil {
return nil, err
}

View File

@ -56,7 +56,9 @@ func TestGatewayAnalyzer(t *testing.T) {
Gateway := BuildGateway(ClassName, AcceptedStatus)
// Create a Gateway Analyzer instance with the fake client
scheme := scheme.Scheme
//nolint:all
gtwapi.Install(scheme)
//nolint:all
apiextensionsv1.AddToScheme(scheme)
objects := []runtime.Object{
&Gateway,
@ -88,6 +90,7 @@ func TestMissingClassGatewayAnalyzer(t *testing.T) {
// Create a Gateway Analyzer instance with the fake client
scheme := scheme.Scheme
//nolint:all
gtwapi.Install(scheme)
apiextensionsv1.AddToScheme(scheme)
objects := []runtime.Object{

View File

@ -33,7 +33,10 @@ func (TrivyAnalyzer) analyzeVulnerabilityReports(a common.Analyzer) ([]common.Re
result := &v1alpha1.VulnerabilityReportList{}
client := a.Client.CtrlClient
v1alpha1.AddToScheme(client.Scheme())
err := v1alpha1.AddToScheme(client.Scheme())
if err != nil {
return nil, err
}
if err := client.List(a.Context, result, &ctrl.ListOptions{}); err != nil {
return nil, err
}
@ -85,7 +88,10 @@ func (t TrivyAnalyzer) analyzeConfigAuditReports(a common.Analyzer) ([]common.Re
result := &v1alpha1.ConfigAuditReportList{}
client := a.Client.CtrlClient
v1alpha1.AddToScheme(client.Scheme())
err := v1alpha1.AddToScheme(client.Scheme())
if err != nil {
return nil, err
}
if err := client.List(a.Context, result, &ctrl.ListOptions{}); err != nil {
return nil, err
}

View File

@ -131,7 +131,10 @@ func (*handler) deactivateAllIntegrations(integrationProvider *integration.Integ
}
if err == nil {
if namespace != "" {
integrationProvider.Deactivate(i, namespace)
err := integrationProvider.Deactivate(i, namespace)
if err != nil {
return err
}
} else {
fmt.Printf("Skipping deactivation of %s, not installed\n", i)
}

View File

@ -14,13 +14,10 @@ limitations under the License.
package server
import (
json "encoding/json"
"errors"
"fmt"
"net"
"net/http"
"strconv"
"strings"
"time"
rpc "buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go/schema/v1/schemav1grpc"
@ -32,25 +29,26 @@ import (
)
type Config struct {
Port string
MetricsPort string
Backend string
Key string
Token string
Output string
maxConcurrency int
Handler *handler
Logger *zap.Logger
metricsServer *http.Server
listener net.Listener
Port string
MetricsPort string
Backend string
Key string
Token string
Output string
Handler *handler
Logger *zap.Logger
metricsServer *http.Server
listener net.Listener
}
//nolint:unused
type Health struct {
Status string `json:"status"`
Success int `json:"success"`
Failure int `json:"failure"`
}
//nolint:unused
var health = Health{
Status: "ok",
Success: 0,
@ -106,21 +104,3 @@ func (s *Config) ServeMetrics() error {
}
return nil
}
func (s *Config) healthzHandler(w http.ResponseWriter, r *http.Request) {
js, err := json.MarshalIndent(health, "", " ")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Fprint(w, string(js))
}
func getBoolParam(param string) bool {
b, err := strconv.ParseBool(strings.ToLower(param))
if err != nil {
// Handle error if conversion fails
return false
}
return b
}

View File

@ -16,6 +16,7 @@ func TestServerInit(t *testing.T) {
color.Red("failed to create logger: %v", err)
os.Exit(1)
}
//nolint:all
defer logger.Sync()
server_config := Config{
Backend: "openai",