mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-11-01 19:21:00 +01:00
Updated minTTL variable type from int64 to Duration
This commit is contained in:
parent
b6111b9768
commit
21275c9aa0
2
main.go
2
main.go
@ -240,7 +240,7 @@ func main() {
|
||||
p, err = provider.NewOCIProvider(*config, domainFilter, zoneIDFilter, cfg.DryRun)
|
||||
}
|
||||
case "rfc2136":
|
||||
p, err = provider.NewRfc2136Provider(cfg.RFC2136Host, cfg.RFC2136Port, cfg.RFC2136Zone, cfg.RFC2136Insecure, cfg.RFC2136TSIGKeyName, cfg.RFC2136TSIGSecret, cfg.RFC2136TSIGSecretAlg, cfg.RFC2136TAXFR, domainFilter, cfg.DryRun, cfg.RFC2136MinTTLSeconds, nil)
|
||||
p, err = provider.NewRfc2136Provider(cfg.RFC2136Host, cfg.RFC2136Port, cfg.RFC2136Zone, cfg.RFC2136Insecure, cfg.RFC2136TSIGKeyName, cfg.RFC2136TSIGSecret, cfg.RFC2136TSIGSecretAlg, cfg.RFC2136TAXFR, domainFilter, cfg.DryRun, cfg.RFC2136MinTTL, nil)
|
||||
case "ns1":
|
||||
p, err = provider.NewNS1Provider(
|
||||
provider.NS1Config{
|
||||
|
||||
@ -130,7 +130,7 @@ type Config struct {
|
||||
RFC2136TSIGSecret string `secure:"yes"`
|
||||
RFC2136TSIGSecretAlg string
|
||||
RFC2136TAXFR bool
|
||||
RFC2136MinTTLSeconds int64
|
||||
RFC2136MinTTL time.Duration
|
||||
NS1Endpoint string
|
||||
NS1IgnoreSSL bool
|
||||
TransIPAccountName string
|
||||
@ -224,7 +224,7 @@ var defaultConfig = &Config{
|
||||
RFC2136TSIGSecret: "",
|
||||
RFC2136TSIGSecretAlg: "",
|
||||
RFC2136TAXFR: true,
|
||||
RFC2136MinTTLSeconds: 0,
|
||||
RFC2136MinTTL: 0,
|
||||
NS1Endpoint: "",
|
||||
NS1IgnoreSSL: false,
|
||||
TransIPAccountName: "",
|
||||
@ -368,7 +368,7 @@ func (cfg *Config) ParseFlags(args []string) error {
|
||||
app.Flag("rfc2136-tsig-secret", "When using the RFC2136 provider, specify the TSIG (base64) value to attached to DNS messages (required when --rfc2136-insecure=false)").Default(defaultConfig.RFC2136TSIGSecret).StringVar(&cfg.RFC2136TSIGSecret)
|
||||
app.Flag("rfc2136-tsig-secret-alg", "When using the RFC2136 provider, specify the TSIG (base64) value to attached to DNS messages (required when --rfc2136-insecure=false)").Default(defaultConfig.RFC2136TSIGSecretAlg).StringVar(&cfg.RFC2136TSIGSecretAlg)
|
||||
app.Flag("rfc2136-tsig-axfr", "When using the RFC2136 provider, specify the TSIG (base64) value to attached to DNS messages (required when --rfc2136-insecure=false)").BoolVar(&cfg.RFC2136TAXFR)
|
||||
app.Flag("rfc2136-min-ttl", "When using the RFC2136 provider, specify minimal TTL (in seconds) for records. This value will be used if the provided TTL for a service/ingress is lower than this").Default(strconv.FormatInt(defaultConfig.RFC2136MinTTLSeconds, 10)).Int64Var(&cfg.RFC2136MinTTLSeconds)
|
||||
app.Flag("rfc2136-min-ttl", "When using the RFC2136 provider, specify minimal TTL (in duration format) for records. This value will be used if the provided TTL for a service/ingress is lower than this").Default(defaultConfig.RFC2136MinTTL.String()).DurationVar(&cfg.RFC2136MinTTL)
|
||||
|
||||
// Flags related to TransIP provider
|
||||
app.Flag("transip-account", "When using the TransIP provider, specify the account name (required when --provider=transip)").Default(defaultConfig.TransIPAccountName).StringVar(&cfg.TransIPAccountName)
|
||||
|
||||
@ -83,7 +83,7 @@ func ValidateConfig(cfg *externaldns.Config) error {
|
||||
}
|
||||
|
||||
if cfg.Provider == "rfc2136" {
|
||||
if cfg.RFC2136MinTTLSeconds < 0 {
|
||||
if cfg.RFC2136MinTTL < 0 {
|
||||
return errors.New("TTL specified for rfc2136 is negative")
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ func TestValidateBadRfc2136Config(t *testing.T) {
|
||||
cfg.LogFormat = "json"
|
||||
cfg.Sources = []string{"test-source"}
|
||||
cfg.Provider = "rfc2136"
|
||||
cfg.RFC2136MinTTLSeconds = -1
|
||||
cfg.RFC2136MinTTL = -1
|
||||
|
||||
err := ValidateConfig(cfg)
|
||||
|
||||
@ -144,7 +144,7 @@ func TestValidateGoodRfc2136Config(t *testing.T) {
|
||||
cfg.LogFormat = "json"
|
||||
cfg.Sources = []string{"test-source"}
|
||||
cfg.Provider = "rfc2136"
|
||||
cfg.RFC2136MinTTLSeconds = 3600
|
||||
cfg.RFC2136MinTTL = 3600
|
||||
|
||||
err := ValidateConfig(cfg)
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ type rfc2136Provider struct {
|
||||
tsigSecretAlg string
|
||||
insecure bool
|
||||
axfr bool
|
||||
minTTLSeconds int64
|
||||
minTTL time.Duration
|
||||
|
||||
// only consider hosted zones managing domains ending in this suffix
|
||||
domainFilter DomainFilter
|
||||
@ -65,20 +65,20 @@ type rfc2136Actions interface {
|
||||
}
|
||||
|
||||
// NewRfc2136Provider is a factory function for OpenStack rfc2136 providers
|
||||
func NewRfc2136Provider(host string, port int, zoneName string, insecure bool, keyName string, secret string, secretAlg string, axfr bool, domainFilter DomainFilter, dryRun bool, minTTLSeconds int64, actions rfc2136Actions) (Provider, error) {
|
||||
func NewRfc2136Provider(host string, port int, zoneName string, insecure bool, keyName string, secret string, secretAlg string, axfr bool, domainFilter DomainFilter, dryRun bool, minTTL time.Duration, actions rfc2136Actions) (Provider, error) {
|
||||
secretAlgChecked, ok := tsigAlgs[secretAlg]
|
||||
if !ok && !insecure {
|
||||
return nil, errors.Errorf("%s is not supported TSIG algorithm", secretAlg)
|
||||
}
|
||||
|
||||
r := &rfc2136Provider{
|
||||
nameserver: net.JoinHostPort(host, strconv.Itoa(port)),
|
||||
zoneName: dns.Fqdn(zoneName),
|
||||
insecure: insecure,
|
||||
domainFilter: domainFilter,
|
||||
dryRun: dryRun,
|
||||
axfr: axfr,
|
||||
minTTLSeconds: minTTLSeconds,
|
||||
nameserver: net.JoinHostPort(host, strconv.Itoa(port)),
|
||||
zoneName: dns.Fqdn(zoneName),
|
||||
insecure: insecure,
|
||||
domainFilter: domainFilter,
|
||||
dryRun: dryRun,
|
||||
axfr: axfr,
|
||||
minTTL: minTTL,
|
||||
}
|
||||
if actions != nil {
|
||||
r.actions = actions
|
||||
@ -256,7 +256,7 @@ func (r rfc2136Provider) UpdateRecord(m *dns.Msg, ep *endpoint.Endpoint) error {
|
||||
func (r rfc2136Provider) AddRecord(m *dns.Msg, ep *endpoint.Endpoint) error {
|
||||
log.Debugf("AddRecord.ep=%s", ep)
|
||||
|
||||
var ttl = r.minTTLSeconds
|
||||
var ttl = int64(r.minTTL.Seconds())
|
||||
if ep.RecordTTL.IsConfigured() && int64(ep.RecordTTL) > ttl {
|
||||
ttl = int64(ep.RecordTTL)
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -93,7 +94,7 @@ func (r *rfc2136Stub) IncomeTransfer(m *dns.Msg, a string) (env chan *dns.Envelo
|
||||
}
|
||||
|
||||
func createRfc2136StubProvider(stub *rfc2136Stub) (Provider, error) {
|
||||
return NewRfc2136Provider("", 0, "", false, "key", "secret", "hmac-sha512", true, DomainFilter{}, false, 300, stub)
|
||||
return NewRfc2136Provider("", 0, "", false, "key", "secret", "hmac-sha512", true, DomainFilter{}, false, 300*time.Second, stub)
|
||||
}
|
||||
|
||||
func extractAuthoritySectionFromMessage(msg fmt.Stringer) []string {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user