Skip to content

Commit

Permalink
fix: warn and fix invalid namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
justdan96 committed Apr 27, 2024
1 parent 342ce7e commit 83308e1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/judge/rego.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package judge

import (
"context"

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

// shouldn't really happen - but if it does fix up and move on
if m["Namespace"] == nil {
log.Warn().Msgf("Object has invalid namespace: %s/%s %s", m["ApiVersion"].(string), m["Kind"].(string), m["Name"].(string))
m["Namespace"] = "<undefined>"
}

results = append(results, Result{
Name: m["Name"].(string),
Namespace: m["Namespace"].(string),
Expand Down

0 comments on commit 83308e1

Please sign in to comment.