-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Resource arm dns cname record #182
Resource arm dns cname record #182
Conversation
Tests pass:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @sebastus
Thanks for this PR - I've taken a look and left some a few minor comments in-line but this generally looks good :)
Thanks!
d.Set("resource_group_name", resGroup) | ||
d.Set("zone_name", zoneName) | ||
d.Set("ttl", *result.TTL) | ||
d.Set("etag", *result.Etag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should be able to remove the *
for these two sets as d.Set()
should take care of that for us automatically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if !createResponse.IsSuccessful() { | ||
return fmt.Errorf("Error creating DNS CName Record: %s", createResponse.Error) | ||
props := dns.RecordSetProperties{ | ||
Metadata: metadata, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from what I can see, these are the same thing, but just to confirm: is metadata
the same thing as tags
? The API documentation doesn't make it clear - but we currently submit these as tags
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the portal and in the sdk that property is called metadata, but it's otherwise identical to tags on other resources. and yes, in the tf file they are tags. I'll add a test to cover it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test was already present.
d.Set("zone_name", zoneName) | ||
d.Set("ttl", *result.TTL) | ||
d.Set("etag", *result.Etag) | ||
d.Set("record", cName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we check to see that result.RecordSetProperties.CnameRecord
isn't nil here - unfortunately swagger/server-side changes could lead to Terraform crashing if we don't check - so it'd be good to change this too:
if props := result.RecordSetProperties; props != nil {
if record := props.CnameRecord; record != nil {
d.Set("record", record.Cname)
}
}
(again, we shouldn't need the *
here because d.Set
will handle that automatically)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it.
|
||
flattenAndSetTags(d, &resp.Tags) | ||
flattenAndSetTags(d, result.Metadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(same question about Metadata+Tags)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the question back to you is: do you prefer the provider match the nomenclature in the tf file or that in the sdk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you prefer the provider match the nomenclature in the tf file or that in the sdk?
so we should be aiming for consistency with the schema (i.e. what's used in the *.tf
file) - rather than renaming this to match the SDK; providing the field we send to/from the API is actually tags (albeit renamed), then that's fine :) i.e. users should be able to upgrade from resources made with the Riviera SDK to resources made with the Azure SDK without any code changes :)
(from what I can see, if this is tags then I'd consider this inconsistency some design feedback for the Azure API's, as the rest of the Azure API's refer to this field as tags
)
@@ -54,112 +54,112 @@ func resourceArmDnsCNameRecord() *schema.Resource { | |||
Required: true, | |||
}, | |||
|
|||
"etag": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add this to the documentation too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tom - I'm new here so still learning. eTag can be left out - I'll remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @sebastus
Thanks for pushing those updates - I've taken another look and left a couple of comments but this is looking good :)
Thanks!
props := dns.RecordSetProperties{ | ||
Metadata: metadata, | ||
TTL: &ttl, | ||
CnameRecord: &cnameRecord, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: can we combine this into the properties
object below?
readResponse, err := readRequest.Execute() | ||
//last parameter is set to empty to allow updates to records after creation | ||
// (per SDK, set it to '*' to prevent updates, all other values are ignored) | ||
resp, err := dnsClient.CreateOrUpdate(resGroup, zoneName, name, dns.CNAME, parameters, "", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the penultimate argument for here? in general we'd tend to split these out into assigned variables if there's multiple
i.e.
foo := "bar"
bar := "foo"
...CreateOrUpdate(..., foo, bar)
|
||
resp, error := dnsClient.Delete(resGroup, zoneName, name, dns.CNAME, "") | ||
if resp.StatusCode != http.StatusOK { | ||
return fmt.Errorf("Error deleting DNS CNAME Record %s: %s", name, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make the second argument %+v
to output the full error here?
if err != nil { | ||
return fmt.Errorf("Bad: GetCNAMERecordSet: %s", err) | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be checking for the 404 above this, and then returning the error if it's present - rather than hiding this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @sebastus
Thanks for this contribution - due to changes within Azure detailed in #192 in order for us to merge this change in I've push a commit which contains fixes for the outstanding comments.
Your contribution is still included (and still credited to you), with the appropriate modifications. Feel free to ask about any of the changes.
Tests pass:
$ TF_ACC=1 envchain azurerm go test ./azurerm -v -timeout 120m -run TestAccAzureRMDnsC
=== RUN TestAccAzureRMDnsCNameRecord_importBasic
--- PASS: TestAccAzureRMDnsCNameRecord_importBasic (71.30s)
=== RUN TestAccAzureRMDnsCNameRecord_importWithTags
--- PASS: TestAccAzureRMDnsCNameRecord_importWithTags (80.29s)
=== RUN TestAccAzureRMDnsCNameRecord_basic
--- PASS: TestAccAzureRMDnsCNameRecord_basic (70.55s)
=== RUN TestAccAzureRMDnsCNameRecord_subdomain
--- PASS: TestAccAzureRMDnsCNameRecord_subdomain (86.35s)
=== RUN TestAccAzureRMDnsCNameRecord_updateRecords
--- PASS: TestAccAzureRMDnsCNameRecord_updateRecords (98.04s)
=== RUN TestAccAzureRMDnsCNameRecord_withTags
--- PASS: TestAccAzureRMDnsCNameRecord_withTags (94.55s)
PASS
ok github.com/terraform-providers/terraform-provider-azurerm/azurerm 501.101s
Thanks!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
No description provided.