Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mateusoliveira43
Copy link
Contributor

Remove logic for adding nullable fields from Makefile and add it to code.

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
Copy link
Member

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.

Copy link
Contributor Author

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!

Copy link
Contributor Author

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?

Copy link
Member

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)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 10, 2024
@openshift-merge-robot
Copy link

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.

@kaovilai kaovilai self-assigned this Feb 12, 2024
@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 14, 2024
@kaovilai

This comment was marked as outdated.

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 14, 2024
Copy link

openshift-ci bot commented Jun 19, 2024

@mateusoliveira43: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/4.14-e2e-test-kubevirt-aws bdffc55 link true /test 4.14-e2e-test-kubevirt-aws
ci/prow/4.16-images bdffc55 link true /test 4.16-images
ci/prow/4.16-ci-index bdffc55 link true /test 4.16-ci-index
ci/prow/4.15-e2e-test-kubevirt-aws bdffc55 link true /test 4.15-e2e-test-kubevirt-aws
ci/prow/4.16-e2e-test-aws bdffc55 link true /test 4.16-e2e-test-aws
ci/prow/4.15-images bdffc55 link true /test 4.15-images
ci/prow/4.16-e2e-test-kubevirt-aws bdffc55 link true /test 4.16-e2e-test-kubevirt-aws
ci/prow/4.15-ci-index bdffc55 link true /test 4.15-ci-index
ci/prow/4.15-e2e-test-aws bdffc55 link true /test 4.15-e2e-test-aws

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.

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 18, 2024
@mateusoliveira43

This comment was marked as outdated.

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants