From 1ddf30f5190f863dcb39863c7d54fd8ab05869bf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Jun 2026 12:41:54 +0000 Subject: [PATCH] Add unit tests for HCP branch in buildServerConfig --- pkg/controller/cluster/server/config_test.go | 63 ++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/pkg/controller/cluster/server/config_test.go b/pkg/controller/cluster/server/config_test.go index ede7a79b..441b1823 100644 --- a/pkg/controller/cluster/server/config_test.go +++ b/pkg/controller/cluster/server/config_test.go @@ -156,6 +156,69 @@ func Test_BuildServerConfig(t *testing.T) { Server: "https://" + testServiceIP, }, }, + { + name: "Init server config with hcp mode cluster", + args: args{ + cluster: &v1beta1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: testClusterName, + Namespace: testClusterNamespace, + }, + Spec: v1beta1.ClusterSpec{ + Mode: v1beta1.HCPClusterMode, + }, + Status: v1beta1.ClusterStatus{ + ClusterCIDR: defaultSharedClusterCIDR, + ServiceCIDR: defaultSharedServiceCIDR, + }, + }, + initServer: true, + token: testToken, + serviceIP: testServiceIP, + }, + expectedData: serverConfig{ + ClusterInit: true, + ClusterCIDR: defaultSharedClusterCIDR, + ServiceCIDR: defaultSharedServiceCIDR, + DisableAgent: true, + EgressSelectorMode: "cluster", + KubeApiServerArg: []string{"endpoint-reconciler-type=none"}, + Token: testToken, + TLSSAN: []string{testServiceIP, ServiceName(testClusterName), fmt.Sprintf("%s.%s", ServiceName(testClusterName), testClusterNamespace)}, + }, + }, + { + name: "server config with hcp mode cluster", + args: args{ + cluster: &v1beta1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: testClusterName, + Namespace: testClusterNamespace, + }, + Spec: v1beta1.ClusterSpec{ + Mode: v1beta1.HCPClusterMode, + }, + Status: v1beta1.ClusterStatus{ + ClusterCIDR: defaultSharedClusterCIDR, + ServiceCIDR: defaultSharedServiceCIDR, + }, + }, + initServer: false, + token: testToken, + serviceIP: testServiceIP, + }, + expectedData: serverConfig{ + ClusterInit: true, + ClusterCIDR: defaultSharedClusterCIDR, + ServiceCIDR: defaultSharedServiceCIDR, + DisableAgent: true, + EgressSelectorMode: "cluster", + KubeApiServerArg: []string{"endpoint-reconciler-type=none"}, + Token: testToken, + TLSSAN: []string{testServiceIP, ServiceName(testClusterName), fmt.Sprintf("%s.%s", ServiceName(testClusterName), testClusterNamespace)}, + Server: "https://" + testServiceIP, + }, + }, { name: "Init server config with clusterDNS cluster spec", args: args{