https://rancher.com/ logo
Title
c

cool-thailand-26552

11/11/2022, 10:42 AM
@rapid-van-91305 @astonishing-stone-14417 I am having multiple constant definitions with the same values like the following:
const (
	KernelDefaultsProtectionEnabled  KernelDefaultsProtectionPolicy = "enabled"
	KernelDefaultsProtectionDisabled KernelDefaultsProtectionPolicy = "disabled"
)

const (
	EtcdMetricsEnabled  EtcdMetricsExposurePolicy = "enabled"
	EtcdMetricsDisabled EtcdMetricsExposurePolicy = "disabled"
)
Is this overkill, or is it how it should be ?
r

rapid-van-91305

11/11/2022, 10:43 AM
Maybe if they have the same values i’d use just one type / constants
👍 1
c

cool-thailand-26552

11/11/2022, 10:45 AM
Most of these were
bool
that we changed to
Enum
for best practices, it looks like we would lose the benefit of the change if we do that. Am I wrong ?
Why not just use the
bool
after all ?
a

astonishing-stone-14417

11/11/2022, 10:45 AM
I'm not strictly against bools but I've seen cases when they had to be expanded with other options.
r

rapid-van-91305

11/11/2022, 10:46 AM
In CAPA we don’t use Enums for bools
We have something like this:
// +kubebuilder:default=false
	DisableVPCCNI bool `json:"disableVPCCNI,omitempty"`
c

cool-thailand-26552

11/11/2022, 10:46 AM
OK, let's say : if it is and should always be
enabled
or
disabled
, we would just put a
bool
👍 1
That's probably more readable
r

rapid-van-91305

11/11/2022, 10:47 AM
Yes i would say so
c

cool-thailand-26552

11/11/2022, 10:48 AM
OK, cool ... I don't think I can recover an old commit after so many commits in between, so I will just refactor