From 1de87486e8c19d9c37d6c6674ff3e31b627d52a8 Mon Sep 17 00:00:00 2001 From: Shalin Patel Date: Mon, 1 Apr 2024 19:04:52 -0700 Subject: [PATCH 1/5] test: unit test for individual patch generator --- common/go.mod | 4 + common/pkg/testutils/capitest/patches.go | 86 ++++++++++--------- .../aws/mutation/region/patch_test.go | 31 +++++++ .../mutation/region/tests/generate_patches.go | 5 +- 4 files changed, 81 insertions(+), 45 deletions(-) create mode 100644 pkg/handlers/aws/mutation/region/patch_test.go diff --git a/common/go.mod b/common/go.mod index 8c488f21a..9fd75ed65 100644 --- a/common/go.mod +++ b/common/go.mod @@ -11,6 +11,7 @@ require ( github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api v0.0.0-00010101000000-000000000000 github.com/evanphx/json-patch/v5 v5.9.0 github.com/go-logr/logr v1.4.1 + github.com/onsi/ginkgo/v2 v2.15.0 github.com/onsi/gomega v1.31.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 @@ -36,6 +37,7 @@ require ( github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.3 // indirect + github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect @@ -43,6 +45,7 @@ require ( github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect + github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect github.com/google/uuid v1.3.1 // indirect github.com/imdario/mergo v0.3.13 // indirect github.com/josharian/intern v1.0.0 // indirect @@ -69,6 +72,7 @@ require ( golang.org/x/term v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.16.1 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect diff --git a/common/pkg/testutils/capitest/patches.go b/common/pkg/testutils/capitest/patches.go index 43ce653ca..80e27bdff 100644 --- a/common/pkg/testutils/capitest/patches.go +++ b/common/pkg/testutils/capitest/patches.go @@ -7,8 +7,8 @@ import ( "context" "encoding/json" "fmt" - "testing" + . "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" "github.com/onsi/gomega/gstruct" gomegatypes "github.com/onsi/gomega/types" @@ -39,55 +39,57 @@ type JSONPatchMatcher struct { } func ValidateGeneratePatches[T mutation.GeneratePatches]( - t *testing.T, + t GinkgoTInterface, handlerCreator func() T, testDefs ...PatchTestDef, ) { t.Helper() + patchTestFunc := func(tt PatchTestDef) { + g := gomega.NewWithT(t) + h := handlerCreator() + req := &runtimehooksv1.GeneratePatchesRequest{ + Variables: tt.Vars, + Items: []runtimehooksv1.GeneratePatchesRequestItem{ + tt.RequestItem, + { + HolderReference: runtimehooksv1.HolderReference{ + APIVersion: capiv1.GroupVersion.String(), + Kind: "Cluster", + Namespace: request.Namespace, + Name: request.ClusterName, + }, + }, + }, + } + resp := &runtimehooksv1.GeneratePatchesResponse{} + h.GeneratePatches(context.Background(), req, resp) + expectedStatus := runtimehooksv1.ResponseStatusSuccess + if tt.ExpectedFailure { + expectedStatus = runtimehooksv1.ResponseStatusFailure + } + g.Expect(resp.Status). + To(gomega.Equal(expectedStatus), fmt.Sprintf("Message: %s", resp.Message)) + + if len(tt.ExpectedPatchMatchers) == 0 { + g.Expect(resp.Items).To(gomega.BeEmpty()) + return + } + g.Expect(resp.Items).To(containPatches(&tt.RequestItem, tt.ExpectedPatchMatchers...)) + if len(tt.UnexpectedPatchMatchers) > 0 { + g.Expect(resp.Items). + ToNot(containPatches(&tt.RequestItem, tt.UnexpectedPatchMatchers...)) + } + } + + // compose Ginkgo table arguments + // https://onsi.github.io/ginkgo/#table-specs for more details + tableArgs := []interface{}{patchTestFunc} for testIdx := range testDefs { tt := testDefs[testIdx] - - t.Run(tt.Name, func(t *testing.T) { - t.Parallel() - - g := gomega.NewWithT(t) - h := handlerCreator() - req := &runtimehooksv1.GeneratePatchesRequest{ - Variables: tt.Vars, - Items: []runtimehooksv1.GeneratePatchesRequestItem{ - tt.RequestItem, - { - HolderReference: runtimehooksv1.HolderReference{ - APIVersion: capiv1.GroupVersion.String(), - Kind: "Cluster", - Namespace: request.Namespace, - Name: request.ClusterName, - }, - }, - }, - } - resp := &runtimehooksv1.GeneratePatchesResponse{} - h.GeneratePatches(context.Background(), req, resp) - expectedStatus := runtimehooksv1.ResponseStatusSuccess - if tt.ExpectedFailure { - expectedStatus = runtimehooksv1.ResponseStatusFailure - } - g.Expect(resp.Status). - To(gomega.Equal(expectedStatus), fmt.Sprintf("Message: %s", resp.Message)) - - if len(tt.ExpectedPatchMatchers) == 0 { - g.Expect(resp.Items).To(gomega.BeEmpty()) - return - } - g.Expect(resp.Items).To(containPatches(&tt.RequestItem, tt.ExpectedPatchMatchers...)) - - if len(tt.UnexpectedPatchMatchers) > 0 { - g.Expect(resp.Items). - ToNot(containPatches(&tt.RequestItem, tt.UnexpectedPatchMatchers...)) - } - }) + tableArgs = append(tableArgs, Entry(tt.Name, tt)) } + DescribeTable("Patches", tableArgs...) } // VariableWithValue returns a runtimehooksv1.Variable with the passed name and value. diff --git a/pkg/handlers/aws/mutation/region/patch_test.go b/pkg/handlers/aws/mutation/region/patch_test.go new file mode 100644 index 000000000..97fe8e49b --- /dev/null +++ b/pkg/handlers/aws/mutation/region/patch_test.go @@ -0,0 +1,31 @@ +package region + +import ( + "testing" + + "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/v1alpha1" + "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" + regiontests "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/mutation/region/tests" + "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestRegionPatch(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "AWS region patch suite") +} + +var _ = Describe("AWS region patches", func() { + // only add aws region patch + regionPatchGenerator := func() mutation.GeneratePatches { + return mutation.NewMetaGeneratePatchesHandler("", NewPatch()).(mutation.GeneratePatches) + } + regiontests.TestGeneratePatches( + GinkgoT(), + regionPatchGenerator, + clusterconfig.MetaVariableName, + v1alpha1.AWSVariableName, + VariableName, + ) +}) diff --git a/pkg/handlers/aws/mutation/region/tests/generate_patches.go b/pkg/handlers/aws/mutation/region/tests/generate_patches.go index 909d2f5c3..883d603c5 100644 --- a/pkg/handlers/aws/mutation/region/tests/generate_patches.go +++ b/pkg/handlers/aws/mutation/region/tests/generate_patches.go @@ -4,8 +4,7 @@ package tests import ( - "testing" - + . "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" @@ -15,7 +14,7 @@ import ( ) func TestGeneratePatches( - t *testing.T, + t GinkgoTInterface, generatorFunc func() mutation.GeneratePatches, variableName string, variablePath ...string, From 83ee10828bef34b45d1bdc84f722152190ee3af1 Mon Sep 17 00:00:00 2001 From: Shalin Patel Date: Mon, 1 Apr 2024 20:32:32 -0700 Subject: [PATCH 2/5] test: package level unit test for HTTPProxy --- common/pkg/testutils/capitest/patches.go | 8 +-- .../region/{patch_test.go => inject_test.go} | 12 +++-- .../generic/mutation/httpproxy/inject_test.go | 27 ++++++++++ .../httpproxy/tests/generate_patches.go | 5 +- test/helpers/environment.go | 50 +++++++++++++++++++ test/helpers/envtest.go | 3 ++ 6 files changed, 94 insertions(+), 11 deletions(-) rename pkg/handlers/aws/mutation/region/{patch_test.go => inject_test.go} (82%) create mode 100644 test/helpers/environment.go diff --git a/common/pkg/testutils/capitest/patches.go b/common/pkg/testutils/capitest/patches.go index 80e27bdff..fa817d25f 100644 --- a/common/pkg/testutils/capitest/patches.go +++ b/common/pkg/testutils/capitest/patches.go @@ -44,7 +44,7 @@ func ValidateGeneratePatches[T mutation.GeneratePatches]( testDefs ...PatchTestDef, ) { t.Helper() - patchTestFunc := func(tt PatchTestDef) { + testFunc := func(tt *PatchTestDef) { g := gomega.NewWithT(t) h := handlerCreator() req := &runtimehooksv1.GeneratePatchesRequest{ @@ -84,12 +84,12 @@ func ValidateGeneratePatches[T mutation.GeneratePatches]( // compose Ginkgo table arguments // https://onsi.github.io/ginkgo/#table-specs for more details - tableArgs := []interface{}{patchTestFunc} + testArgs := make([]TableEntry, 0, len(testDefs)) for testIdx := range testDefs { tt := testDefs[testIdx] - tableArgs = append(tableArgs, Entry(tt.Name, tt)) + testArgs = append(testArgs, Entry(tt.Name, &tt)) } - DescribeTable("Patches", tableArgs...) + DescribeTable("Patches", testFunc, testArgs) } // VariableWithValue returns a runtimehooksv1.Variable with the passed name and value. diff --git a/pkg/handlers/aws/mutation/region/patch_test.go b/pkg/handlers/aws/mutation/region/inject_test.go similarity index 82% rename from pkg/handlers/aws/mutation/region/patch_test.go rename to pkg/handlers/aws/mutation/region/inject_test.go index 97fe8e49b..40b8d52db 100644 --- a/pkg/handlers/aws/mutation/region/patch_test.go +++ b/pkg/handlers/aws/mutation/region/inject_test.go @@ -1,22 +1,26 @@ +// Copyright 2023 D2iQ, Inc. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + package region import ( "testing" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" regiontests "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/mutation/region/tests" "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" ) func TestRegionPatch(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "AWS region patch suite") + RunSpecs(t, "AWS Region mutator suite") } -var _ = Describe("AWS region patches", func() { +var _ = Describe("Generate AWS Region patches", func() { // only add aws region patch regionPatchGenerator := func() mutation.GeneratePatches { return mutation.NewMetaGeneratePatchesHandler("", NewPatch()).(mutation.GeneratePatches) diff --git a/pkg/handlers/generic/mutation/httpproxy/inject_test.go b/pkg/handlers/generic/mutation/httpproxy/inject_test.go index caae06f15..064765538 100644 --- a/pkg/handlers/generic/mutation/httpproxy/inject_test.go +++ b/pkg/handlers/generic/mutation/httpproxy/inject_test.go @@ -6,9 +6,15 @@ package httpproxy import ( "testing" + . "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" capiv1 "sigs.k8s.io/cluster-api/api/v1beta1" + + "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" + "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" + httpproxy "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/httpproxy/tests" + "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/test/helpers" ) func TestGenerateNoProxy(t *testing.T) { @@ -179,3 +185,24 @@ func TestGenerateNoProxy(t *testing.T) { }) } } + +func TestHTTPProxyPatch(t *testing.T) { + gomega.RegisterFailHandler(Fail) + RunSpecs(t, "HTTP Proxy mutator suite") +} + +var _ = Describe("Generate HTTPProxy Patches", func() { + // only add HTTPProxy patch + httpProxyPatchGenerator := func() mutation.GeneratePatches { + testEnv := helpers.TestEnv + return mutation.NewMetaGeneratePatchesHandler( + "", + NewPatch(testEnv.Client)).(mutation.GeneratePatches) + } + httpproxy.TestGeneratePatches( + GinkgoT(), + httpProxyPatchGenerator, + clusterconfig.MetaVariableName, + VariableName, + ) +}) diff --git a/pkg/handlers/generic/mutation/httpproxy/tests/generate_patches.go b/pkg/handlers/generic/mutation/httpproxy/tests/generate_patches.go index f3b437ed5..302cc96d3 100644 --- a/pkg/handlers/generic/mutation/httpproxy/tests/generate_patches.go +++ b/pkg/handlers/generic/mutation/httpproxy/tests/generate_patches.go @@ -4,8 +4,7 @@ package tests import ( - "testing" - + . "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" "k8s.io/apiserver/pkg/storage/names" runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" @@ -17,7 +16,7 @@ import ( ) func TestGeneratePatches( - t *testing.T, + t GinkgoTInterface, generatorFunc func() mutation.GeneratePatches, variableName string, variablePath ...string, diff --git a/test/helpers/environment.go b/test/helpers/environment.go new file mode 100644 index 000000000..d40ef8c8b --- /dev/null +++ b/test/helpers/environment.go @@ -0,0 +1,50 @@ +// Copyright 2023 D2iQ, Inc. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +package helpers + +import ( + "context" + "time" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "k8s.io/klog/v2" + "k8s.io/klog/v2/textlogger" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/log" +) + +var TestEnv *TestEnvironment + +// Initialize the test environment. BeforeSuite will be only executed if this package is loaded by the test. +var _ = BeforeSuite(func(ctx SpecContext) { + By("Starting test environment") + testEnvConfig := NewTestEnvironmentConfiguration() + var err error + TestEnv, err = testEnvConfig.Build() + if err != nil { + panic(err) + } + go func() { + By("Starting the manager") + defer GinkgoRecover() + Expect(TestEnv.StartManager(ctx)).To(Succeed()) + }() +}, NodeTimeout(60*time.Second)) + +var _ = AfterSuite(func(ctx context.Context) { + Expect(TestEnv.Stop()).To(Succeed()) +}) + +//nolint:gochecknoinits //needed for test initialization +func init() { + klog.InitFlags(nil) + logger := textlogger.NewLogger(textlogger.NewConfig()) + // use klog as the internal logger for this envtest environment. + log.SetLogger(logger) + // additionally force all of the controllers to use the Ginkgo logger. + ctrl.SetLogger(logger) + // add logger for ginkgo + klog.SetOutput(GinkgoWriter) +} diff --git a/test/helpers/envtest.go b/test/helpers/envtest.go index 26257229d..190b8f009 100644 --- a/test/helpers/envtest.go +++ b/test/helpers/envtest.go @@ -137,6 +137,9 @@ func (t *TestEnvironment) StartManager(ctx context.Context) error { // Stop stops the test environment. func (t *TestEnvironment) Stop() error { + if t.cancel != nil { + t.cancel() + } return t.env.Stop() } From 620f02024c35e81f116898dbcee4b919f39f57a5 Mon Sep 17 00:00:00 2001 From: Shalin Patel Date: Tue, 2 Apr 2024 12:14:47 -0700 Subject: [PATCH 3/5] test: fix data race between multiple unit test that use envtest --- test/helpers/environment.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/test/helpers/environment.go b/test/helpers/environment.go index d40ef8c8b..9d0e48263 100644 --- a/test/helpers/environment.go +++ b/test/helpers/environment.go @@ -19,6 +19,17 @@ var TestEnv *TestEnvironment // Initialize the test environment. BeforeSuite will be only executed if this package is loaded by the test. var _ = BeforeSuite(func(ctx SpecContext) { + By("Initialize loggers for testing") + // Uninitialized logger spits stacktrace as warning during test execution + logger := textlogger.NewLogger(textlogger.NewConfig()) + // use klog as the internal logger for this envtest environment. + log.SetLogger(logger) + // additionally force all of the controllers to use the Ginkgo logger. + ctrl.SetLogger(logger) + klog.InitFlags(nil) + // add logger for ginkgo + klog.SetOutput(GinkgoWriter) + By("Starting test environment") testEnvConfig := NewTestEnvironmentConfiguration() var err error @@ -26,8 +37,8 @@ var _ = BeforeSuite(func(ctx SpecContext) { if err != nil { panic(err) } + By("Starting the manager") go func() { - By("Starting the manager") defer GinkgoRecover() Expect(TestEnv.StartManager(ctx)).To(Succeed()) }() @@ -36,15 +47,3 @@ var _ = BeforeSuite(func(ctx SpecContext) { var _ = AfterSuite(func(ctx context.Context) { Expect(TestEnv.Stop()).To(Succeed()) }) - -//nolint:gochecknoinits //needed for test initialization -func init() { - klog.InitFlags(nil) - logger := textlogger.NewLogger(textlogger.NewConfig()) - // use klog as the internal logger for this envtest environment. - log.SetLogger(logger) - // additionally force all of the controllers to use the Ginkgo logger. - ctrl.SetLogger(logger) - // add logger for ginkgo - klog.SetOutput(GinkgoWriter) -} From f3883c398215c29768434046fcff683538d96a8b Mon Sep 17 00:00:00 2001 From: Shalin Patel Date: Tue, 2 Apr 2024 15:33:07 -0700 Subject: [PATCH 4/5] test: make patchgenerator generic function --- pkg/handlers/aws/mutation/region/inject_test.go | 4 ++-- pkg/handlers/generic/mutation/httpproxy/inject_test.go | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/handlers/aws/mutation/region/inject_test.go b/pkg/handlers/aws/mutation/region/inject_test.go index 40b8d52db..4f76e95ea 100644 --- a/pkg/handlers/aws/mutation/region/inject_test.go +++ b/pkg/handlers/aws/mutation/region/inject_test.go @@ -22,12 +22,12 @@ func TestRegionPatch(t *testing.T) { var _ = Describe("Generate AWS Region patches", func() { // only add aws region patch - regionPatchGenerator := func() mutation.GeneratePatches { + patchGenerator := func() mutation.GeneratePatches { return mutation.NewMetaGeneratePatchesHandler("", NewPatch()).(mutation.GeneratePatches) } regiontests.TestGeneratePatches( GinkgoT(), - regionPatchGenerator, + patchGenerator, clusterconfig.MetaVariableName, v1alpha1.AWSVariableName, VariableName, diff --git a/pkg/handlers/generic/mutation/httpproxy/inject_test.go b/pkg/handlers/generic/mutation/httpproxy/inject_test.go index 064765538..13f183394 100644 --- a/pkg/handlers/generic/mutation/httpproxy/inject_test.go +++ b/pkg/handlers/generic/mutation/httpproxy/inject_test.go @@ -193,7 +193,9 @@ func TestHTTPProxyPatch(t *testing.T) { var _ = Describe("Generate HTTPProxy Patches", func() { // only add HTTPProxy patch - httpProxyPatchGenerator := func() mutation.GeneratePatches { + patchGenerator := func() mutation.GeneratePatches { + // Always initialize the testEnv variable in the closure. + // This will allow ginkgo to initialize testEnv variable during test execution time. testEnv := helpers.TestEnv return mutation.NewMetaGeneratePatchesHandler( "", @@ -201,7 +203,7 @@ var _ = Describe("Generate HTTPProxy Patches", func() { } httpproxy.TestGeneratePatches( GinkgoT(), - httpProxyPatchGenerator, + patchGenerator, clusterconfig.MetaVariableName, VariableName, ) From 94ce4f3d8ece94236cc60b412d4b1cf5a75ebba3 Mon Sep 17 00:00:00 2001 From: Shalin Patel Date: Thu, 4 Apr 2024 21:03:36 -0700 Subject: [PATCH 5/5] fix: linting errors after rebase from main --- api/v1alpha1/nutanix_node_types.go | 26 ++++++++++++++----- common/go.sum | 1 - .../generic/lifecycle/ccm/aws/handler.go | 8 +++++- .../tests/generate_patches.go | 1 + 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/api/v1alpha1/nutanix_node_types.go b/api/v1alpha1/nutanix_node_types.go index 1637721fa..8190c395a 100644 --- a/api/v1alpha1/nutanix_node_types.go +++ b/api/v1alpha1/nutanix_node_types.go @@ -80,16 +80,27 @@ func (NutanixMachineDetails) VariableSchema() clusterv1.VariableSchema { Description: "memorySize is the memory size (in Quantity format) of the VM eg. 4Gi", Type: "string", }, - "image": NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema, - "cluster": NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema, - "subnets": NutanixResourceIdentifiers{}.VariableSchema().OpenAPIV3Schema, - "bootType": NutanixBootType(capxv1.NutanixBootTypeLegacy).VariableSchema().OpenAPIV3Schema, + "image": NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema, + "cluster": NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema, + "subnets": NutanixResourceIdentifiers{}.VariableSchema().OpenAPIV3Schema, + "bootType": NutanixBootType( + capxv1.NutanixBootTypeLegacy, + ).VariableSchema(). + OpenAPIV3Schema, "systemDiskSize": { Description: "systemDiskSize is size (in Quantity format) of the system disk of the VM eg. 20Gi", Type: "string", }, }, - Required: []string{"vcpusPerSocket", "vcpuSockets", "memorySize", "image", "cluster", "subnets", "systemDiskSize"}, + Required: []string{ + "vcpusPerSocket", + "vcpuSockets", + "memorySize", + "image", + "cluster", + "subnets", + "systemDiskSize", + }, }, } } @@ -134,7 +145,10 @@ func (NutanixResourceIdentifier) VariableSchema() clusterv1.VariableSchema { Description: "Nutanix Resource Identifier", Type: "object", Properties: map[string]clusterv1.JSONSchemaProps{ - "type": NutanixIdentifierType(capxv1.NutanixIdentifierName).VariableSchema().OpenAPIV3Schema, + "type": NutanixIdentifierType( + capxv1.NutanixIdentifierName, + ).VariableSchema(). + OpenAPIV3Schema, "uuid": { Type: "string", Description: "uuid is the UUID of the resource in the PC.", diff --git a/common/go.sum b/common/go.sum index a705598aa..d6c26d887 100644 --- a/common/go.sum +++ b/common/go.sum @@ -365,7 +365,6 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= -github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= diff --git a/pkg/handlers/generic/lifecycle/ccm/aws/handler.go b/pkg/handlers/generic/lifecycle/ccm/aws/handler.go index c9f34ebfc..fa37fd1db 100644 --- a/pkg/handlers/generic/lifecycle/ccm/aws/handler.go +++ b/pkg/handlers/generic/lifecycle/ccm/aws/handler.go @@ -96,7 +96,13 @@ func (a *AWSCCM) Apply( ) } - err = lifecycleutils.EnsureCRSForClusterFromObjects(ctx, ccmConfigMap.Name, a.client, cluster, ccmConfigMap) + err = lifecycleutils.EnsureCRSForClusterFromObjects( + ctx, + ccmConfigMap.Name, + a.client, + cluster, + ccmConfigMap, + ) if err != nil { return fmt.Errorf("failed to generate CCM CRS for cluster: %w", err) } diff --git a/pkg/handlers/nutanix/mutation/prismcentralendpoint/tests/generate_patches.go b/pkg/handlers/nutanix/mutation/prismcentralendpoint/tests/generate_patches.go index 4ae6c6243..0b9003fc1 100644 --- a/pkg/handlers/nutanix/mutation/prismcentralendpoint/tests/generate_patches.go +++ b/pkg/handlers/nutanix/mutation/prismcentralendpoint/tests/generate_patches.go @@ -17,6 +17,7 @@ import ( "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest/request" ) +// //nolint:lll // just a long string const testCertBundle = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVjekNDQTF1Z0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRUUZBRC4uQWtHQTFVRUJoTUNSMEl4CkV6QVJCZ05WQkFnVENsTnZiV1V0VTNSaGRHVXhGREFTQmdOVkJBb1RDMC4uMEVnVEhSa01UY3dOUVlEClZRUUxFeTVEYkdGemN5QXhJRkIxWW14cFl5QlFjbWx0WVhKNUlFTmxjbi4uWFJwYjI0Z1FYVjBhRzl5CmFYUjVNUlF3RWdZRFZRUURFd3RDWlhOMElFTkJJRXgwWkRBZUZ3MHdNRC4uVFV3TVRaYUZ3MHdNVEF5Ck1EUXhPVFV3TVRaYU1JR0hNUXN3Q1FZRFZRUUdFd0pIUWpFVE1CRUdBMS4uMjl0WlMxVGRHRjBaVEVVCk1CSUdBMVVFQ2hNTF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