Skip to content

Commit

Permalink
fix(azure) sovereign cloud support
Browse files Browse the repository at this point in the history
Signed-off-by: jbpaux <[email protected]>
  • Loading branch information
jbpaux committed Sep 15, 2023
1 parent bfe50a9 commit 91cae9b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
15 changes: 13 additions & 2 deletions provider/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (

log "github.com/sirupsen/logrus"

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
azcoreruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
dns "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns"
Expand Down Expand Up @@ -74,11 +76,20 @@ func NewAzureProvider(configFile string, domainFilter endpoint.DomainFilter, zon
if err != nil {
return nil, fmt.Errorf("failed to get credentials: %w", err)
}
zonesClient, err := dns.NewZonesClient(cfg.SubscriptionID, cred, nil)
cloudCfg, err := getCloudConfiguration(cfg.Cloud)
if err != nil {
return nil, fmt.Errorf("failed to get cloud configuration: %w", err)
}
opts := &arm.ClientOptions{
ClientOptions: azcore.ClientOptions{
Cloud: cloudCfg,
},
}
zonesClient, err := dns.NewZonesClient(cfg.SubscriptionID, cred, opts)
if err != nil {
return nil, err
}
recordSetsClient, err := dns.NewRecordSetsClient(cfg.SubscriptionID, cred, nil)
recordSetsClient, err := dns.NewRecordSetsClient(cfg.SubscriptionID, cred, opts)
if err != nil {
return nil, err
}
Expand Down
15 changes: 13 additions & 2 deletions provider/azure/azure_private_dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"fmt"
"strings"

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
azcoreruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
privatedns "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns"
Expand Down Expand Up @@ -68,11 +70,20 @@ func NewAzurePrivateDNSProvider(configFile string, domainFilter endpoint.DomainF
if err != nil {
return nil, fmt.Errorf("failed to get credentials: %w", err)
}
zonesClient, err := privatedns.NewPrivateZonesClient(cfg.SubscriptionID, cred, nil)
cloudCfg, err := getCloudConfiguration(cfg.Cloud)
if err != nil {
return nil, fmt.Errorf("failed to get cloud configuration: %w", err)
}
opts := &arm.ClientOptions{
ClientOptions: azcore.ClientOptions{
Cloud: cloudCfg,
},
}
zonesClient, err := privatedns.NewPrivateZonesClient(cfg.SubscriptionID, cred, opts)
if err != nil {
return nil, err
}
recordSetsClient, err := privatedns.NewRecordSetsClient(cfg.SubscriptionID, cred, nil)
recordSetsClient, err := privatedns.NewRecordSetsClient(cfg.SubscriptionID, cred, opts)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 91cae9b

Please sign in to comment.