@@ -209,6 +209,7 @@ func getPolicyTemplates(policyConf *types.PolicyConfig) ([]map[string]map[string
209209 len (policyTemplates )+ 1 ,
210210 & []map [string ]interface {}{objTemplate },
211211 & policyConf .Manifests [i ].EvaluationInterval ,
212+ policyConf .Manifests [i ].PruneObjectBehavior ,
212213 )
213214 setNamespaceSelector (policyConf , policyTemplate )
214215 policyTemplates = append (policyTemplates , * policyTemplate )
@@ -225,7 +226,13 @@ func getPolicyTemplates(policyConf *types.PolicyConfig) ([]map[string]map[string
225226 // just build one policyTemplate by using the above non-empty consolidated objectTemplates
226227 // ConsolidateManifests = true or there is non-policy-type manifest
227228 if policyConf .ConsolidateManifests && len (objectTemplates ) > 0 {
228- policyTemplate := buildPolicyTemplate (policyConf , 1 , & objectTemplates , & policyConf .EvaluationInterval )
229+ policyTemplate := buildPolicyTemplate (
230+ policyConf ,
231+ 1 ,
232+ & objectTemplates ,
233+ & policyConf .EvaluationInterval ,
234+ policyConf .PruneObjectBehavior ,
235+ )
229236 setNamespaceSelector (policyConf , policyTemplate )
230237 policyTemplates = append (policyTemplates , * policyTemplate )
231238 }
@@ -300,6 +307,7 @@ func buildPolicyTemplate(
300307 policyNum int ,
301308 objectTemplates * []map [string ]interface {},
302309 evaluationInterval * types.EvaluationInterval ,
310+ pruneObjectBehavior string ,
303311) * map [string ]map [string ]interface {} {
304312 var name string
305313 if policyNum > 1 {
@@ -328,6 +336,11 @@ func buildPolicyTemplate(
328336 metadata ["annotations" ] = policyConf .ConfigurationPolicyAnnotations
329337 }
330338
339+ if pruneObjectBehavior != "" {
340+ configSpec := policyTemplate ["objectDefinition" ]["spec" ].(map [string ]interface {})
341+ configSpec ["pruneObjectBehavior" ] = policyConf .PruneObjectBehavior
342+ }
343+
331344 if evaluationInterval .Compliant != "" || evaluationInterval .NonCompliant != "" {
332345 evalInterval := map [string ]interface {}{}
333346
0 commit comments