StackExchange / dnscontrol

Infrastructure as code for DNS!
https://dnscontrol.org/
MIT License
3.1k stars 391 forks source link

Need some help with implementing a provider for GoDaddy #2596

Open nvanlaerebeke opened 11 months ago

nvanlaerebeke commented 11 months ago

I've been trying my hand at creating a provider for godaddy where I have my domains.

Need some help with the implementation, gotten some things working already but still have quite a few tests failing.

Have no GO experience at all, this is the first time doing anything in the language but did somewhat manage I think.

The fork can be found here: https://github.com/nvanlaerebeke/dnscontrol/tree/feature/godaddy

Trying to get all the integration tests working, I'm having some issues with the CNAME and MX records now where the domain is being appended to the data, example the output for the "Create_a_CNAME" test:

=== RUN   TestDNSProviders
=== RUN   TestDNSProviders/example.com
=== RUN   TestDNSProviders/example.com/03:CNAME:Create_a_CNAME
WARNING: + CREATE testcname.example.com CNAME www.google.com. ttl=600
WARNING: ± MODIFY testcname.example.com CNAME (www.google.com.example.com. ttl=600) -> (www.google.com. ttl=600)
    integration_test.go:277: Expected 0 corrections on second run, but found 1.
    integration_test.go:279: UNEXPECTED #0: ± MODIFY testcname.example.com CNAME (www.google.com.example.com. ttl=600) -> (www.google.com. ttl=600)
--- FAIL: TestDNSProviders (1.98s)
    --- FAIL: TestDNSProviders/example.com (1.98s)
        --- FAIL: TestDNSProviders/example.com/03:CNAME:Create_a_CNAME (1.17s)
FAIL
exit status 1
FAIL    github.com/StackExchange/dnscontrol/v4/integrationTest  1.989s

The CNAME record is correctly created, but for some reason it checks with the 'www.google.com.' during the verification.

It's implemented with diff2 just as mentioned in the docs.
I'm working on this on and off when I have some brain power left after work so apologies if progress isn't super fast.

Current progress on the tests

OK:

00:A:Create_A 
01:Apex:Create_A 
02:Protocol-Wildcard:Create_wildcard 
05:TXT:Create_TXT
06:ManyAtOnce:CreateManyAtLabel
09:TTL:Start
11:TypeChange:Create_A
13:CNAME:Record_pointing_to_@
16:complex_TXT:TXT_with_1_single-quote
18:testByLabel:initial
20:IDNA:Internationalized_name
22:pager101:99_records 

NOT OK:

03:CNAME:Create_a_CNAME 
04:MX:Create_MX 
07:manyTypesAtOnce:CreateManyTypesAtLabel
08:Attl:Create_Arc
10:add_to_label_and_change_orig_ttl:Setup 
12:TypeChangeHard:Create_a_CNAME 
14:MX:Record_pointing_to_@  
15:NS:NS_for_subdomain 
17:Case_Sensitivity:Create_CAPS
19:testByRecordSet:initial 
21:IDNAs_in_CNAME_targets:IDN_CNAME_AND_Target
61:IGNORE_TARGET_function_CNAME:Create_some_records

SKIPPED:

