mirror of
https://github.com/YuzuZensai/netbird-kubernetes-operator.git
synced 2026-09-13 10:49:15 +00:00
Add ingress feature to controller (#5)
Co-authored-by: Maycon Santos <mlsmaycon@gmail.com>
This commit is contained in:
co-authored by
Maycon Santos
parent
cea60745d2
commit
166091b8e0
@@ -0,0 +1,6 @@
|
||||
package util
|
||||
|
||||
// Ptr return pointer to any value for API purposes
|
||||
func Ptr[T any, PT *T](x T) PT {
|
||||
return &x
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package util
|
||||
|
||||
// Contains return if y is in slice x
|
||||
func Contains[T comparable](x []T, y T) bool {
|
||||
for _, v := range x {
|
||||
if v == y {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Without return all of x in same order without y
|
||||
func Without[T comparable](x []T, y T) []T {
|
||||
var ret []T
|
||||
for _, v := range x {
|
||||
if v != y {
|
||||
ret = append(ret, v)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// Equivalent return true if x and y are equal when sorted
|
||||
func Equivalent[T comparable](x, y []T) bool {
|
||||
if len(x) != len(y) {
|
||||
return false
|
||||
}
|
||||
|
||||
mp := make(map[T]interface{})
|
||||
for _, v := range x {
|
||||
mp[v] = nil
|
||||
}
|
||||
for _, v := range y {
|
||||
if _, ok := mp[v]; !ok {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user