From 701225e576e51083346e10cb718ce5057f491d30 Mon Sep 17 00:00:00 2001 From: Bohdan Siryk Date: Wed, 21 Feb 2024 16:45:18 +0200 Subject: [PATCH] dev --- apis/clusters/v1beta1/generic_spec.go | 2 +- pkg/models/apiv2_generic.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apis/clusters/v1beta1/generic_spec.go b/apis/clusters/v1beta1/generic_spec.go index f7f9502c8..45d52fe43 100644 --- a/apis/clusters/v1beta1/generic_spec.go +++ b/apis/clusters/v1beta1/generic_spec.go @@ -209,7 +209,7 @@ func (s *GenericDataCentreSpec) cloudProviderSettingsFromInstAPI(instaModel *mod } switch { - case len(instaModel.AWSSettings) > 0: + case len(instaModel.AWSSettings) > 0 && instaModel.HasAWSCloudProviderSettings(): setting := instaModel.AWSSettings[0] s.AWSSettings = []*AWSSettings{{ DiskEncryptionKey: setting.EBSEncryptionKey, diff --git a/pkg/models/apiv2_generic.go b/pkg/models/apiv2_generic.go index e7ea9c85c..465296044 100644 --- a/pkg/models/apiv2_generic.go +++ b/pkg/models/apiv2_generic.go @@ -25,3 +25,18 @@ type GenericDataCentreFields struct { *CloudProviderSettings `json:",inline"` } + +func (dc *CloudProviderSettings) HasAWSCloudProviderSettings() bool { + if dc == nil { + return false + } + + zero := AWSSetting{} + for _, s := range dc.AWSSettings { + if *s == zero { + return false + } + } + + return true +}