Skip to content

Commit

Permalink
Fix aws client issue
Browse files Browse the repository at this point in the history
Signed-off-by: rasel <[email protected]>
  • Loading branch information
Superm4n97 committed Apr 15, 2024
1 parent d749168 commit 402a1ed
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 37 deletions.
7 changes: 0 additions & 7 deletions apis/external/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions apis/external/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions crds/external-dns.appscode.com_externaldnses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ spec:
required:
- name
type: object
zonesPerPage:
description: 'When using the Cloudflare provider, specify how
many zones per page listed, max. possible 50 (default: 50)'
type: integer
type: object
connectorSourceServer:
description: The server to connect for connector source, valid only
Expand Down
56 changes: 35 additions & 21 deletions pkg/plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import (

api "kubeops.dev/external-dns-operator/apis/external/v1alpha1"

"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/route53"
sd "github.com/aws/aws-sdk-go/service/servicediscovery"
"github.com/sirupsen/logrus"
"gomodules.xyz/sets"
"k8s.io/apimachinery/pkg/labels"
Expand All @@ -46,7 +49,6 @@ import (
"sigs.k8s.io/external-dns/provider/digitalocean"
"sigs.k8s.io/external-dns/provider/dnsimple"
"sigs.k8s.io/external-dns/provider/dyn"
"sigs.k8s.io/external-dns/provider/exoscale"
"sigs.k8s.io/external-dns/provider/gandi"
"sigs.k8s.io/external-dns/provider/godaddy"
"sigs.k8s.io/external-dns/provider/google"
Expand Down Expand Up @@ -220,7 +222,7 @@ func SetDNSRecords(ctx context.Context, edns *api.ExternalDNS) ([]api.DNSRecord,
return nil, err
}

reg, err := createRegistry(cfg, *pvdr)
reg, err := createRegistry(cfg, pvdr)
if err != nil {
klog.Errorf("failed to create Registry.", err.Error())

Check failure on line 227 in pkg/plan/plan.go

View workflow job for this annotation

GitHub Actions / Build

printf: k8s.io/klog/v2.Errorf call has arguments but no formatting directives (govet)
return nil, err
Expand Down Expand Up @@ -588,7 +590,7 @@ func createEndpointsSource(ctx context.Context, cfg *externaldns.Config) (source
return endpointsSource, nil
}

func createProviderFromCfg(ctx context.Context, cfg *externaldns.Config, endpointsSource source.Source) (*provider.Provider, error) {
func createProviderFromCfg(ctx context.Context, cfg *externaldns.Config, endpointsSource source.Source) (provider.Provider, error) {
var p provider.Provider
var err error

Expand All @@ -604,6 +606,20 @@ func createProviderFromCfg(ctx context.Context, cfg *externaldns.Config, endpoin
zoneTypeFilter := provider.NewZoneTypeFilter(cfg.AWSZoneType)
zoneTagFilter := provider.NewZoneTagFilter(cfg.AWSZoneTagFilter)

var awsSession *session.Session
if cfg.Provider == "aws" || cfg.Provider == "aws-sd" {
awsSession, err = aws.NewSession(
aws.AWSSessionConfig{
AssumeRole: cfg.AWSAssumeRole,
AssumeRoleExternalID: cfg.AWSAssumeRoleExternalID,
APIRetries: cfg.AWSAPIRetries,
},
)
if err != nil {
log.Fatal(err)
}
}

switch cfg.Provider {
case "akamai":
p, err = akamai.NewAkamaiProvider(
Expand All @@ -623,27 +639,27 @@ func createProviderFromCfg(ctx context.Context, cfg *externaldns.Config, endpoin
case "aws":
p, err = aws.NewAWSProvider(
aws.AWSConfig{
DomainFilter: domainFilter,
ZoneIDFilter: zoneIDFilter,
ZoneTypeFilter: zoneTypeFilter,
ZoneTagFilter: zoneTagFilter,
BatchChangeSize: cfg.AWSBatchChangeSize,
BatchChangeInterval: cfg.AWSBatchChangeInterval,
EvaluateTargetHealth: cfg.AWSEvaluateTargetHealth,
// FIX
// AssumeRole: cfg.AWSAssumeRole,
// APIRetries: cfg.AWSAPIRetries,
PreferCNAME: cfg.AWSPreferCNAME,
DryRun: cfg.DryRun,
ZoneCacheDuration: cfg.AWSZoneCacheDuration,
DomainFilter: domainFilter,
ZoneIDFilter: zoneIDFilter,
ZoneTypeFilter: zoneTypeFilter,
ZoneTagFilter: zoneTagFilter,
ZoneMatchParent: cfg.AWSZoneMatchParent,
BatchChangeSize: cfg.AWSBatchChangeSize,
BatchChangeSizeBytes: cfg.AWSBatchChangeSizeBytes,
BatchChangeSizeValues: cfg.AWSBatchChangeSizeValues,
BatchChangeInterval: cfg.AWSBatchChangeInterval,
EvaluateTargetHealth: cfg.AWSEvaluateTargetHealth,
PreferCNAME: cfg.AWSPreferCNAME,
DryRun: cfg.DryRun,
ZoneCacheDuration: cfg.AWSZoneCacheDuration,
},
nil, // FIX
route53.New(awsSession),
)
case providerAWSSD:
if cfg.Registry != "noop" && cfg.Registry != providerAWSSD {
cfg.Registry = providerAWSSD
}
p, err = awssd.NewAWSSDProvider(domainFilter, cfg.AWSZoneType, cfg.DryRun, cfg.AWSSDServiceCleanup, cfg.TXTOwnerID /* FIX */, nil)
p, err = awssd.NewAWSSDProvider(domainFilter, cfg.AWSZoneType, cfg.DryRun, cfg.AWSSDServiceCleanup, cfg.TXTOwnerID, sd.New(awsSession))
case "azure-dns", "azure":
p, err = azure.NewAzureProvider(cfg.AzureConfigFile, domainFilter, zoneNameFilter, zoneIDFilter, "FIX -- subscriptionID", cfg.AzureResourceGroup, cfg.AzureUserAssignedIdentityClientID, cfg.DryRun)
case "azure-private-dns":
Expand Down Expand Up @@ -711,8 +727,6 @@ func createProviderFromCfg(ctx context.Context, cfg *externaldns.Config, endpoin
DryRun: cfg.DryRun,
},
)
case "exoscale":
p, err = exoscale.NewExoscaleProvider(cfg.ExoscaleAPIEnvironment, cfg.ExoscaleAPIZone, cfg.ExoscaleAPIKey, cfg.ExoscaleAPISecret, cfg.DryRun, exoscale.ExoscaleWithDomain(domainFilter), exoscale.ExoscaleWithLogging()), nil
case "inmemory":
p, err = inmemory.NewInMemoryProvider(inmemory.InMemoryInitZones(cfg.InMemoryZones), inmemory.InMemoryWithDomain(domainFilter), inmemory.InMemoryWithLogging()), nil
case "designate":
Expand Down Expand Up @@ -767,7 +781,7 @@ func createProviderFromCfg(ctx context.Context, cfg *externaldns.Config, endpoin
log.Fatalf("unknown dns provider: %s", cfg.Provider)
}

return &p, err
return p, err
}

func createRegistry(cfg *externaldns.Config, p provider.Provider) (registry.Registry, error) {
Expand Down

0 comments on commit 402a1ed

Please sign in to comment.