-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set parent policy label on template when updating #35
Set parent policy label on template when updating #35
Conversation
a76360a
to
af95418
Compare
969f8e7
to
df4a698
Compare
8520fd2
to
d876cae
Compare
Currently, the parent policy label on templates, which is used for open-cluster-management-io#28 , is only set on template creation, which could cause issues with policies that have already been created. This fix verifies the necessary template labels are set when updating the template. Signed-off-by: Will Kutler <wkutler@redhat.com>
05899f7
to
2c8fb86
Compare
@@ -666,20 +666,24 @@ func (r *PolicyReconciler) Reconcile(ctx context.Context, request reconcile.Requ | |||
log.Error(err, "Failed to apply defaults to the ConstraintTemplate for comparison. Continuing.") | |||
} | |||
} | |||
// verify parent policy label is set properly | |||
tObjectUnstructured.SetLabels(r.setDefaultTemplateLabels(instance, tObjectUnstructured.GetLabels())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@willkutler, did you mean this instead?
tObjectUnstructured.SetLabels(r.setDefaultTemplateLabels(instance, tObjectUnstructured.GetLabels())) | |
tObjectUnstructured.SetLabels(r.setDefaultTemplateLabels(instance, eObject.GetLabels())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think that line should be right - the code should retain any non-default labels specified in the template in case users edit a policy to add labels to the policy template. That line is just making sure the template labels have the default labels set too before we compare them with the existing template object's labels.
Signed-off-by: Will Kutler <wkutler@redhat.com> review Signed-off-by: Will Kutler <wkutler@redhat.com>
2c8fb86
to
71003be
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mprahl, willkutler The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Currently, the parent policy label on templates, which is used for #28 , is only set on template creation, which could cause issues with policies that have already been created. This fix verifies the necessary template labels are set when updating the template. It also includes a light refactor of the template equality check to make it look a little cleaner.