Skip to content

Commit

Permalink
Improvement DNS provider registration (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
shibayan authored May 31, 2022
1 parent e48e6b4 commit 6e35913
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions KeyVault.Acmebot/Internal/DnsProvidersExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public static async Task<IReadOnlyList<DnsZone>> ListAllZonesAsync(this IEnumera
return zones.SelectMany(x => x).ToArray();
}

public static void TryAdd(this IList<IDnsProvider> dnsProviders, object options, Func<IDnsProvider> factory)
public static void TryAdd<TOption>(this IList<IDnsProvider> dnsProviders, TOption options, Func<TOption, IDnsProvider> factory)
{
if (options is not null)
{
dnsProviders.Add(factory());
dnsProviders.Add(factory(options));
}
}
}
18 changes: 9 additions & 9 deletions KeyVault.Acmebot/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ public override void Configure(IFunctionsHostBuilder builder)

var dnsProviders = new List<IDnsProvider>();

dnsProviders.TryAdd(options.AzureDns, () => new AzureDnsProvider(options.AzureDns, environment));
dnsProviders.TryAdd(options.Cloudflare, () => new CloudflareProvider(options.Cloudflare));
dnsProviders.TryAdd(options.CustomDns, () => new CustomDnsProvider(options.CustomDns));
dnsProviders.TryAdd(options.DnsMadeEasy, () => new DnsMadeEasyProvider(options.DnsMadeEasy));
dnsProviders.TryAdd(options.Gandi, () => new GandiProvider(options.Gandi));
dnsProviders.TryAdd(options.GoDaddy, () => new GoDaddyProvider(options.GoDaddy));
dnsProviders.TryAdd(options.GoogleDns, () => new GoogleDnsProvider(options.GoogleDns));
dnsProviders.TryAdd(options.Route53, () => new Route53Provider(options.Route53));
dnsProviders.TryAdd(options.TransIp, () => new TransIpProvider(options, options.TransIp, environment));
dnsProviders.TryAdd(options.AzureDns, o => new AzureDnsProvider(o, environment));
dnsProviders.TryAdd(options.Cloudflare, o => new CloudflareProvider(o));
dnsProviders.TryAdd(options.CustomDns, o => new CustomDnsProvider(o));
dnsProviders.TryAdd(options.DnsMadeEasy, o => new DnsMadeEasyProvider(o));
dnsProviders.TryAdd(options.Gandi, o => new GandiProvider(o));
dnsProviders.TryAdd(options.GoDaddy, o => new GoDaddyProvider(o));
dnsProviders.TryAdd(options.GoogleDns, o => new GoogleDnsProvider(o));
dnsProviders.TryAdd(options.Route53, o => new Route53Provider(o));
dnsProviders.TryAdd(options.TransIp, o => new TransIpProvider(options, o, environment));

if (dnsProviders.Count == 0)
{
Expand Down
8 changes: 8 additions & 0 deletions KeyVault.Acmebot/wwwroot/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=/dashboard">
</head>
<body>
</body>
</html>

0 comments on commit 6e35913

Please sign in to comment.