Skip to content

Commit

Permalink
fixup! refactor: Satisfy pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson committed Mar 19, 2024
1 parent 9955adb commit c22b9e2
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ patches:
generateExtension: "nutanixworkerconfigpatch.capi-runtime-extensions"
discoverVariablesExtension: "nutanixworkerconfigvars.capi-runtime-extensions"
- op: "remove"
path: "/spec/variables"
path: "/spec/variables"
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ patches:
value:
cni:
provider: Calico
strategy: HelmAddon
strategy: HelmAddon
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ patches:
value:
cni:
provider: Cilium
strategy: ClusterResourceSet
strategy: ClusterResourceSet
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ patches:
value:
cni:
provider: Cilium
strategy: HelmAddon
strategy: HelmAddon
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ kind: Kustomization

resources:
- ../../../base/nutanix/clusterclass

2 changes: 1 addition & 1 deletion hack/examples/overlays/nutanix/kustomization.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ patches:
generateExtension: "nutanixworkerconfigpatch.capi-runtime-extensions"
discoverVariablesExtension: "nutanixworkerconfigvars.capi-runtime-extensions"
- op: "remove"
path: "/spec/variables"
path: "/spec/variables"
16 changes: 7 additions & 9 deletions hack/examples/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
11 changes: 8 additions & 3 deletions pkg/handlers/nutanix/mutation/machinedetails/inject_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions pkg/handlers/nutanix/mutation/metapatch_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 (
Expand Down

0 comments on commit c22b9e2

Please sign in to comment.