Skip to content

Commit

Permalink
Allow all policy types to use hub templates
Browse files Browse the repository at this point in the history
The framework-addon will handle the reporting of the hub template
errors, it is not necessary for each controller to consider them.

Refs:
 - https://issues.redhat.com/browse/ACM-10858

Signed-off-by: Justin Kulikauskas <[email protected]>
  • Loading branch information
JustinKuli authored and openshift-merge-bot[bot] committed Apr 29, 2024
1 parent 1f8a6f0 commit 66971b0
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions controllers/propagator/propagation.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,22 +269,6 @@ func (r *ReplicatedPolicyReconciler) processTemplates(
continue
}

if !isConfigurationPolicy(policyT) {
// has Templates but not a configuration policy
err := k8serrors.NewBadRequest("Templates are restricted to only Configuration Policies")
log.Error(err, "Not a Configuration Policy")

r.Recorder.Event(rootPlc, "Warning", "PolicyPropagation",
fmt.Sprintf(
"Policy %s/%s has templates but it is not a ConfigurationPolicy.",
rootPlc.GetName(),
rootPlc.GetNamespace(),
),
)

return err
}

log.V(1).Info("Found an object definition with templates")

templateContext := templateCtx{ManagedClusterName: clusterName}
Expand Down Expand Up @@ -427,11 +411,3 @@ func (r *ReplicatedPolicyReconciler) processTemplates(

return nil
}

func isConfigurationPolicy(policyT *policiesv1.PolicyTemplate) bool {
// check if it is a configuration policy first
var jsonDef map[string]interface{}
_ = json.Unmarshal(policyT.ObjectDefinition.Raw, &jsonDef)

return jsonDef != nil && jsonDef["kind"] == "ConfigurationPolicy"
}

0 comments on commit 66971b0

Please sign in to comment.