Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Changes ¶
type Changes struct { // Records that need to be created Create []endpoint.Endpoint // Records that need to be updated (current data) UpdateOld []endpoint.Endpoint // Records that need to be updated (desired data) UpdateNew []endpoint.Endpoint // Records that need to be deleted Delete []endpoint.Endpoint }
Changes holds lists of actions to be executed by dns providers
type Plan ¶
type Plan struct { // List of current records Current []endpoint.Endpoint // List of desired records Desired []endpoint.Endpoint // List of changes necessary to move towards desired state // Populated after calling Calculate() Changes Changes }
Plan can convert a list of desired and current records to a series of create, update and delete actions.
Example ¶
ExamplePlan shows how plan can be used.
foo := endpoint.Endpoint{DNSName: "foo.example.com", Target: "1.2.3.4"} barV1 := endpoint.Endpoint{DNSName: "bar.example.com", Target: "8.8.8.8"} barV2 := endpoint.Endpoint{DNSName: "bar.example.com", Target: "8.8.4.4"} baz := endpoint.Endpoint{DNSName: "baz.example.com", Target: "6.6.6.6"} // Plan where // * foo should be deleted // * bar should be updated from v1 to v2 // * baz should be created plan := &Plan{ Current: []endpoint.Endpoint{foo, barV1}, Desired: []endpoint.Endpoint{barV2, baz}, } // calculate actions plan = plan.Calculate() // print actions fmt.Println("Create:", plan.Changes.Create) fmt.Println("UpdateOld:", plan.Changes.UpdateOld) fmt.Println("UpdateNew:", plan.Changes.UpdateNew) fmt.Println("Delete:", plan.Changes.Delete)
Output: Create: [{baz.example.com 6.6.6.6}] UpdateOld: [{bar.example.com 8.8.8.8}] UpdateNew: [{bar.example.com 8.8.4.4}] Delete: [{foo.example.com 1.2.3.4}]
Click to show internal directories.
Click to hide internal directories.