Skip to content

Commit

Permalink
resource_cloudflare_record: Add DiffSuppressFunc to value param
Browse files Browse the repository at this point in the history
Fixes: #154

When a trailing period is passed to the cloudflare_record resource,
we get a perpetual diff that looks as follows:

```
~ value: "_dbdxxx05384ca.hnyhpvdqhv.acm-validations.aws" => "_dbdxxxf205384ca.hnyhpvdqhv.acm-validations.aws."
```

We should ensure that we are adhering to the following RFCs where it
states that an FQDN can have a trailing `.`

Therefore, we can now use a DiffSuppressFunc to check that the old
value with the final `.` removed and the new value with the `.`
removed are the same and if they are then we don't need to cause a
diff
  • Loading branch information
stack72 committed Jun 20, 2022
1 parent 9ed7f06 commit 426735e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/1706.txt
@@ -0,0 +1,3 @@
``release-note:enhancement
resource/cloudflare_record: ensure trailing `.` in `value` don't cause surious diffs
```
3 changes: 3 additions & 0 deletions internal/provider/schema_cloudflare_record.go
Expand Up @@ -42,6 +42,9 @@ func resourceCloudflareRecordSchema() map[string]*schema.Schema {
Optional: true,
Computed: true,
ConflictsWith: []string{"data"},
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return strings.TrimSuffix(old, ".") == strings.TrimSuffix(new, ".")
},
},

"data": {
Expand Down

0 comments on commit 426735e

Please sign in to comment.