Skip to content

Commit

Permalink
ignore by env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Nov 9, 2021
1 parent 4c80eab commit 11d0aee
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions score/score.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package score
import (
"encoding/json"
"fmt"
"os"
"strings"

"github.com/armosec/k8s-interface/workloadinterface"
Expand Down Expand Up @@ -66,14 +67,16 @@ workloads: if replicas:
*/
func (su *ScoreUtil) GetScore(v map[string]interface{}) float32 {

shouldIgnore := os.Getenv("IGNORE_ENABLED")
var score float32 = 1
ignoredKinds := []string{
"role", "rolebinding", "clusterrole", "clusterrolebinding",
}
wl := workloadinterface.NewWorkloadObj(v)
kind := ""

shouldIgnore = strings.ToLower(shouldIgnore)

if wl != nil {
kind = strings.ToLower(wl.GetKind())
replicas := wl.GetReplicas()
Expand All @@ -82,7 +85,7 @@ func (su *ScoreUtil) GetScore(v map[string]interface{}) float32 {
}
//temporarily we ignore role,rolebinding,clusterrole,clusterrolebinding
for i := range ignoredKinds {
if ignoredKinds[i] == kind {
if shouldIgnore == "true" && ignoredKinds[i] == kind {
return 0
}
}
Expand Down

0 comments on commit 11d0aee

Please sign in to comment.