Skip to content

Commit

Permalink
Rename option with --rfc2136-create-ptr, similar to infoblox option
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloxx committed Feb 25, 2024
1 parent 940899b commit b083e34
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/tutorials/rfc2136.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ tutorial and are covered in the main documentation.

### Generate reverse DNS records

If you want to generate reverse DNS records for your services, you have to enable the functionality using the `--rfc2136-manageptr`
If you want to generate reverse DNS records for your services, you have to enable the functionality using the `--rfc2136-create-ptr`
flag. You have also to add the zone to the list of zones managed by ExternalDNS via the `--rfc2136-zone` and `--domain-filter` flags.
An example of a valid configuration is the following:

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func main() {
p, err = oci.NewOCIProvider(*config, domainFilter, zoneIDFilter, cfg.OCIZoneScope, cfg.DryRun)
}
case "rfc2136":
p, err = rfc2136.NewRfc2136Provider(cfg.RFC2136Host, cfg.RFC2136Port, cfg.RFC2136Zone, cfg.RFC2136Insecure, cfg.RFC2136TSIGKeyName, cfg.RFC2136TSIGSecret, cfg.RFC2136TSIGSecretAlg, cfg.RFC2136TAXFR, domainFilter, cfg.DryRun, cfg.RFC2136MinTTL, cfg.RFC2136ManagePTR, cfg.RFC2136GSSTSIG, cfg.RFC2136KerberosUsername, cfg.RFC2136KerberosPassword, cfg.RFC2136KerberosRealm, cfg.RFC2136BatchChangeSize, nil)
p, err = rfc2136.NewRfc2136Provider(cfg.RFC2136Host, cfg.RFC2136Port, cfg.RFC2136Zone, cfg.RFC2136Insecure, cfg.RFC2136TSIGKeyName, cfg.RFC2136TSIGSecret, cfg.RFC2136TSIGSecretAlg, cfg.RFC2136TAXFR, domainFilter, cfg.DryRun, cfg.RFC2136MinTTL, cfg.RFC2136CreatePTR, cfg.RFC2136GSSTSIG, cfg.RFC2136KerberosUsername, cfg.RFC2136KerberosPassword, cfg.RFC2136KerberosRealm, cfg.RFC2136BatchChangeSize, nil)
case "ns1":
p, err = ns1.NewNS1Provider(
ns1.NS1Config{
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/externaldns/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ type Config struct {
RFC2136Zone []string
RFC2136Insecure bool
RFC2136GSSTSIG bool
RFC2136ManagePTR bool
RFC2136CreatePTR bool
RFC2136KerberosRealm string
RFC2136KerberosUsername string
RFC2136KerberosPassword string `secure:"yes"`
Expand Down Expand Up @@ -580,7 +580,7 @@ func (cfg *Config) ParseFlags(args []string) error {
app.Flag("rfc2136-host", "When using the RFC2136 provider, specify the host of the DNS server").Default(defaultConfig.RFC2136Host).StringVar(&cfg.RFC2136Host)
app.Flag("rfc2136-port", "When using the RFC2136 provider, specify the port of the DNS server").Default(strconv.Itoa(defaultConfig.RFC2136Port)).IntVar(&cfg.RFC2136Port)
app.Flag("rfc2136-zone", "When using the RFC2136 provider, specify zone entries of the DNS server to use").StringsVar(&cfg.RFC2136Zone)
app.Flag("rfc2136-manageptr", "When using the RFC2136 provider, enable PTR management").Default(strconv.FormatBool(defaultConfig.RFC2136ManagePTR)).BoolVar(&cfg.RFC2136ManagePTR)
app.Flag("rfc2136-create-ptr", "When using the RFC2136 provider, enable PTR management").Default(strconv.FormatBool(defaultConfig.RFC2136CreatePTR)).BoolVar(&cfg.RFC2136CreatePTR)
app.Flag("rfc2136-insecure", "When using the RFC2136 provider, specify whether to attach TSIG or not (default: false, requires --rfc2136-tsig-keyname and rfc2136-tsig-secret)").Default(strconv.FormatBool(defaultConfig.RFC2136Insecure)).BoolVar(&cfg.RFC2136Insecure)
app.Flag("rfc2136-tsig-keyname", "When using the RFC2136 provider, specify the TSIG key to attached to DNS messages (required when --rfc2136-insecure=false)").Default(defaultConfig.RFC2136TSIGKeyName).StringVar(&cfg.RFC2136TSIGKeyName)
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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/externaldns/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func TestValidateBadRfc2136Config(t *testing.T) {
cfg.Sources = []string{"test-source"}
cfg.Provider = "rfc2136"
cfg.RFC2136MinTTL = -1
cfg.ManagePTR = false
cfg.CreatePTR = false
cfg.RFC2136BatchChangeSize = 50

err := ValidateConfig(cfg)
Expand Down
10 changes: 5 additions & 5 deletions provider/rfc2136/rfc2136.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type rfc2136Provider struct {
axfr bool
minTTL time.Duration
batchChangeSize int
managePTR bool
createPTR bool

// options specific to rfc3645 gss-tsig support
gssTsig bool
Expand Down Expand Up @@ -83,7 +83,7 @@ type rfc2136Actions interface {
}

// NewRfc2136Provider is a factory function for OpenStack rfc2136 providers
func NewRfc2136Provider(host string, port int, zoneNames []string, insecure bool, keyName string, secret string, secretAlg string, axfr bool, domainFilter endpoint.DomainFilter, dryRun bool, minTTL time.Duration, managePTR bool, gssTsig bool, krb5Username string, krb5Password string, krb5Realm string, batchChangeSize int, actions rfc2136Actions) (provider.Provider, error) {
func NewRfc2136Provider(host string, port int, zoneNames []string, insecure bool, keyName string, secret string, secretAlg string, axfr bool, domainFilter endpoint.DomainFilter, dryRun bool, minTTL time.Duration, createPTR bool, gssTsig bool, krb5Username string, krb5Password string, krb5Realm string, batchChangeSize int, actions rfc2136Actions) (provider.Provider, error) {
secretAlgChecked, ok := tsigAlgs[secretAlg]
if !ok && !insecure && !gssTsig {
return nil, errors.Errorf("%s is not supported TSIG algorithm", secretAlg)
Expand All @@ -104,7 +104,7 @@ func NewRfc2136Provider(host string, port int, zoneNames []string, insecure bool
zoneNames: zoneNames,
insecure: insecure,
gssTsig: gssTsig,
managePTR: managePTR,
createPTR: createPTR,
krb5Username: krb5Username,
krb5Password: krb5Password,
krb5Realm: strings.ToUpper(krb5Realm),
Expand Down Expand Up @@ -308,7 +308,7 @@ func (r rfc2136Provider) ApplyChanges(ctx context.Context, changes *plan.Changes
m[zone].SetUpdate(zone)
r.AddRecord(m[zone], ep)

if r.managePTR && (ep.RecordType == "A" || ep.RecordType == "AAAA") {
if r.createPTR && (ep.RecordType == "A" || ep.RecordType == "AAAA") {
r.AddReverseRecord(ep.Targets[0], ep.DNSName)
}
}
Expand Down Expand Up @@ -380,7 +380,7 @@ func (r rfc2136Provider) ApplyChanges(ctx context.Context, changes *plan.Changes
m[zone].SetUpdate(zone)

r.RemoveRecord(m[zone], ep)
if r.managePTR && (ep.RecordType == "A" || ep.RecordType == "AAAA") {
if r.createPTR && (ep.RecordType == "A" || ep.RecordType == "AAAA") {
r.RemoveReverseRecord(ep.Targets[0], ep.DNSName)
}
}
Expand Down

0 comments on commit b083e34

Please sign in to comment.