瀏覽代碼

make casing consistent and use json tags

Alexander Belanger 3 年之前
父節點
當前提交
99700d2339
共有 2 個文件被更改,包括 8 次插入6 次删除
  1. 1 1
      internal/opa/config.yaml
  2. 7 5
      internal/opa/loader.go

+ 1 - 1
internal/opa/config.yaml

@@ -56,7 +56,7 @@ prometheus:
     name: "prometheus.version"
 nginx_pod:
   kind: "pod"
-  override_severity: "critical"
+  overrideSeverity: "critical"
   match:
     namespace: ingress-nginx
     labels:

+ 7 - 5
internal/opa/loader.go

@@ -13,11 +13,11 @@ import (
 type ConfigFile map[string]ConfigFilePolicyCollection
 
 type ConfigFilePolicyCollection struct {
-	Kind             string             `yaml:"kind"`
-	Match            MatchParameters    `yaml:"match"`
-	MustExist        bool               `yaml:"mustExist"`
-	OverrideSeverity string             `yaml:"override_severity"`
-	Policies         []ConfigFilePolicy `yaml:"policies"`
+	Kind             string             `json:"kind"`
+	Match            MatchParameters    `json:"match"`
+	MustExist        bool               `json:"mustExist"`
+	OverrideSeverity string             `json:"overrideSeverity"`
+	Policies         []ConfigFilePolicy `json:"policies"`
 }
 
 type ConfigFilePolicy struct {
@@ -74,6 +74,8 @@ func LoadPolicies(configFilePathDir string) (*KubernetesPolicies, error) {
 			OverrideSeverity: cfPolicyCollection.OverrideSeverity,
 			MustExist:        cfPolicyCollection.MustExist,
 		}
+
+		fmt.Println("ADDED POLICY WITH SEVERITY", cfPolicyCollection.OverrideSeverity)
 	}
 
 	return &KubernetesPolicies{