Skip to content

Commit

Permalink
remove provider store and don't initialize each DNS provider (#96)
Browse files Browse the repository at this point in the history
* fix(dnsprovider): do not always initialize each DNS provider

* fix(dnsprovider): fix unnecessary error return value

* ref(dnsprovider): drop the store and use a simple switch for lookup
  • Loading branch information
linki authored Mar 16, 2017
1 parent aacec39 commit 8170947
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 136 deletions.
6 changes: 4 additions & 2 deletions dnsprovider/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ func NewGoogleProvider(project string, dryRun bool) (DNSProvider, error) {
return nil, err
}

return &googleProvider{
provider := &googleProvider{
project: project,
dryRun: dryRun,
resourceRecordSetsClient: resourceRecordSetsService{dnsClient.ResourceRecordSets},
managedZonesClient: managedZonesService{dnsClient.ManagedZones},
changesClient: changesService{dnsClient.Changes},
}, nil
}

return provider, nil
}

// Zones returns the list of hosted zones.
Expand Down
38 changes: 0 additions & 38 deletions dnsprovider/store.go

This file was deleted.

87 changes: 0 additions & 87 deletions dnsprovider/store_test.go

This file was deleted.

18 changes: 9 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,23 @@ func main() {

sources := source.NewMultiSource(source.LookupMultiple(cfg.Sources...)...)

googleProvider, err := dnsprovider.NewGoogleProvider(cfg.GoogleProject, cfg.DryRun)
if err != nil {
log.Fatal(err)
var provider dnsprovider.DNSProvider
switch cfg.DNSProvider {
case "google":
provider, err = dnsprovider.NewGoogleProvider(cfg.GoogleProject, cfg.DryRun)
case "aws":
provider, err = dnsprovider.NewAWSProvider(cfg.DryRun)
default:
log.Fatalf("unknown dns provider: %s", cfg.DNSProvider)
}

awsProvider, err := dnsprovider.NewAWSProvider(cfg.DryRun)
if err != nil {
log.Fatal(err)
}

dnsprovider.Register("google", googleProvider)
dnsprovider.Register("aws", awsProvider)

ctrl := controller.Controller{
Zone: cfg.Zone,
Source: sources,
DNSProvider: dnsprovider.Lookup(cfg.DNSProvider),
DNSProvider: provider,
}

if cfg.Once {
Expand Down

0 comments on commit 8170947

Please sign in to comment.