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

Can't compare structs that contain pointers with == #428

Open
jiridanek opened this issue Oct 22, 2024 · 0 comments
Open

Can't compare structs that contain pointers with == #428

jiridanek opened this issue Oct 22, 2024 · 0 comments
Labels
kind/bug Something isn't working

Comments

@jiridanek
Copy link
Member

jiridanek commented Oct 22, 2024

/kind bug

What steps did you take and what happened:

if pod.Status.ContainerStatuses[i].State == nb.Status.ContainerState {
continue
}

There, even if

reflect.DeepEqual(pod.Status.ContainerStatuses[i].State, nb.Status.ContainerState)

returns true, that == will give us false because status contains references, not direct values.

What you expect

We should look into https://github.com/google/go-cmp, or cmp.Equal, or reflect.DeepEqual and use one of these.

Or maybe the k8s compare function, apiequality.Semantic.DeepEqual, see https://godoc.org/k8s.io/apimachinery/pkg/api/equality)

Note:

Trying this out in debugger is annoying because of

@openshift-ci openshift-ci bot added the kind/bug Something isn't working label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant