Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNS comment fixes #2148

Merged
merged 7 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/2148.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
fix issue with DNS comments and tags not being set
jacobbednarz marked this conversation as resolved.
Show resolved Hide resolved
```
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ FROM golang:1.18.3
RUN apt-get update -y && apt-get install -y lsb-release
RUN wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
RUN echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/hashicorp.list
RUN apt-get update -y && apt-get install -y terraform
RUN apt-get update -y && apt-get install -y terraform jq curl
10 changes: 10 additions & 0 deletions internal/provider/resource_cloudflare_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ func resourceCloudflareRecordCreate(ctx context.Context, d *schema.ResourceData,
proxiedVal = cloudflare.BoolPtr(false)
}

if comment, ok := d.GetOk("comment"); ok {
newRecord.Comment = comment.(string)
}

if tags, ok := d.GetOk("tags"); ok {
for _, tag := range tags.(*schema.Set).List() {
newRecord.Tags = append(newRecord.Tags, tag.(string))
}
}

// Validate type
if err := validateRecordType(newRecord.Type, *proxiedVal); err != nil {
return diag.FromErr(fmt.Errorf("error validating record type %q: %w", newRecord.Type, err))
Expand Down
6 changes: 6 additions & 0 deletions internal/provider/resource_cloudflare_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func TestAccCloudflareRecord_Basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "ttl", "3600"),
resource.TestCheckResourceAttr(resourceName, "metadata.%", "4"),
resource.TestCheckResourceAttr(resourceName, "metadata.auto_added", "false"),
resource.TestCheckResourceAttr(resourceName, "tags.#", "2"),
resource.TestCheckResourceAttr(resourceName, "tags.0", "tag1"),
resource.TestCheckResourceAttr(resourceName, "tags.1", "tag2"),
resource.TestCheckResourceAttr(resourceName, "comment", "this is a comment"),
),
},
},
Expand Down Expand Up @@ -700,6 +704,8 @@ resource "cloudflare_record" "%[3]s" {
value = "192.168.0.10"
type = "A"
ttl = 3600
tags = ["tag1", "tag2"]
comment = "this is a comment"
}`, zoneID, name, rnd)
}

Expand Down