Skip to content

Commit

Permalink
Return slice from GetIPFamilies instead of fixed-sized array
Browse files Browse the repository at this point in the history
...since it could have 0, 1, or 2 elements otherwise it will have empty
string values for element indices that aren't specifically set (so
currently it returns ["4", ""]).

Signed-off-by: Tom Pantelis <[email protected]>
  • Loading branch information
tpantelis committed Feb 24, 2025
1 parent 00afd11 commit 5262f00
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package types
import (
subv1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
k8snet "k8s.io/utils/net"
"k8s.io/utils/set"
)

type SubmarinerCluster struct {
Expand Down Expand Up @@ -52,10 +53,11 @@ type SubmarinerSpecification struct {
MetricsPort int `default:"32780"`
}

func (subSpec *SubmarinerSpecification) GetIPFamilies() [2]k8snet.IPFamily {
var ipFamilies [2]k8snet.IPFamily
func (subSpec *SubmarinerSpecification) GetIPFamilies() []k8snet.IPFamily {
ipFamilies := set.New[k8snet.IPFamily]()

// TODO_IPV6: set ipFamilies according to ClusterCidr content
ipFamilies[0] = k8snet.IPv4
ipFamilies.Insert(k8snet.IPv4)

return ipFamilies
return ipFamilies.UnsortedList()
}

0 comments on commit 5262f00

Please sign in to comment.