Skip to content

Commit 83308e1

Browse files
committed
fix: warn and fix invalid namespace
1 parent 342ce7e commit 83308e1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/judge/rego.go

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package judge
22

33
import (
44
"context"
5+
56
"github.com/doitintl/kube-no-trouble/pkg/rules"
67
"github.com/open-policy-agent/opa/rego"
78
"github.com/rs/zerolog/log"
@@ -56,6 +57,12 @@ func (j *RegoJudge) Eval(input []map[string]interface{}) ([]Result, error) {
5657
log.Debug().Msgf("Failed to parse version: %s", err)
5758
}
5859

60+
// shouldn't really happen - but if it does fix up and move on
61+
if m["Namespace"] == nil {
62+
log.Warn().Msgf("Object has invalid namespace: %s/%s %s", m["ApiVersion"].(string), m["Kind"].(string), m["Name"].(string))
63+
m["Namespace"] = "<undefined>"
64+
}
65+
5966
results = append(results, Result{
6067
Name: m["Name"].(string),
6168
Namespace: m["Namespace"].(string),

0 commit comments

Comments
 (0)