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 ceebf07 commit 4a9c49f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/controller/direct/maputils.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,17 @@ 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
//val := false
return &v
}
// For all other zero-value types, return nil
return nil
}
return &v
}

func StringTimestamp_FromProto(mapCtx *MapContext, ts *timestamppb.Timestamp) *string {
if ts == nil {
return nil
Expand Down

0 comments on commit 4a9c49f

Please sign in to comment.