Skip to content

Commit

Permalink
Merge pull request #594 from justdan96/master
Browse files Browse the repository at this point in the history
Warn and Fix Up Invalid Namespaces on Objects
  • Loading branch information
dark0dave authored May 2, 2024
2 parents 342ce7e + 83308e1 commit 12491ad
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 12491ad

Please sign in to comment.