Skip to content

Commit 5ed9ab7

Browse files
committed
Rename field to reflect their meaning, document breaking changes
1 parent 1a8b054 commit 5ed9ab7

File tree

5 files changed

+129
-12
lines changed

5 files changed

+129
-12
lines changed

BREAKING.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Breaking Changes
2+
3+
## Version 1.6 (Upcoming)
4+
5+
### libdns 1.0 Compatibility
6+
7+
Version 1.6 requires **libdns v1.0** or later. The libdns v1.0 release introduced typed record structs that replace the generic `libdns.Record` type. This is a fundamental change to the libdns API.
8+
9+
#### What Changed in libdns 1.0
10+
11+
- **Typed Records**: Instead of using generic `libdns.Record` structs, libdns v1.0 introduced typed record implementations like `libdns.Address`, `libdns.TXT`, `libdns.SRV`, etc.
12+
- **Parse() Method**: The new `Record` interface includes a `Parse()` method that returns typed structs
13+
- **RR() Method**: All record types implement `RR()` to get the underlying resource record data
14+
15+
#### Migration for libdns 1.0
16+
17+
See the [libdns documentation](https://pkg.go.dev/github.com/libdns/libdns) for complete details on migrating to typed records.
18+
19+
Example of the new API:
20+
```go
21+
// Old (libdns <1.0)
22+
records := []libdns.Record{
23+
{
24+
Type: "A",
25+
Name: "www",
26+
Value: "1.2.3.4",
27+
TTL: 300 * time.Second,
28+
},
29+
}
30+
31+
// New (libdns >=1.0)
32+
records := []libdns.Record{
33+
libdns.Address{
34+
Name: "www",
35+
Value: netip.MustParseAddr("1.2.3.4"),
36+
TTL: 300 * time.Second,
37+
},
38+
}
39+
```
40+
41+
### Field Renames
42+
43+
Two provider configuration fields have been renamed for clarity:
44+
45+
#### 1. `MaxWaitDur``Route53MaxWait`
46+
47+
**Old (pre-v1.6):**
48+
```go
49+
provider := &route53.Provider{
50+
MaxWaitDur: 60, // Was treated as seconds (multiplied by time.Second internally)
51+
}
52+
```
53+
54+
**New (v1.6+):**
55+
```go
56+
provider := &route53.Provider{
57+
Route53MaxWait: 60 * time.Second, // Use proper time.Duration
58+
}
59+
```
60+
61+
**Important:** In versions before v1.6, `MaxWaitDur` was silently multiplied by `time.Second` in the provider's init function. This was non-idiomatic Go and has been fixed. You must now provide a proper `time.Duration` value (like `60 * time.Second` or `2 * time.Minute`), as is standard in Go.
62+
63+
**Failure to multiply by `time.Second` will result in a 60-nanosecond timeout instead of 60 seconds!**
64+
65+
**Rationale:** The new name clearly indicates this is a Route53-specific timeout for AWS internal propagation, not general DNS propagation.
66+
67+
#### 2. `WaitForPropagation``WaitForRoute53Sync`
68+
69+
**Old (pre-v1.6):**
70+
```go
71+
provider := &route53.Provider{
72+
WaitForPropagation: true,
73+
}
74+
```
75+
76+
**New (v1.6+):**
77+
```go
78+
provider := &route53.Provider{
79+
WaitForRoute53Sync: true,
80+
}
81+
```
82+
83+
**Rationale:** The new name clearly indicates this waits for Route53's internal synchronization, not worldwide DNS propagation (which can take hours depending on TTL values).
84+
85+
### JSON Configuration
86+
87+
If you're using JSON configuration, update your field names:
88+
89+
**Old (pre-v1.6):**
90+
```json
91+
{
92+
"max_wait_dur": 60,
93+
"wait_for_propagation": true
94+
}
95+
```
96+
97+
**New (v1.6+):**
98+
```json
99+
{
100+
"route53_max_wait": "2m",
101+
"wait_for_route53_sync": true
102+
}
103+
```
104+
105+
Note: The old `max_wait_dur` field accepted a numeric value (seconds), while the new `route53_max_wait` field uses standard Go duration strings like `"2m"`, `"120s"`, etc.
106+
107+
## Migration Checklist
108+
109+
- [ ] Update to libdns v1.0+ (see libdns documentation for typed records)
110+
- [ ] Rename `MaxWaitDur` to `Route53MaxWait` in your code
111+
- [ ] Change from plain integer (e.g., `60`) to proper `time.Duration` (e.g., `60 * time.Second`)
112+
- [ ] Rename `WaitForPropagation` to `WaitForRoute53Sync` in your code
113+
- [ ] Update JSON/YAML configuration files with new field names
114+
- [ ] Test your code thoroughly after migration

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Route53 for `libdns`
33

44
[![godoc reference](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/libdns/route53)
55

6+
> [!WARNING]
7+
> **Breaking changes in v1.6:** Field names have changed. See [BREAKING.md](BREAKING.md) for migration guide.
8+
69
This package implements the [libdns interfaces](https://github.com/libdns/libdns) for AWS [Route53](https://aws.amazon.com/route53/).
710

811
## Example
@@ -104,7 +107,7 @@ For more information, see the [AWS EC2 Instance Metadata Options documentation](
104107

105108
## Note on propagation-related fields
106109

107-
When you update records in AWS Route53, changes first propagate internally across AWSs DNS servers before becoming visible to the public. This internal step usually finishes within seconds, but may take more in rare cases, and can be waited on when `WaitForPropagation` is enabled. *It is different from normal DNS propagation, which depends on TTL and external caching.*
110+
When you update records in AWS Route53, changes first propagate internally across AWS's DNS servers before becoming visible to the public. This internal step usually finishes within seconds, but may take more in rare cases, and can be waited on when `WaitForRoute53Sync` is enabled. *It is different from normal DNS propagation, which depends on TTL and external caching.*
108111

109112
See [Change Propagation to Route 53 DNS Servers](https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html#API_ChangeResourceRecordSets_RequestSyntax:~:text=Change%20Propagation%20to%20Route%2053%20DNS%20Servers).
110113

client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ func (p *Provider) init(ctx context.Context) {
9292
p.MaxRetries = 5
9393
}
9494

95-
if p.MaxWaitDuration == 0 {
96-
p.MaxWaitDuration = time.Minute
95+
if p.Route53MaxWait == 0 {
96+
p.Route53MaxWait = time.Minute
9797
}
9898

9999
opts := make([]func(*config.LoadOptions) error, 0)
@@ -393,14 +393,14 @@ func (p *Provider) applyChange(ctx context.Context, input *r53.ChangeResourceRec
393393
}
394394

395395
// Waiting for propagation if it's set in the provider config.
396-
if p.WaitForPropagation {
396+
if p.WaitForRoute53Sync {
397397
changeInput := &r53.GetChangeInput{
398398
Id: changeResult.ChangeInfo.Id,
399399
}
400400

401401
// Wait for the RecordSetChange status to be "INSYNC"
402402
waiter := r53.NewResourceRecordSetsChangedWaiter(p.client)
403-
err = waiter.Wait(ctx, changeInput, p.MaxWaitDuration)
403+
err = waiter.Wait(ctx, changeInput, p.Route53MaxWait)
404404
if err != nil {
405405
return err
406406
}

client_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func TestMarshalRecord(t *testing.T) {
362362
}
363363
}
364364

365-
func TestMaxWaitDur(t *testing.T) {
365+
func TestRoute53MaxWait(t *testing.T) {
366366
cases := []struct {
367367
name string
368368
input time.Duration
@@ -382,9 +382,9 @@ func TestMaxWaitDur(t *testing.T) {
382382

383383
for _, c := range cases {
384384
t.Run(c.name, func(t *testing.T) {
385-
provider := Provider{MaxWaitDuration: c.input}
385+
provider := Provider{Route53MaxWait: c.input}
386386
provider.init(context.TODO())
387-
actual := provider.MaxWaitDuration
387+
actual := provider.Route53MaxWait
388388
if actual != c.expected {
389389
t.Errorf("expected %d, got %d", c.expected, actual)
390390
}

provider.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ type Provider struct {
3939
// fails. If not set, it will use 5 retries.
4040
MaxRetries int `json:"max_retries,omitempty"`
4141

42-
// MaxWaitDuration is the maximum amount of time to wait for a record
42+
// Route53MaxWait is the maximum amount of time to wait for a record
4343
// to be propagated within AWS infrastructure. Default is 1 minute.
44-
MaxWaitDuration time.Duration `json:"max_wait_duration,omitempty"`
44+
Route53MaxWait time.Duration `json:"route53_max_wait,omitempty"`
4545

46-
// WaitForPropagation if set to true, it will wait for the record to be
46+
// WaitForRoute53Sync if set to true, it will wait for the record to be
4747
// propagated within AWS infrastructure before returning. This is not related
4848
// to DNS propagation, that could take much longer.
49-
WaitForPropagation bool `json:"wait_for_propagation,omitempty"`
49+
WaitForRoute53Sync bool `json:"wait_for_route53_sync,omitempty"`
5050

5151
// HostedZoneID is the ID of the hosted zone to use. If not set, it will
5252
// be discovered from the zone name.

0 commit comments

Comments
 (0)