Disable records instead of deleting them

A disabled record stays in Jarl with its ID, TTL and comment but is
left out of the zone; the zone file lists it as a comment. Web UI
toggle, jarl record disable|enable, record.disable|enable operations
and API endpoints. Database schema 5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adamandClaude Opus 5.5 committed 2026-10-09 22:33:02 +00:00
1 parent 5f04ab523b
commit 295c549479
29 files changed
+815 -60

No files matched your search

+21 -9
View File
@@ -26,6 +26,10 @@ type batchEntry struct {
Delete map[string]any `yaml:"delete,omitempty" json:"delete,omitempty"`
Set map[string]any `yaml:"set,omitempty" json:"set,omitempty"`
Update map[string]any `yaml:"update,omitempty" json:"update,omitempty"`
// Disable and Enable find records like Delete: by id, or by zone,
// name, type and optionally data.
Disable map[string]any `yaml:"disable,omitempty" json:"disable,omitempty"`
Enable map[string]any `yaml:"enable,omitempty" json:"enable,omitempty"`
// Any API operation: op, id, data.
Op string `yaml:"op,omitempty" json:"op,omitempty"`
ID int64 `yaml:"id,omitempty" json:"id,omitempty"`
@@ -57,25 +61,23 @@ func (b *batchFile) requests() ([]api.ChangeRequest, error) {
var out []api.ChangeRequest
for i, e := range b.Changes {
n := 0
for _, set := range []bool{e.Add != nil, e.Delete != nil, e.Set != nil, e.Update != nil, e.Op != ""} {
for _, set := range []bool{e.Add != nil, e.Delete != nil, e.Set != nil, e.Update != nil, e.Disable != nil, e.Enable != nil, e.Op != ""} {
if set {
n++
}
}
if n != 1 {
return nil, fmt.Errorf("change %d: use exactly one of add, delete, set, update or op", i+1)
return nil, fmt.Errorf("change %d: use exactly one of add, delete, set, update, disable, enable or op", i+1)
}
switch {
case e.Add != nil:
out = append(out, api.ChangeRequest{Op: "record.create", Data: rawJSON(e.Add)})
case e.Delete != nil:
d := e.Delete
if id, ok := toInt64(d["id"]); ok {
delete(d, "id")
out = append(out, api.ChangeRequest{Op: "record.delete", ID: id, Data: rawJSON(d)})
} else {
out = append(out, api.ChangeRequest{Op: "record.delete", Data: rawJSON(d)})
}
out = append(out, byIDOrMatch("record.delete", e.Delete))
case e.Disable != nil:
out = append(out, byIDOrMatch("record.disable", e.Disable))
case e.Enable != nil:
out = append(out, byIDOrMatch("record.enable", e.Enable))
case e.Set != nil:
s := e.Set
switch d := s["data"].(type) {
@@ -104,6 +106,16 @@ func (b *batchFile) requests() ([]api.ChangeRequest, error) {
return out, nil
}
// byIDOrMatch is a request for the record with d's id, or for the records
// d matches.
func byIDOrMatch(op string, d map[string]any) api.ChangeRequest {
if id, ok := toInt64(d["id"]); ok {
delete(d, "id")
return api.ChangeRequest{Op: op, ID: id, Data: rawJSON(d)}
}
return api.ChangeRequest{Op: op, Data: rawJSON(d)}
}
// submitBatch applies requests as one changeset, or stages them into the
// changeset given with --changeset.
func submitBatch(c *client.Client, description string, reqs []api.ChangeRequest) error {