Skip to content

Commit

Permalink
refactor: return pointer to false
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Pana <[email protected]>
  • Loading branch information
acpana committed Dec 11, 2024
1 parent dd2d99c commit b6d9adf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/controller/direct/maputils.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ func EnumSlice_FromProto[U ProtoEnum](mapCtx *MapContext, in []U) []string {
func LazyPtr[V comparable](v V) *V {
var defaultV V
if v == defaultV {
// Special handling for booleans
if b, ok := any(v).(bool); ok && !b {
// Return a pointer to a false boolean instead of nil
return &v
}
// For all other zero-value types, return nil
return nil
}
return &v
Expand Down

0 comments on commit b6d9adf

Please sign in to comment.