github.com/ironcore-dev/gardener-extension-provider-ironcore@v0.3.2-0.20240314231816-8336447fb9a0/pkg/apis/ironcore/validation/controlplane_test.go (about) 1 // SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and IronCore contributors 2 // SPDX-License-Identifier: Apache-2.0 3 4 package validation 5 6 import ( 7 . "github.com/onsi/ginkgo/v2" 8 . "github.com/onsi/gomega" 9 . "github.com/onsi/gomega/gstruct" 10 "k8s.io/apimachinery/pkg/util/validation/field" 11 12 apisironcore "github.com/ironcore-dev/gardener-extension-provider-ironcore/pkg/apis/ironcore" 13 ) 14 15 var _ = Describe("ControlPlaneConfig validation", func() { 16 var ( 17 controlPlane *apisironcore.ControlPlaneConfig 18 fldPath *field.Path 19 ) 20 21 BeforeEach(func() { 22 controlPlane = &apisironcore.ControlPlaneConfig{} 23 }) 24 25 Describe("#ValidateControlPlaneConfig", func() { 26 It("should return no errors for a valid configuration", func() { 27 Expect(ValidateControlPlaneConfig(controlPlane, "", fldPath)).To(BeEmpty()) 28 }) 29 30 It("should fail with invalid CCM feature gates", func() { 31 controlPlane.CloudControllerManager = &apisironcore.CloudControllerManagerConfig{ 32 FeatureGates: map[string]bool{ 33 "AnyVolumeDataSource": true, 34 "CustomResourceValidation": true, 35 "Foo": true, 36 }, 37 } 38 39 errorList := ValidateControlPlaneConfig(controlPlane, "1.18.14", fldPath) 40 41 Expect(errorList).To(ConsistOf( 42 PointTo(MatchFields(IgnoreExtras, Fields{ 43 "Type": Equal(field.ErrorTypeInvalid), 44 "Field": Equal("cloudControllerManager.featureGates.CustomResourceValidation"), 45 })), 46 PointTo(MatchFields(IgnoreExtras, Fields{ 47 "Type": Equal(field.ErrorTypeInvalid), 48 "Field": Equal("cloudControllerManager.featureGates.Foo"), 49 })), 50 )) 51 }) 52 }) 53 54 Describe("#ValidateControlPlaneConfigUpdate", func() { 55 It("should return no errors for an unchanged config", func() { 56 Expect(ValidateControlPlaneConfigUpdate(controlPlane, controlPlane, fldPath)).To(BeEmpty()) 57 }) 58 }) 59 })