Add server URL handling in cluster creation and enhance kubeconfig tests (#1050)

This commit is contained in:
Enrico Candino
2026-07-23 12:26:10 +02:00
committed by GitHub
parent d9219da469
commit fd64c55e5c
2 changed files with 66 additions and 0 deletions
+10
View File
@@ -29,6 +29,7 @@ import (
"github.com/rancher/k3k/pkg/apis/k3k.io/v1beta1"
"github.com/rancher/k3k/pkg/controller"
k3kcluster "github.com/rancher/k3k/pkg/controller/cluster"
"github.com/rancher/k3k/pkg/controller/cluster/server"
)
type CreateConfig struct {
@@ -198,6 +199,15 @@ func createAction(appCtx *AppContext, config *CreateConfig) func(cmd *cobra.Comm
return err
}
serverURL, err := server.ServerURL(ctx, client, cluster, host)
if err != nil {
return err
}
for _, kubeCluster := range kubeconfig.Clusters {
kubeCluster.Server = serverURL.String()
}
if err := writeKubeconfigFile(cluster, kubeconfig, ""); err != nil {
return err
}