From 214eaeb84d183341e3bce75d7689c7bf71fb668f Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 11 Jan 2023 12:17:34 -0500 Subject: [PATCH] DOCS: Clarify ByRecord() assertions (#1931) --- pkg/diff2/diff2.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/diff2/diff2.go b/pkg/diff2/diff2.go index f5d5bd847..1e4a812d8 100644 --- a/pkg/diff2/diff2.go +++ b/pkg/diff2/diff2.go @@ -132,6 +132,12 @@ func ByLabel(existing models.Records, dc *models.DomainConfig, compFunc Comparab // // Use this with DNS providers whose API updates one record at a time. // +// Note: The .Old and .New field are lists ([]models.RecordConfig) but +// when using ByRecord() they will never have more than one entry. +// A create always has exactly 1 new: .New[0] +// A change always has exactly 1 old and 1 new: .Old[0] and .New[0] +// A delete always has exactly 1 old: .Old[0] +// // Examples include: INWX func ByRecord(existing models.Records, dc *models.DomainConfig, compFunc ComparableFunc) (ChangeList, error) { // dc stores the desired state.