|
9 | 9 | "fmt" |
10 | 10 | "time" |
11 | 11 |
|
| 12 | + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" |
12 | 13 | extensionscontroller "github.com/gardener/gardener/extensions/pkg/controller" |
13 | 14 | "github.com/gardener/gardener/extensions/pkg/controller/dnsrecord" |
14 | 15 | "github.com/gardener/gardener/extensions/pkg/util" |
@@ -52,9 +53,16 @@ func (a *actuator) Reconcile(ctx context.Context, log logr.Logger, dns *extensio |
52 | 53 | return err |
53 | 54 | } |
54 | 55 |
|
55 | | - azCloudConfiguration, err := azureclient.AzureCloudConfiguration(dnsRecordConfig.CloudConfiguration, dns.Spec.Region) |
56 | | - if err != nil { |
57 | | - return err |
| 56 | + var azCloudConfiguration cloud.Configuration |
| 57 | + // Unlike for the other actuators, both of the values used to determine the cloud instance might be nil - usually the region would not be. |
| 58 | + // Default to the public cloud in this case. |
| 59 | + if dnsRecordConfig.CloudConfiguration != nil || dns.Spec.Region != nil { |
| 60 | + azCloudConfiguration, err = azureclient.AzureCloudConfiguration(dnsRecordConfig.CloudConfiguration, dns.Spec.Region) |
| 61 | + if err != nil { |
| 62 | + return err |
| 63 | + } |
| 64 | + } else { |
| 65 | + azCloudConfiguration = cloud.AzurePublic |
58 | 66 | } |
59 | 67 |
|
60 | 68 | clientFactory, err := DefaultAzureClientFactoryFunc( |
@@ -106,10 +114,16 @@ func (a *actuator) Delete(ctx context.Context, log logr.Logger, dns *extensionsv |
106 | 114 | return err |
107 | 115 | } |
108 | 116 |
|
109 | | - azCloudConfiguration, err := azureclient.AzureCloudConfiguration(dnsRecordConfig.CloudConfiguration, dns.Spec.Region) |
110 | | - |
111 | | - if err != nil { |
112 | | - return err |
| 117 | + var azCloudConfiguration cloud.Configuration |
| 118 | + // Unlike for the other actuators, both of the values used to determine the cloud instance might be nil - usually the region would not be. |
| 119 | + // Default to the public cloud in this case. |
| 120 | + if dnsRecordConfig.CloudConfiguration != nil || dns.Spec.Region != nil { |
| 121 | + azCloudConfiguration, err = azureclient.AzureCloudConfiguration(dnsRecordConfig.CloudConfiguration, dns.Spec.Region) |
| 122 | + if err != nil { |
| 123 | + return err |
| 124 | + } |
| 125 | + } else { |
| 126 | + azCloudConfiguration = cloud.AzurePublic |
113 | 127 | } |
114 | 128 |
|
115 | 129 | clientFactory, err := DefaultAzureClientFactoryFunc( |
|
0 commit comments