Skip to content

Commit

Permalink
use constants for key values
Browse files Browse the repository at this point in the history
  • Loading branch information
defo89 committed Dec 20, 2024
1 parent 4d156a6 commit 8024e98
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion pkg/apis/metal/validation/controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package validation

import (
featurevalidation "github.com/gardener/gardener/pkg/utils/validation/features"
"github.com/ironcore-dev/gardener-extension-provider-metal/pkg/metal"
"k8s.io/apimachinery/pkg/util/validation/field"

apismetal "github.com/ironcore-dev/gardener-extension-provider-metal/pkg/apis/metal"
Expand All @@ -15,7 +16,7 @@ func ValidateControlPlaneConfig(controlPlaneConfig *apismetal.ControlPlaneConfig
allErrs := field.ErrorList{}

if controlPlaneConfig.CloudControllerManager != nil {
allErrs = append(allErrs, featurevalidation.ValidateFeatureGates(controlPlaneConfig.CloudControllerManager.FeatureGates, version, fldPath.Child("cloudControllerManager", "featureGates"))...)
allErrs = append(allErrs, featurevalidation.ValidateFeatureGates(controlPlaneConfig.CloudControllerManager.FeatureGates, version, fldPath.Child("cloudControllerManager", metal.CloudControllerManagerFeatureGatesKeyName))...)
}

// TODO add validation for IPs
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/controlplane/valuesprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ func getCCMChartValues(
}

if cpConfig.CloudControllerManager != nil {
values["featureGates"] = cpConfig.CloudControllerManager.FeatureGates
values[metal.CloudControllerManagerFeatureGatesKeyName] = cpConfig.CloudControllerManager.FeatureGates
if cpConfig.CloudControllerManager.CloudControllerNetworking != nil {
values["networking"] = map[string]any{
"configureNodeAddresses": cpConfig.CloudControllerManager.CloudControllerNetworking.ConfigureNodeAddresses,
values[metal.CloudControllerManagerNetworkingKeyName] = map[string]any{
metal.CloudControllerManagerNodeAddressesConfigKeyName: cpConfig.CloudControllerManager.CloudControllerNetworking.ConfigureNodeAddresses,
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/controller/controlplane/valuesprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ var _ = Describe("Valueprovider Reconcile", func() {
cloudProviderConfig := map[string]any{}
Expect(yaml.Unmarshal([]byte(config.Data["cloudprovider.conf"]), &cloudProviderConfig)).NotTo(HaveOccurred())
Expect(cloudProviderConfig["clusterName"]).To(Equal(cluster.Name))
networkingConfig, ok := cloudProviderConfig["networking"].(map[string]any)
networkingConfig, ok := cloudProviderConfig[metal.CloudControllerManagerNetworkingKeyName].(map[string]any)
Expect(ok).To(BeTrue())
Expect(networkingConfig["configureNodeAddresses"]).To(BeTrue())
Expect(networkingConfig[metal.CloudControllerManagerNodeAddressesConfigKeyName]).To(BeTrue())
})
})

Expand Down Expand Up @@ -212,7 +212,7 @@ var _ = Describe("Valueprovider Reconcile", func() {
"secrets": map[string]any{
"server": "cloud-controller-manager-server",
},
"featureGates": map[string]bool{
metal.CloudControllerManagerFeatureGatesKeyName: map[string]bool{
"CustomResourceValidation": true,
},
"podNetwork": "10.0.0.0/16",
Expand Down Expand Up @@ -333,11 +333,11 @@ var _ = Describe("Valueprovider Reconcile", func() {
"secrets": map[string]any{
"server": "cloud-controller-manager-server",
},
"featureGates": map[string]bool{
metal.CloudControllerManagerFeatureGatesKeyName: map[string]bool{
"CustomResourceValidation": true,
},
"networking": map[string]any{
"configureNodeAddresses": false,
metal.CloudControllerManagerNetworkingKeyName: map[string]any{
metal.CloudControllerManagerNodeAddressesConfigKeyName: false,
},
"podNetwork": "10.0.0.0/16",
"configureCloudRoutes": true,
Expand Down
6 changes: 6 additions & 0 deletions pkg/metal/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ const (
CloudProviderConfigName = "cloud-provider-config"
// CloudControllerManagerName is a constant for the name of the CloudController deployed by the worker controller.
CloudControllerManagerName = "cloud-controller-manager"
// CloudControllerManagerFeatureGatesKeyName is the key name for the feature gates key in CCM configuration
CloudControllerManagerFeatureGatesKeyName = "featureGates"
// CloudControllerManagerNetworkingKeyName is the key name for the networking key in CCM configuration
CloudControllerManagerNetworkingKeyName = "networking"
// CloudControllerManagerNodeAddressesConfigKeyName is the key name for the networking key in CCM configuration
CloudControllerManagerNodeAddressesConfigKeyName = "configureNodeAddresses"
// CalicoBgpName is a constant for the name of the Calico BGP deployed by the worker controller.
CalicoBgpName = "calico-bgp"
// MetallbName is a constant for the name of the MetalLB deployed by the worker controller.
Expand Down

0 comments on commit 8024e98

Please sign in to comment.