dualstack: incorporate IsIPv4 updates from utils repo

This dependency bump will allow for cleanup of duplicate code in
the dualstack e2e tests.

Signed-off-by: Christopher M. Luciano <cmluciano@us.ibm.com>
This commit is contained in:
Christopher M. Luciano
2020-11-05 14:25:23 -05:00
parent eca53507be
commit 5303b3fbbd
38 changed files with 177 additions and 71 deletions

View File

@@ -51,14 +51,23 @@ func Int32Ptr(i int32) *int32 {
return &i
}
// Int32PtrDerefOr dereference the int32 ptr and returns it if not nil,
// else returns def.
func Int32PtrDerefOr(ptr *int32, def int32) int32 {
if ptr != nil {
return *ptr
}
return def
}
// Int64Ptr returns a pointer to an int64
func Int64Ptr(i int64) *int64 {
return &i
}
// Int32PtrDerefOr dereference the int32 ptr and returns it if not nil,
// Int64PtrDerefOr dereference the int64 ptr and returns it if not nil,
// else returns def.
func Int32PtrDerefOr(ptr *int32, def int32) int32 {
func Int64PtrDerefOr(ptr *int64, def int64) int64 {
if ptr != nil {
return *ptr
}
@@ -70,17 +79,53 @@ func BoolPtr(b bool) *bool {
return &b
}
// BoolPtrDerefOr dereference the bool ptr and returns it if not nil,
// else returns def.
func BoolPtrDerefOr(ptr *bool, def bool) bool {
if ptr != nil {
return *ptr
}
return def
}
// StringPtr returns a pointer to the passed string.
func StringPtr(s string) *string {
return &s
}
// StringPtrDerefOr dereference the string ptr and returns it if not nil,
// else returns def.
func StringPtrDerefOr(ptr *string, def string) string {
if ptr != nil {
return *ptr
}
return def
}
// Float32Ptr returns a pointer to the passed float32.
func Float32Ptr(i float32) *float32 {
return &i
}
// Float32PtrDerefOr dereference the float32 ptr and returns it if not nil,
// else returns def.
func Float32PtrDerefOr(ptr *float32, def float32) float32 {
if ptr != nil {
return *ptr
}
return def
}
// Float64Ptr returns a pointer to the passed float64.
func Float64Ptr(i float64) *float64 {
return &i
}
// Float64PtrDerefOr dereference the float64 ptr and returns it if not nil,
// else returns def.
func Float64PtrDerefOr(ptr *float64, def float64) float64 {
if ptr != nil {
return *ptr
}
return def
}