Skip to content

Commit 50fbfa4

Browse files
committed
Add function to check for OCP IPv6 cluster network
The RabbitMQ config differs for IPv6 so add a function to determine if IPv6 is enabled on the OCP cluster network
1 parent 6c8da3c commit 50fbfa4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

modules/common/ocp/ocp.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ package ocp
1818

1919
import (
2020
"context"
21+
"strings"
2122

2223
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
2324

25+
ocp_config "github.com/openshift/api/config/v1"
2426
"gopkg.in/yaml.v3"
2527
corev1 "k8s.io/api/core/v1"
2628
"k8s.io/apimachinery/pkg/types"
@@ -47,3 +49,19 @@ func IsFipsCluster(ctx context.Context, h *helper.Helper) (bool, error) {
4749
}
4850
return fipsEnabled, nil
4951
}
52+
53+
// HasIPv6ClusterNetwork - Check if OCP has an IPv6 cluster network
54+
func HasIPv6ClusterNetwork(ctx context.Context, h *helper.Helper) (bool, error) {
55+
networkConfig := &ocp_config.Network{}
56+
err := h.GetClient().Get(ctx, types.NamespacedName{Name: "cluster", Namespace: ""}, networkConfig)
57+
if err != nil {
58+
return false, err
59+
}
60+
61+
for _, clusterNetwork := range networkConfig.Status.ClusterNetwork {
62+
if strings.Count(clusterNetwork.CIDR, ":") >= 2 {
63+
return true, nil
64+
}
65+
}
66+
return false, nil
67+
}

0 commit comments

Comments
 (0)