diff --git a/go.mod b/go.mod index 2db2c6f45..6cc2b283d 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/d2iq-labs/capi-runtime-extensions/api v0.0.0-00010101000000-000000000000 github.com/d2iq-labs/capi-runtime-extensions/common v0.0.0-00010101000000-000000000000 github.com/go-logr/logr v1.4.1 + github.com/nutanix-cloud-native/prism-go-client v0.3.4 github.com/onsi/ginkgo/v2 v2.16.0 github.com/onsi/gomega v1.31.1 github.com/spf13/pflag v1.0.5 @@ -94,7 +95,6 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/nutanix-cloud-native/prism-go-client v0.3.4 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc5 // indirect github.com/pelletier/go-toml v1.9.5 // indirect diff --git a/hack/examples/base/nutanix/clusterclass/kustomization.yaml.tmpl b/hack/examples/base/nutanix/clusterclass/kustomization.yaml.tmpl index 57f359351..dbfe1cc93 100644 --- a/hack/examples/base/nutanix/clusterclass/kustomization.yaml.tmpl +++ b/hack/examples/base/nutanix/clusterclass/kustomization.yaml.tmpl @@ -31,4 +31,4 @@ patches: generateExtension: "nutanixworkerconfigpatch.capi-runtime-extensions" discoverVariablesExtension: "nutanixworkerconfigvars.capi-runtime-extensions" - op: "remove" - path: "/spec/variables" \ No newline at end of file + path: "/spec/variables" diff --git a/hack/examples/overlays/nutanix/calico/helm-addon/kustomization.yaml.tmpl b/hack/examples/overlays/nutanix/calico/helm-addon/kustomization.yaml.tmpl index f1a0754c9..42e297c40 100644 --- a/hack/examples/overlays/nutanix/calico/helm-addon/kustomization.yaml.tmpl +++ b/hack/examples/overlays/nutanix/calico/helm-addon/kustomization.yaml.tmpl @@ -17,4 +17,4 @@ patches: value: cni: provider: Calico - strategy: HelmAddon \ No newline at end of file + strategy: HelmAddon diff --git a/hack/examples/overlays/nutanix/cilium/crs/kustomization.yaml.tmpl b/hack/examples/overlays/nutanix/cilium/crs/kustomization.yaml.tmpl index 3bab17d02..c1ce1bb3e 100644 --- a/hack/examples/overlays/nutanix/cilium/crs/kustomization.yaml.tmpl +++ b/hack/examples/overlays/nutanix/cilium/crs/kustomization.yaml.tmpl @@ -17,4 +17,4 @@ patches: value: cni: provider: Cilium - strategy: ClusterResourceSet \ No newline at end of file + strategy: ClusterResourceSet diff --git a/hack/examples/overlays/nutanix/cilium/helm-addon/kustomization.yaml.tmpl b/hack/examples/overlays/nutanix/cilium/helm-addon/kustomization.yaml.tmpl index 1e1f2f6d3..2036d9700 100644 --- a/hack/examples/overlays/nutanix/cilium/helm-addon/kustomization.yaml.tmpl +++ b/hack/examples/overlays/nutanix/cilium/helm-addon/kustomization.yaml.tmpl @@ -17,4 +17,4 @@ patches: value: cni: provider: Cilium - strategy: HelmAddon \ No newline at end of file + strategy: HelmAddon diff --git a/hack/examples/overlays/nutanix/clusterclass/kustomization.yaml.tmpl b/hack/examples/overlays/nutanix/clusterclass/kustomization.yaml.tmpl index 6a26d6ebd..f108b031d 100644 --- a/hack/examples/overlays/nutanix/clusterclass/kustomization.yaml.tmpl +++ b/hack/examples/overlays/nutanix/clusterclass/kustomization.yaml.tmpl @@ -6,4 +6,3 @@ kind: Kustomization resources: - ../../../base/nutanix/clusterclass - diff --git a/hack/examples/overlays/nutanix/kustomization.yaml.tmpl b/hack/examples/overlays/nutanix/kustomization.yaml.tmpl index fd0030ee7..943283714 100644 --- a/hack/examples/overlays/nutanix/kustomization.yaml.tmpl +++ b/hack/examples/overlays/nutanix/kustomization.yaml.tmpl @@ -129,4 +129,4 @@ patches: generateExtension: "nutanixworkerconfigpatch.capi-runtime-extensions" discoverVariablesExtension: "nutanixworkerconfigvars.capi-runtime-extensions" - op: "remove" - path: "/spec/variables" \ No newline at end of file + path: "/spec/variables" diff --git a/hack/examples/sync.sh b/hack/examples/sync.sh index 409beae9d..71f6418e7 100755 --- a/hack/examples/sync.sh +++ b/hack/examples/sync.sh @@ -20,12 +20,11 @@ readonly EXAMPLE_CLUSTERS_DIR=examples/capi-quick-start mkdir -p "${EXAMPLE_CLUSTERS_DIR}" # build nutanix overlays -kustomize build ./hack/examples/overlays/nutanix/clusterclass > "${EXAMPLE_CLUSTERCLASSES_DIR}/nutanix-cluster-class.yaml" -kustomize build ./hack/examples/overlays/nutanix/calico/crs > "${EXAMPLE_CLUSTERS_DIR}/nutanix-cluster-calico-crs.yaml" -kustomize build ./hack/examples/overlays/nutanix/calico/helm-addon > "${EXAMPLE_CLUSTERS_DIR}/nutanix-cluster-calico-helm-addon.yaml" -kustomize build ./hack/examples/overlays/nutanix/cilium/crs > "${EXAMPLE_CLUSTERS_DIR}/nutanix-cluster-cilium-crs.yaml" -kustomize build ./hack/examples/overlays/nutanix/cilium/helm-addon > "${EXAMPLE_CLUSTERS_DIR}/nutanix-cluster-cilium-helm-addon.yaml" - +kustomize build ./hack/examples/overlays/nutanix/clusterclass >"${EXAMPLE_CLUSTERCLASSES_DIR}/nutanix-cluster-class.yaml" +kustomize build ./hack/examples/overlays/nutanix/calico/crs >"${EXAMPLE_CLUSTERS_DIR}/nutanix-cluster-calico-crs.yaml" +kustomize build ./hack/examples/overlays/nutanix/calico/helm-addon >"${EXAMPLE_CLUSTERS_DIR}/nutanix-cluster-calico-helm-addon.yaml" +kustomize build ./hack/examples/overlays/nutanix/cilium/crs >"${EXAMPLE_CLUSTERS_DIR}/nutanix-cluster-cilium-crs.yaml" +kustomize build ./hack/examples/overlays/nutanix/cilium/helm-addon >"${EXAMPLE_CLUSTERS_DIR}/nutanix-cluster-cilium-helm-addon.yaml" # Sync ClusterClasses (including Templates) and Clusters to separate files. kustomize build ./hack/examples | @@ -104,10 +103,9 @@ kustomize build ./hack/examples | ) \ >/dev/null -#shellcheck disable=SC2016 # TODO: deepakm-ntnx this is affecting examples of nutanix where there are 2 secrets gets same name -sed -i'' 's/^ name: .\+$/ name: ${CLUSTER_NAME}/' "${EXAMPLE_CLUSTERS_DIR}"/aws*.yaml -sed -i'' 's/^ name: .\+$/ name: ${CLUSTER_NAME}/' "${EXAMPLE_CLUSTERS_DIR}"/docker*.yaml +#shellcheck disable=SC2016 +sed -i'' 's/^ name: .\+$/ name: ${CLUSTER_NAME}/' "${EXAMPLE_CLUSTERS_DIR}"/aws*.yaml "${EXAMPLE_CLUSTERS_DIR}"/docker*.yaml # TODO Remove once kustomize supports retaining quotes in what will be numeric values. #shellcheck disable=SC2016 diff --git a/pkg/handlers/nutanix/mutation/machinedetails/inject_control_plane.go b/pkg/handlers/nutanix/mutation/machinedetails/inject_control_plane.go index 33ace1c8d..9eee6038a 100644 --- a/pkg/handlers/nutanix/mutation/machinedetails/inject_control_plane.go +++ b/pkg/handlers/nutanix/mutation/machinedetails/inject_control_plane.go @@ -128,9 +128,14 @@ func (h *nutanixMachineDetailsControlPlanePatchHandler) Mutate( nutanixMachineDetailsVar.SystemDiskSize, ) - subnets := make([]capxv1.NutanixResourceIdentifier, len(nutanixMachineDetailsVar.Subnets)) + subnets := make( + []capxv1.NutanixResourceIdentifier, + len(nutanixMachineDetailsVar.Subnets), + ) for _, subnetCRE := range nutanixMachineDetailsVar.Subnets { - subnet := capxv1.NutanixResourceIdentifier{Type: capxv1.NutanixIdentifierType(subnetCRE.Type)} + subnet := capxv1.NutanixResourceIdentifier{ + Type: capxv1.NutanixIdentifierType(subnetCRE.Type), + } if subnetCRE.Type == v1alpha1.NutanixIdentifierName { subnet.Name = subnetCRE.Name } else { @@ -140,7 +145,7 @@ func (h *nutanixMachineDetailsControlPlanePatchHandler) Mutate( } obj.Spec.Template.Spec.Subnets = subnets - // TODO + // TODO Update project, categories, and GPUs. // obj.Spec.Template.Spec.Project = nutanixMachineDetailsVar.Project // obj.Spec.Template.Spec.AdditionalCategories = nutanixMachineDetailsVar.AdditionalCategories // obj.Spec.Template.Spec.GPUs = nutanixMachineDetailsVar.GPUs diff --git a/pkg/handlers/nutanix/mutation/machinedetails/inject_worker.go b/pkg/handlers/nutanix/mutation/machinedetails/inject_worker.go index 2601774c4..c26464b32 100644 --- a/pkg/handlers/nutanix/mutation/machinedetails/inject_worker.go +++ b/pkg/handlers/nutanix/mutation/machinedetails/inject_worker.go @@ -122,9 +122,14 @@ func (h *nutanixMachineDetailsWorkerPatchHandler) Mutate( nutanixMachineDetailsVar.SystemDiskSize, ) - subnets := make([]capxv1.NutanixResourceIdentifier, len(nutanixMachineDetailsVar.Subnets)) + subnets := make( + []capxv1.NutanixResourceIdentifier, + len(nutanixMachineDetailsVar.Subnets), + ) for _, subnetCRE := range nutanixMachineDetailsVar.Subnets { - subnet := capxv1.NutanixResourceIdentifier{Type: capxv1.NutanixIdentifierType(subnetCRE.Type)} + subnet := capxv1.NutanixResourceIdentifier{ + Type: capxv1.NutanixIdentifierType(subnetCRE.Type), + } if subnetCRE.Type == v1alpha1.NutanixIdentifierName { subnet.Name = subnetCRE.Name } else { @@ -134,7 +139,7 @@ func (h *nutanixMachineDetailsWorkerPatchHandler) Mutate( } obj.Spec.Template.Spec.Subnets = subnets - // TODO + // TODO Update project, categories, and GPUs. // obj.Spec.Template.Spec.Project = nutanixMachineDetailsVar.Project // obj.Spec.Template.Spec.AdditionalCategories = nutanixMachineDetailsVar.AdditionalCategories // obj.Spec.Template.Spec.GPUs = nutanixMachineDetailsVar.GPUs diff --git a/pkg/handlers/nutanix/mutation/metapatch_handler_test.go b/pkg/handlers/nutanix/mutation/metapatch_handler_test.go index efb58a888..a64816ca9 100644 --- a/pkg/handlers/nutanix/mutation/metapatch_handler_test.go +++ b/pkg/handlers/nutanix/mutation/metapatch_handler_test.go @@ -36,11 +36,11 @@ func metaPatchGeneratorFunc(mgr manager.Manager) func() mutation.GeneratePatches } } -func workerPatchGeneratorFunc() func() mutation.GeneratePatches { - return func() mutation.GeneratePatches { - return MetaWorkerPatchHandler().(mutation.GeneratePatches) - } -} +// func workerPatchGeneratorFunc() func() mutation.GeneratePatches { +// return func() mutation.GeneratePatches { +// return MetaWorkerPatchHandler().(mutation.GeneratePatches) +// } +// } func TestGeneratePatches(t *testing.T) { t.Parallel() diff --git a/pkg/handlers/nutanix/mutation/prismcentralendpoint/inject.go b/pkg/handlers/nutanix/mutation/prismcentralendpoint/inject.go index 2de854972..d07c05f06 100644 --- a/pkg/handlers/nutanix/mutation/prismcentralendpoint/inject.go +++ b/pkg/handlers/nutanix/mutation/prismcentralendpoint/inject.go @@ -6,6 +6,7 @@ package prismcentralendpoint import ( "context" + "github.com/nutanix-cloud-native/prism-go-client/environment/credentials" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" @@ -18,7 +19,6 @@ import ( "github.com/d2iq-labs/capi-runtime-extensions/common/pkg/capi/clustertopology/patches/selectors" "github.com/d2iq-labs/capi-runtime-extensions/common/pkg/capi/clustertopology/variables" "github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/generic/clusterconfig" - "github.com/nutanix-cloud-native/prism-go-client/environment/credentials" ) const (