23:pager601_***SKIPPED(disabled_by_only)***:Empty (0.20s)
24:pager1201_***SKIPPED(disabled_by_only)***:Empty (0.20s)
25:CAA_***SKIPPED(CanUseCAA_not_supported)***:Empty (0.20s)
26:LOC_***SKIPPED(CanUseLOC_not_supported)***:Empty (0.20s)
27:NAPTR_***SKIPPED(CanUseNAPTR_not_supported)***:Empty (0.19s)
28:PTR_***SKIPPED(CanUsePTR_not_supported)***:Empty (0.18s)
29:SOA_***SKIPPED(CanUseSOA_not_supported)***:Empty (0.24s)
30:SRV_***SKIPPED(CanUseSRV_not_supported)***:Empty (0.20s)
31:SRV_***SKIPPED(CanUseSRV_not_supported)***:Empty (0.20s)
32:SSHFP_***SKIPPED(CanUseSSHFP_not_supported)***:Empty (0.20s)
33:TLSA_***SKIPPED(CanUseTLSA_not_supported)***:Empty (0.20s)
34:DS_***SKIPPED(CanUseDS_not_supported)***:Empty (0.18s)
35:DS_(children_only)_***SKIPPED(CanUseDSForChildren_not_supported)***:Empty (0.19s)
36:DS_(children_only)_CLOUDNS_***SKIPPED(CanUseDSForChildren_not_supported)***:Empty (0.19s)
37:ALIAS_***SKIPPED(CanUseAlias_not_supported)***:Empty (0.26s)
38:AZURE_ALIAS_A_***SKIPPED(CanUseAzureAlias_not_supported)***:Empty (0.18s)
39:AZURE_ALIAS_CNAME_***SKIPPED(CanUseAzureAlias_not_supported)***:Empty (0.23s)
40:R53_ALIAS2_***SKIPPED(CanUseRoute53Alias_not_supported)***:Empty (0.20s)
41:R53_ALIAS_ORDER_***SKIPPED(CanUseRoute53Alias_not_supported)***:Empty (0.20s)
42:R53_ALIAS_CNAME_***SKIPPED(CanUseRoute53Alias_not_supported)***:Empty (0.20s)
43:R53_ALIAS_Loop_***SKIPPED(CanUseRoute53Alias_not_supported)***:Empty (0.20s)
44:R53_alias_pre-existing_***SKIPPED(CanUseRoute53Alias_not_supported)***:Empty (0.18s)
45:CF_REDIRECT_***SKIPPED(disabled_by_only)***:Empty (0.23s)
46:CF_PROXY_A_create_***SKIPPED(disabled_by_only)***:Empty (0.19s)
47:CF_PROXY_A_off_to_X_***SKIPPED(disabled_by_only)***:Empty (0.19s)
48:CF_PROXY_A_on_to_X_***SKIPPED(disabled_by_only)***:Empty (0.18s)
49:CF_PROXY_A_full1_to_X_***SKIPPED(disabled_by_only)***:Empty (0.18s)
50:CF_PROXY_A_full2_to_X_***SKIPPED(disabled_by_only)***:Empty (0.18s)
51:CF_PROXY_CNAME_create_***SKIPPED(disabled_by_only)***:Empty (0.29s)
52:CF_PROXY_CNAME_off_to_X_***SKIPPED(disabled_by_only)***:Empty (0.20s)
53:CF_PROXY_CNAME_on_to_X_***SKIPPED(disabled_by_only)***:Empty (0.19s)
54:CF_PROXY_CNAME_full_to_X_***SKIPPED(disabled_by_only)***:Empty (0.22s)
55:CF_WORKER_ROUTE_***SKIPPED(disabled_by_only)***:Empty (0.19s)
56:NS1_URLFWD_tests_***SKIPPED(disabled_by_only)***:Empty (0.23s)
57:IGNORE_main_***SKIPPED(test_for_diff2_only)***:Empty (0.20s)
58:IGNORE_apex_***SKIPPED(test_for_diff2_only)***:Empty (0.20s)
59:IGNORE_NAME_function_***SKIPPED(test_for_diff2_only)***:Empty (0.20s)
60:IGNORE_NAME_apex_***SKIPPED(test_for_diff2_only)***:Empty (0.19s)
62:IGNORE_TARGET_function_CNAME*:Create_some_records (0.20s)
63:IGNORE_TARGET_function_CNAME**:Create_some_records (0.20s)
64:IGNORE_TARGET_b2285_***SKIPPED(test_for_diff2_only)***:Empty (0.20s)
65:structured_TXT_***SKIPPED(disabled_by_only)***:Empty (0.21s)
66:structured_TXT_as_native_records_***SKIPPED(disabled_by_only)***:Empty (0.19s)
tlimoncelli commented 11 months ago

Sorry for the long delay!

I'd be glad to walk you through this!

The way that integration tests work is to make a change then do a preview to see that the change worked as expected. Think of each test as building a dnsconfig.js file. The first step is to (do the equivalent of) "dnscontrol push" to make the change. The second step is to do (the equivalent of) "dnscontrol preview" which should result in "0 changes needed". If any changes were needed, the update wasn't done correctly. Those unexpected changes are listed as "UNEXPECTED #n" where n starts at 0 and increments.

The above error message is the 2nd push. Instead of getting "0 changes needed", the diff engine returned 1 change. UNEXPECTED #0 is the first (0th) change:

integration_test.go:279: UNEXPECTED #0: ± MODIFY testcname.example.com CNAME (www.google.com.example.com. ttl=600) -> (www.google.com. ttl=600)

The preview found a CNAME at testcname.example.com which pointed to www.google.com.example.com. but needs to be corrected to point to www.google.com..

That indicates that the original "push" created the CNAME without the trailing "." thus GoDaddy added .example.com..

In other words, the API is expecting you to add a "." to the end of the CNAME's target.

I see there are failures for MX, NS and other records that have a target that is a hostname, just like CNAME.

Hope that helps!

P.S. Try adding -v and -verbose to your integration test for more verbose output: go test -v -verbose -provider GODADDY

tlimoncelli commented 9 months ago

Friendly ping?

nvanlaerebeke commented 9 months ago

Unfortunately I haven't found the time to work on this, had things come in between (like planning my wedding).

Still want to finish this as every time I make a DNS change I'm annoyed at having to do it manually, their interface is fairly annoying to use IMO.

Hoping to find some time between Christmas and new year, have a couple of days off work that period.

tlimoncelli commented 9 months ago

No worries! Just wanted to check in and let you know I'm available if you need help.

wedding > dnscontrol

Congrats on your recent nuptials! I hope marriage brings you the joy that it has brought my family!

Best, Tom