koki / short

Manageable Kubernetes manifests through a composable, reusable syntax
https://docs.koki.io/short
Apache License 2.0
122 stars 14 forks source link

add support for pod_security_policy #183

Closed wlan0 closed 6 years ago

wlan0 commented 6 years ago

@ublubu

The behavior is correct, but the tests are failing becuse of how we check for equivalence. Help me fix it - @ublubu

ublubu commented 6 years ago

It complains that [0].Spec.SELinux.SELinuxOptions: &v1.SELinuxOptions{} != nil, which is technically true. I'm not sure we want the comparison logic to generically consider &zero-value and nil to be equal in all cases.

We could write our own (or find an existing library) DeepEqual that uses an interface to see if a particular type has the property "&zero-value and nil are equivalent". Even this might not be correct, because that may only be a property of that particular field, not every field of that type.

I think the best answer might be to standardize on nil when &zero-value and nil are equivalent. We already started doing this because &zero-value serializes as {} rather than being omitted. (note that if it weren't a pointer field, there's no &, and the zero-value would be omitted correctly.)

So checking if SELinuxOptions DeepEquals zero in revertPodSecurityPolicySELinuxPolicy and using nil instead of zero should be good enough.

wlan0 commented 6 years ago

@ublubu updated according to comments