2019-08-09 12:40:28 +05:30
|
|
|
package azure
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
"strconv"
|
2019-08-09 12:40:28 +05:30
|
|
|
"strings"
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
"time"
|
2019-08-09 12:40:28 +05:30
|
|
|
|
2020-09-24 18:14:41 +02:00
|
|
|
"github.com/coredns/caddy"
|
2019-08-09 12:40:28 +05:30
|
|
|
"github.com/coredns/coredns/core/dnsserver"
|
|
|
|
|
"github.com/coredns/coredns/plugin"
|
|
|
|
|
"github.com/coredns/coredns/plugin/pkg/fall"
|
|
|
|
|
clog "github.com/coredns/coredns/plugin/pkg/log"
|
|
|
|
|
|
2020-03-11 00:52:23 +05:30
|
|
|
publicAzureDNS "github.com/Azure/azure-sdk-for-go/profiles/latest/dns/mgmt/dns"
|
|
|
|
|
privateAzureDNS "github.com/Azure/azure-sdk-for-go/profiles/latest/privatedns/mgmt/privatedns"
|
2019-08-09 12:40:28 +05:30
|
|
|
azurerest "github.com/Azure/go-autorest/autorest/azure"
|
|
|
|
|
"github.com/Azure/go-autorest/autorest/azure/auth"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var log = clog.NewWithPlugin("azure")
|
|
|
|
|
|
2019-09-20 08:02:30 +01:00
|
|
|
func init() { plugin.Register("azure", setup) }
|
2019-08-09 12:40:28 +05:30
|
|
|
|
|
|
|
|
func setup(c *caddy.Controller) error {
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
env, keys, accessMap, fall, refresh, err := parse(c)
|
2019-08-09 12:40:28 +05:30
|
|
|
if err != nil {
|
|
|
|
|
return plugin.Error("azure", err)
|
|
|
|
|
}
|
2020-10-24 05:37:01 -07:00
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
2019-08-09 16:10:26 +01:00
|
|
|
|
2020-03-11 00:52:23 +05:30
|
|
|
publicDNSClient := publicAzureDNS.NewRecordSetsClient(env.Values[auth.SubscriptionID])
|
|
|
|
|
if publicDNSClient.Authorizer, err = env.GetAuthorizer(); err != nil {
|
2022-07-10 20:06:33 +02:00
|
|
|
cancel()
|
2019-08-09 16:10:26 +01:00
|
|
|
return plugin.Error("azure", err)
|
2019-08-09 12:40:28 +05:30
|
|
|
}
|
2019-08-09 16:10:26 +01:00
|
|
|
|
2020-03-11 00:52:23 +05:30
|
|
|
privateDNSClient := privateAzureDNS.NewRecordSetsClient(env.Values[auth.SubscriptionID])
|
|
|
|
|
if privateDNSClient.Authorizer, err = env.GetAuthorizer(); err != nil {
|
2022-07-10 20:06:33 +02:00
|
|
|
cancel()
|
2020-03-11 00:52:23 +05:30
|
|
|
return plugin.Error("azure", err)
|
|
|
|
|
}
|
|
|
|
|
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
h, err := New(ctx, publicDNSClient, privateDNSClient, keys, accessMap, refresh)
|
2019-08-09 12:40:28 +05:30
|
|
|
if err != nil {
|
2022-07-10 20:06:33 +02:00
|
|
|
cancel()
|
2019-08-09 16:10:26 +01:00
|
|
|
return plugin.Error("azure", err)
|
2019-08-09 12:40:28 +05:30
|
|
|
}
|
|
|
|
|
h.Fall = fall
|
2019-08-09 16:10:26 +01:00
|
|
|
|
2019-08-09 12:40:28 +05:30
|
|
|
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
|
|
|
|
|
h.Next = next
|
|
|
|
|
return h
|
|
|
|
|
})
|
2026-09-11 11:54:12 +08:00
|
|
|
c.OnStartup(func() error { return h.Run(ctx) })
|
|
|
|
|
c.OnShutdown(func() error {
|
|
|
|
|
cancel()
|
|
|
|
|
h.updates.Wait()
|
|
|
|
|
return nil
|
|
|
|
|
})
|
2019-08-09 12:40:28 +05:30
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
func parse(c *caddy.Controller) (auth.EnvironmentSettings, map[string][]string, map[string]string, fall.F, time.Duration, error) {
|
2019-08-09 12:40:28 +05:30
|
|
|
resourceGroupMapping := map[string][]string{}
|
2020-03-11 00:52:23 +05:30
|
|
|
accessMap := map[string]string{}
|
2019-08-09 12:40:28 +05:30
|
|
|
resourceGroupSet := map[string]struct{}{}
|
|
|
|
|
azureEnv := azurerest.PublicCloud
|
|
|
|
|
env := auth.EnvironmentSettings{Values: map[string]string{}}
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
refresh := time.Duration(1) * time.Minute // default update frequency to 1 minute
|
2019-08-09 12:40:28 +05:30
|
|
|
|
2019-08-09 16:10:26 +01:00
|
|
|
var fall fall.F
|
2020-03-11 00:52:23 +05:30
|
|
|
var access string
|
2019-08-09 16:10:26 +01:00
|
|
|
|
2019-08-09 12:40:28 +05:30
|
|
|
for c.Next() {
|
|
|
|
|
args := c.RemainingArgs()
|
2026-05-20 23:06:37 +08:00
|
|
|
var currentZoneKeys []string
|
2019-08-09 12:40:28 +05:30
|
|
|
|
2025-05-29 03:50:55 +03:00
|
|
|
for i := range args {
|
2019-08-09 12:40:28 +05:30
|
|
|
parts := strings.SplitN(args[i], ":", 2)
|
|
|
|
|
if len(parts) != 2 {
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.Errf("invalid resource group/zone: %q", args[i])
|
2019-08-09 12:40:28 +05:30
|
|
|
}
|
2026-05-20 23:06:37 +08:00
|
|
|
resourceGroup, zoneName := parts[0], parts[1]
|
2019-08-09 12:40:28 +05:30
|
|
|
if resourceGroup == "" || zoneName == "" {
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.Errf("invalid resource group/zone: %q", args[i])
|
2019-08-09 12:40:28 +05:30
|
|
|
}
|
2020-03-11 00:52:23 +05:30
|
|
|
if _, ok := resourceGroupSet[resourceGroup+zoneName]; ok {
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.Errf("conflicting zone: %q", args[i])
|
2019-08-09 12:40:28 +05:30
|
|
|
}
|
|
|
|
|
|
2020-03-11 00:52:23 +05:30
|
|
|
resourceGroupSet[resourceGroup+zoneName] = struct{}{}
|
|
|
|
|
accessMap[resourceGroup+zoneName] = "public"
|
2026-05-20 23:06:37 +08:00
|
|
|
currentZoneKeys = append(currentZoneKeys, resourceGroup+zoneName)
|
2019-08-09 12:40:28 +05:30
|
|
|
resourceGroupMapping[resourceGroup] = append(resourceGroupMapping[resourceGroup], zoneName)
|
|
|
|
|
}
|
2020-03-11 00:52:23 +05:30
|
|
|
|
2019-08-09 12:40:28 +05:30
|
|
|
for c.NextBlock() {
|
|
|
|
|
switch c.Val() {
|
|
|
|
|
case "subscription":
|
|
|
|
|
if !c.NextArg() {
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.ArgErr()
|
2019-08-09 12:40:28 +05:30
|
|
|
}
|
|
|
|
|
env.Values[auth.SubscriptionID] = c.Val()
|
|
|
|
|
case "tenant":
|
|
|
|
|
if !c.NextArg() {
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.ArgErr()
|
2019-08-09 12:40:28 +05:30
|
|
|
}
|
|
|
|
|
env.Values[auth.TenantID] = c.Val()
|
|
|
|
|
case "client":
|
|
|
|
|
if !c.NextArg() {
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.ArgErr()
|
2019-08-09 12:40:28 +05:30
|
|
|
}
|
|
|
|
|
env.Values[auth.ClientID] = c.Val()
|
|
|
|
|
case "secret":
|
|
|
|
|
if !c.NextArg() {
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.ArgErr()
|
2019-08-09 12:40:28 +05:30
|
|
|
}
|
|
|
|
|
env.Values[auth.ClientSecret] = c.Val()
|
|
|
|
|
case "environment":
|
|
|
|
|
if !c.NextArg() {
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.ArgErr()
|
2019-08-09 12:40:28 +05:30
|
|
|
}
|
2019-08-09 16:10:26 +01:00
|
|
|
var err error
|
|
|
|
|
if azureEnv, err = azurerest.EnvironmentFromName(c.Val()); err != nil {
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.Errf("cannot set azure environment: %q", err.Error())
|
2019-08-09 12:40:28 +05:30
|
|
|
}
|
|
|
|
|
case "fallthrough":
|
|
|
|
|
fall.SetZonesFromArgs(c.RemainingArgs())
|
2020-03-11 00:52:23 +05:30
|
|
|
case "access":
|
|
|
|
|
if !c.NextArg() {
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.ArgErr()
|
2020-03-11 00:52:23 +05:30
|
|
|
}
|
|
|
|
|
access = c.Val()
|
|
|
|
|
if access != "public" && access != "private" {
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.Errf("invalid access value: can be public/private, found: %s", access)
|
2020-03-11 00:52:23 +05:30
|
|
|
}
|
2026-05-20 23:06:37 +08:00
|
|
|
for _, k := range currentZoneKeys {
|
|
|
|
|
accessMap[k] = access
|
|
|
|
|
}
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
case "refresh":
|
|
|
|
|
if !c.NextArg() {
|
|
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.ArgErr()
|
|
|
|
|
}
|
|
|
|
|
refreshStr := c.Val()
|
|
|
|
|
_, err := strconv.Atoi(refreshStr)
|
|
|
|
|
if err == nil {
|
|
|
|
|
refreshStr += "s"
|
|
|
|
|
}
|
|
|
|
|
refresh, err = time.ParseDuration(refreshStr)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.Errf("unable to parse duration: %v", err)
|
|
|
|
|
}
|
|
|
|
|
if refresh <= 0 {
|
|
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.Errf("refresh interval must be greater than 0: %q", refreshStr)
|
|
|
|
|
}
|
2019-08-09 12:40:28 +05:30
|
|
|
default:
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, c.Errf("unknown property: %q", c.Val())
|
2019-08-09 12:40:28 +05:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-09 16:10:26 +01:00
|
|
|
|
2019-08-09 12:40:28 +05:30
|
|
|
env.Values[auth.Resource] = azureEnv.ResourceManagerEndpoint
|
|
|
|
|
env.Environment = azureEnv
|
plugin/azure: add refresh directive (#8614)
Brings azure to parity with route53, which already exposes a refresh
directive to control how often zones are re-synced. azure currently
hardcodes this to 1 minute (Run calls h.run(ctx, time.Minute)) with no
way to change it, even though the internal run() method already takes
an arbitrary interval parameter - the plumbing exists, it just wasn't
exposed as a Corefile option.
Adds a refresh field to the Azure struct, threads it through New(), and
has Run() use h.refresh instead of the hardcoded value. Parses the
refresh directive in parse() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).
Extends TestSetup with refresh coverage (valid duration, valid plain
number, missing arg, non-numeric, zero, negative). Verified it fails
without the setup.go change (unknown property error) and passes with
it.
Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
2026-10-09 07:18:10 +05:30
|
|
|
return env, resourceGroupMapping, accessMap, fall, refresh, nil
|
2019-08-09 12:40:28 +05:30
|
|
|
}
|