-
Notifications
You must be signed in to change notification settings - Fork 16
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
do not overwirte user added labels added to the deployment template #183
base: main
Are you sure you want to change the base?
Conversation
d496720
to
6530652
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #183 +/- ##
==========================================
- Coverage 83.71% 82.76% -0.96%
==========================================
Files 18 18
Lines 1210 1230 +20
==========================================
+ Hits 1013 1018 +5
- Misses 150 160 +10
- Partials 47 52 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
c77999c
to
d142de1
Compare
bd6f1d8
to
04eaa19
Compare
04eaa19
to
39ae954
Compare
b792015
to
2f46bc6
Compare
Propagate Limitador CR labels to deployment labels as well here https://github.com/Kuadrant/limitador-operator/blob/main/pkg/limitador/k8s_objects.go#L77 |
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.
Looking very nice
2f46bc6
to
c84accc
Compare
18b0c08
to
8f40569
Compare
97168ec
to
519d065
Compare
519d065
to
10cf420
Compare
10cf420
to
9b6b9d0
Compare
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.
Verified and working as expected, looks good to me 👍
@@ -33,3 +33,19 @@ func IsObjectTaggedToDelete(obj client.Object) bool { | |||
annotation, ok := annotations[DeleteTagAnnotation] | |||
return ok && annotation == "true" | |||
} | |||
|
|||
func MergeMapStringString(modified *bool, existing *map[string]string, desired map[string]string) { | |||
if *existing == nil { |
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.
add extra guard
if existing == nil {
// early return, as there is no ref to initialize map
return
}
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.
I've added this check but as part of the testing of the changes I've noticed a problem. If the existing map pointer is nil and we don't add that, then we never are able to add the desired labels to the existing one which is the one that we use in the cluster. If the user removes the label map and as such there is nothing there we don't have an opportunity to put that back. In the case of the deployment object meta, this is possible.
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.
when testing live against k8s, removing the label map results in the default ones being added back in so in this case there doesn't appear to be a nil pointer. in this case i don't know if we need this extra guard rail. wdyt?
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.
I'm good with not neeing this 👍
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.
almost done. Good job!
I am a bit confused. From the last community call I understood you would be implementing the option 2 (labels will be externally added and not removed). However, I see that option 1 is being implemented here, so Limitador CR labels are propagated to the deployment, not to other resources though.
9b6b9d0
to
40563f2
Compare
@@ -219,8 +218,8 @@ func ValidatePDB(pdb *policyv1.PodDisruptionBudget) error { | |||
|
|||
func Labels(limitador *limitadorv1alpha1.Limitador) map[string]string { | |||
return map[string]string{ | |||
"app": "limitador", | |||
"limitador-resource": limitador.ObjectMeta.Name, | |||
helpers.LabelKeyApp: "limitador", |
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.
we may not need this change.
025a0a6
to
7d171f9
Compare
…te objectmeta Signed-off-by: Laura Fitzgerald <[email protected]>
7d171f9
to
470589b
Compare
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.
Verified and changes looks good to me! 💯
@eguzki i'll wait for your approval before adding this to the merge queue. |
Closes #176
Verification
make run
kubectl edit deployment
spec.template.labels
something likeuseradded: label
spec.template.labels
includes the following labels