dnscontrol icon indicating copy to clipboard operation
dnscontrol copied to clipboard

FEATURE REQUEST: Override NO_PURGE with ENSURE_ABSENT()

Open tlimoncelli opened this issue 2 years ago • 4 comments

NO_PURGE is used to "share" a zone with someone else by not deleting any records that are not recognized. Currently if you really want to delete something you have to manually remove it. It would be nice to have a way to delete something despite the use of NO_PURGE.

Proposed syntax:

D("example.com", REG_FOO,
    NO_PURGE,
    ENSURE_ABSENT(A("myname", "1.2.3.4"))
)
  • When PURGE is activated, the ENSURE_ABSENT() record is ignored, as if it is commented out.
  • When NO_PURGE is activated, the ENSURE_ABSENT() record is deleted.

Other notes:

  • The TTL is not considered when comparing records.
  • For providers that don't support this, a warning should be emitted.

Tom

tlimoncelli avatar Feb 09 '23 22:02 tlimoncelli

@tlimoncelli Does this allow deleting all A records for a specific name, or does each A record and the relevant target IP need to be specified?

Yannik avatar Feb 22 '23 12:02 Yannik

Each has to be listed. I was going to match the rec.GetLabel(), rec.Type, and rec.GetTargetField(); but not TTL or other fields like the MX priority.

tlimoncelli avatar Feb 22 '23 14:02 tlimoncelli

I personally don't have any need for this functionality, but allowing to match only on getLabel and rec.Type might make this feature more useful.

Yannik avatar Feb 22 '23 18:02 Yannik

Yeah, I can see that. Right now the use case is that if you had an existing record in dnsconfig.js, you can just wrap ENSURE_ABSENT( old_record ) around it and be assured it is deleted. Adding the functionality you describe later won't be too difficult

Of course, right now I'm in a situation where I don't know enough Javascript to get the syntax working. It works as:

A(x, y, ENSURE_ABSENT_REC())

But I can't figure out how to have it as a wrapper:

ENSURE_ABSENT(A(x, y))

(I hope you agree the 2nd one is a lot nicer!)

tlimoncelli avatar Feb 22 '23 19:02 tlimoncelli