-
Notifications
You must be signed in to change notification settings - Fork 70
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
feat: Nullable logic in code #1261
base: master
Are you sure you want to change the base?
feat: Nullable logic in code #1261
Conversation
Signed-off-by: Mateus Oliveira <[email protected]>
@@ -15,7 +15,7 @@ require ( | |||
github.com/operator-framework/operator-lib v0.9.0 | |||
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.51.2 | |||
github.com/sirupsen/logrus v1.9.0 | |||
k8s.io/api v0.25.6 | |||
k8s.io/api v0.25.6 // must update OADPResourceRequirements in api/v1alpha1/oadp_types.go when package updates |
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.
Can we create a unit test that turns resoureRequirements into unstructured and run deepEqual against current expected value? That way we know when change is required.
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.
nice idea!
Going to try to do that, thanks!
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.
did not find a way to converted to unstructured. How can I do it?
did this
func TestEqual(t *testing.T) {
created := oadpv1alpha1.OADPResourceRequirements{}
real := corev1.ResourceRequirements{}
createdConverted := corev1.ResourceRequirements(created)
realCoverted := oadpv1alpha1.OADPResourceRequirements(real)
fmt.Printf("Equal: %#v\n", reflect.DeepEqual(created, realCoverted))
fmt.Printf("Equal: %#v", reflect.DeepEqual(createdConverted, real))
}
But I am not satisfied with the test, basically the difference is the nullable comment, so we should check that is the only difference between the structs is that comment (get go comments in structs, does not seem to be easy, from what I searched)
Another question: do we need these fields to allow to be nullable?
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.
Re: how to convert to unstructured... that's what velero does :)
Here's an example: https://github.com/vmware-tanzu/velero/blob/2caba3efb93c37edc73aac1301f68ba91a670a80/pkg/backup/item_backupper_test.go#L49
content, _ := runtime.DefaultUnstructuredConverter.ToUnstructured(tt.resource)
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.
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.
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.
it may not help with nullables but it should help track field changes.
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Issues go stale after 90d of inactivity. Mark the issue as fresh by commenting If this issue is safe to close now please do so with /lifecycle stale |
This comment was marked as outdated.
This comment was marked as outdated.
@mateusoliveira43: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Issues go stale after 90d of inactivity. Mark the issue as fresh by commenting If this issue is safe to close now please do so with /lifecycle stale |
Remove logic for adding nullable fields from Makefile and add it to code.