Skip to content

Commit

Permalink
fix #314
Browse files Browse the repository at this point in the history
  • Loading branch information
derailed committed Sep 14, 2024
1 parent 02cc29c commit 1c48753
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 46 deletions.
3 changes: 3 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Popeye

package cmd

import (
Expand Down
7 changes: 7 additions & 0 deletions internal/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (

var (
ClusterGVR = types.NewGVR("cluster")
groups = map[R]string{
NP: "networking.k8s.io",
}
)

// ResourceMetas represents a collection of resource metadata.
Expand Down Expand Up @@ -165,6 +168,10 @@ func (a *Aliases) loadPreferred(c types.Connection) error {
continue
}
for _, r := range l.APIResources {
if g, ok := groups[R(r.Name)]; ok && g != gv.Group {
continue
}

gvr := types.NewGVRFromAPIRes(gv, r)
if !a.cilium && strings.Contains(gvr.G(), "cilium.io") {
a.cilium = true
Expand Down
37 changes: 0 additions & 37 deletions internal/gvr/types.go

This file was deleted.

2 changes: 1 addition & 1 deletion internal/report/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (s *ScanReport) Error(msg string, err error) {

// Comment writes a comment line.
func (s *ScanReport) Comment(msg string) {
fmt.Fprintf(s, " · "+msg+"\n")
fmt.Fprint(s, " · "+msg+"\n")
}

// Dump all errors to output.
Expand Down
9 changes: 5 additions & 4 deletions internal/report/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package report

import (
"bytes"
"errors"
"fmt"
"io"
"strings"
Expand All @@ -31,12 +32,12 @@ func TestError(t *testing.T) {
e string
}{
{
fmt.Errorf("crapola"),
"\n💥 \x1b[38;5;196mblee: crapola\x1b[0m\n",
err: fmt.Errorf("crapola"),
e: "\n💥 \x1b[38;5;196mblee: crapola\x1b[0m\n",
},
{
fmt.Errorf(strings.Repeat("#", 200)),
"\n💥 \x1b[38;5;196mblee: " + strings.Repeat("#", Width-9) + "\x1b[0m\n\x1b[38;5;196m" + strings.Repeat("#", Width-3) + "\x1b[0m\n\x1b[38;5;196m" + strings.Repeat("#", Width-88) + "\x1b[0m\n",
err: errors.New(strings.Repeat("#", 200)),
e: "\n💥 \x1b[38;5;196mblee: " + strings.Repeat("#", Width-9) + "\x1b[0m\n\x1b[38;5;196m" + strings.Repeat("#", Width-3) + "\x1b[0m\n\x1b[38;5;196m" + strings.Repeat("#", Width-88) + "\x1b[0m\n",
},
}

Expand Down
3 changes: 3 additions & 0 deletions internal/stringset_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Popeye

package internal_test

import (
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Popeye

package main

import (
Expand Down
12 changes: 8 additions & 4 deletions pkg/popeye.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,9 @@ func (p *Popeye) lint() (int, int, error) {
if gvr == internal.Glossary[internal.NO] && p.client().ActiveNamespace() != client.AllNamespaces {
continue
}
if !p.aliases.IsNamespaced(gvr) {
ctx = context.WithValue(ctx, internal.KeyNamespace, client.ClusterScope)
}

runners[gvr] = fn(ctx, cache, codes)

}

total, errCount := len(runners), 0
Expand Down Expand Up @@ -305,7 +304,12 @@ func (p *Popeye) runLinter(ctx context.Context, gvr types.GVR, l scrub.Linter, c
}
}()

if err := l.Lint(ctx); err != nil {
callCtx := ctx
if !p.aliases.IsNamespaced(gvr) {
callCtx = context.WithValue(ctx, internal.KeyNamespace, client.ClusterScope)
}

if err := l.Lint(callCtx); err != nil {
p.builder.AddError(err)
}
o := l.Outcome().Filter(rules.Level(p.config.LintLevel))
Expand Down

0 comments on commit 1c48753

Please sign in to comment.