diff --git a/packaging/flavorgen/flavors/kubevip/files.go b/internal/kubevip/files.go similarity index 90% rename from packaging/flavorgen/flavors/kubevip/files.go rename to internal/kubevip/files.go index ee0ce3bb0d..64f2c06240 100644 --- a/packaging/flavorgen/flavors/kubevip/files.go +++ b/internal/kubevip/files.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package kubevip provides the files required to run kube-vip in a cluster. package kubevip import ( @@ -38,12 +39,13 @@ var ( kubeVipPodRaw string ) -func newKubeVIPFiles() []bootstrapv1.File { +// Files returns the files required for a control plane node to run kube-vip. +func Files() []bootstrapv1.File { return []bootstrapv1.File{ { Owner: "root:root", Path: "/etc/kubernetes/manifests/kube-vip.yaml", - Content: kubeVIPPodYAML(), + Content: PodYAML(), Permissions: "0644", }, // This file is part of the workaround for https://github.com/kube-vip/kube-vip/issues/692 @@ -63,7 +65,8 @@ func newKubeVIPFiles() []bootstrapv1.File { } } -func kubeVIPPodYAML() string { +// PodYAML returns the static pod manifest required to run kube-vip. +func PodYAML() string { pod := &corev1.Pod{} if err := yaml.Unmarshal([]byte(kubeVipPodRaw), pod); err != nil { diff --git a/packaging/flavorgen/flavors/kubevip/kube-vip-prepare.sh b/internal/kubevip/kube-vip-prepare.sh similarity index 100% rename from packaging/flavorgen/flavors/kubevip/kube-vip-prepare.sh rename to internal/kubevip/kube-vip-prepare.sh diff --git a/packaging/flavorgen/flavors/kubevip/kube-vip.yaml b/internal/kubevip/kube-vip.yaml similarity index 100% rename from packaging/flavorgen/flavors/kubevip/kube-vip.yaml rename to internal/kubevip/kube-vip.yaml diff --git a/packaging/flavorgen/flavors/clusterclass_generators.go b/packaging/flavorgen/flavors/clusterclass_generators.go index 0e5382b10c..30d08444ff 100644 --- a/packaging/flavorgen/flavors/clusterclass_generators.go +++ b/packaging/flavorgen/flavors/clusterclass_generators.go @@ -55,7 +55,7 @@ func newClusterClass() clusterv1.ClusterClass { }, ControlPlane: getControlPlaneClass(), Workers: getWorkersClass(), - Variables: getClusterClassVariables(false), + Variables: GetClusterClassVariables(false), Patches: getClusterClassPatches(), }, } @@ -81,7 +81,7 @@ func newVMWareClusterClass() clusterv1.ClusterClass { }, ControlPlane: getVMWareControlPlaneClass(), Workers: getVMWareWorkersClass(), - Variables: getClusterClassVariables(true), + Variables: GetClusterClassVariables(true), Patches: getVMWareClusterClassPatches(), }, } @@ -238,7 +238,7 @@ func getEnableSSHIntoNodesTemplate() *string { return ptr.To(string(templateStr)) } -func getClusterClassVariables(supervisorMode bool) []clusterv1.ClusterClassVariable { +func GetClusterClassVariables(supervisorMode bool) []clusterv1.ClusterClassVariable { variables := []clusterv1.ClusterClassVariable{ { Name: "sshKey", diff --git a/packaging/flavorgen/flavors/kubevip/kubevip.go b/packaging/flavorgen/flavors/kubevip/kubevip.go index c18ead9c79..a78d8003cf 100644 --- a/packaging/flavorgen/flavors/kubevip/kubevip.go +++ b/packaging/flavorgen/flavors/kubevip/kubevip.go @@ -19,9 +19,11 @@ package kubevip import ( controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1" + + "sigs.k8s.io/cluster-api-provider-vsphere/internal/kubevip" ) // PatchControlPlane adds kube-vip to a KubeadmControlPlane object. func PatchControlPlane(cp *controlplanev1.KubeadmControlPlane) { - cp.Spec.KubeadmConfigSpec.Files = append(cp.Spec.KubeadmConfigSpec.Files, newKubeVIPFiles()...) + cp.Spec.KubeadmConfigSpec.Files = append(cp.Spec.KubeadmConfigSpec.Files, kubevip.Files()...) } diff --git a/packaging/flavorgen/flavors/kubevip/topology.go b/packaging/flavorgen/flavors/kubevip/topology.go index 5d15bbb7fb..2dd0d7b17a 100644 --- a/packaging/flavorgen/flavors/kubevip/topology.go +++ b/packaging/flavorgen/flavors/kubevip/topology.go @@ -30,12 +30,13 @@ import ( controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1" "sigs.k8s.io/yaml" + "sigs.k8s.io/cluster-api-provider-vsphere/internal/kubevip" "sigs.k8s.io/cluster-api-provider-vsphere/packaging/flavorgen/flavors/util" ) // TopologyVariable returns the ClusterClass variable for kube-vip. func TopologyVariable() (*clusterv1.ClusterVariable, error) { - out, err := json.Marshal(kubeVIPPodYAML()) + out, err := json.Marshal(kubevip.PodYAML()) if err != nil { return nil, errors.Wrapf(err, "failed to json-encode variable kubeVipPod") } @@ -52,7 +53,7 @@ func TopologyVariable() (*clusterv1.ClusterVariable, error) { func TopologyPatch() clusterv1.ClusterClassPatch { patches := []clusterv1.JSONPatch{} - for _, f := range newKubeVIPFiles() { + for _, f := range kubevip.Files() { p := clusterv1.JSONPatch{ Op: "add", Path: "/spec/template/spec/kubeadmConfigSpec/files/-",