@@ -11,11 +11,11 @@ import (
1111 "github.com/libdns/libdns"
1212)
1313
14- func (p * Provider ) setRecord (ctx context.Context , zone string , record libdns.Record , domain gandiDomain ) error {
14+ func (p * Provider ) setRecord (ctx context.Context , zone string , rr libdns.RR , domain gandiDomain ) error {
1515 p .mutex .Lock ()
1616 defer p .mutex .Unlock ()
1717
18- req , err := http .NewRequestWithContext (ctx , "GET" , fmt .Sprintf ("%s/%s/%s" , domain .DomainRecordsHref , record .Name , record .Type ), nil )
18+ req , err := http .NewRequestWithContext (ctx , "GET" , fmt .Sprintf ("%s/%s/%s" , domain .DomainRecordsHref , rr .Name , rr .Type ), nil )
1919 if err != nil {
2020 return err
2121 }
@@ -31,22 +31,22 @@ func (p *Provider) setRecord(ctx context.Context, zone string, record libdns.Rec
3131 // we check if the new value does not already exists and append it if not
3232 var exists bool
3333 for _ , val := range oldGandiRecord .RRSetValues {
34- if val == record . Value {
34+ if val == rr . Data {
3535 exists = true
3636 break
3737 }
3838 }
3939
4040 recValues := oldGandiRecord .RRSetValues
4141 if ! exists {
42- recValues = append (recValues , record . Value )
42+ recValues = append (recValues , rr . Data )
4343 }
4444
4545 // we just create a new record, if an existing record was found, we just append the new value to the existing ones
4646 newGandiRecord := gandiRecord {
47- RRSetTTL : int (record .TTL .Seconds ()),
48- RRSetType : record .Type ,
49- RRSetName : record .Name ,
47+ RRSetTTL : int (rr .TTL .Seconds ()),
48+ RRSetType : rr .Type ,
49+ RRSetName : rr .Name ,
5050 RRSetValues : recValues ,
5151 }
5252
@@ -56,7 +56,7 @@ func (p *Provider) setRecord(ctx context.Context, zone string, record libdns.Rec
5656 }
5757
5858 // we update existing record or create a new record if it does not exist yet
59- req , err = http .NewRequestWithContext (ctx , "PUT" , fmt .Sprintf ("%s/%s/%s" , domain .DomainRecordsHref , record .Name , record .Type ), bytes .NewReader (raw ))
59+ req , err = http .NewRequestWithContext (ctx , "PUT" , fmt .Sprintf ("%s/%s/%s" , domain .DomainRecordsHref , rr .Name , rr .Type ), bytes .NewReader (raw ))
6060 if err != nil {
6161 return err
6262 }
@@ -68,11 +68,11 @@ func (p *Provider) setRecord(ctx context.Context, zone string, record libdns.Rec
6868 return err
6969}
7070
71- func (p * Provider ) deleteRecord (ctx context.Context , zone string , record libdns.Record , domain gandiDomain ) error {
71+ func (p * Provider ) deleteRecord (ctx context.Context , zone string , rr libdns.RR , domain gandiDomain ) error {
7272 p .mutex .Lock ()
7373 defer p .mutex .Unlock ()
7474
75- req , err := http .NewRequestWithContext (ctx , "GET" , fmt .Sprintf ("%s/%s/%s" , domain .DomainRecordsHref , record .Name , record .Type ), nil )
75+ req , err := http .NewRequestWithContext (ctx , "GET" , fmt .Sprintf ("%s/%s/%s" , domain .DomainRecordsHref , rr .Name , rr .Type ), nil )
7676 if err != nil {
7777 return err
7878 }
@@ -91,7 +91,7 @@ func (p *Provider) deleteRecord(ctx context.Context, zone string, record libdns.
9191 // if it contains multiple values, the best is to update the record instead of deleting all the values
9292 newRRSetValues := []string {}
9393 for _ , val := range rec .RRSetValues {
94- if val != record . Value {
94+ if val != rr . Data {
9595 newRRSetValues = append (newRRSetValues , val )
9696 }
9797 }
@@ -102,15 +102,15 @@ func (p *Provider) deleteRecord(ctx context.Context, zone string, record libdns.
102102 return err
103103 }
104104
105- req , requestErr = http .NewRequestWithContext (ctx , "PUT" , fmt .Sprintf ("%s/%s/%s" , domain .DomainRecordsHref , record .Name , record .Type ), bytes .NewReader (raw ))
105+ req , requestErr = http .NewRequestWithContext (ctx , "PUT" , fmt .Sprintf ("%s/%s/%s" , domain .DomainRecordsHref , rr .Name , rr .Type ), bytes .NewReader (raw ))
106106 } else {
107107 // if there is only one entry, we make sure that the value to delete is matching the one we found
108108 // otherwise we may delete the wrong record
109- if strings .Trim (rec .RRSetValues [0 ], "\" " ) != record . Value {
109+ if strings .Trim (rec .RRSetValues [0 ], "\" " ) != rr . Data {
110110 return fmt .Errorf ("LiveDNS returned a %v (%v)" , http .StatusNotFound , "Can't find such a DNS value" )
111111 }
112112
113- req , requestErr = http .NewRequestWithContext (ctx , "DELETE" , fmt .Sprintf ("%s/%s/%s" , domain .DomainRecordsHref , record .Name , record .Type ), nil )
113+ req , requestErr = http .NewRequestWithContext (ctx , "DELETE" , fmt .Sprintf ("%s/%s/%s" , domain .DomainRecordsHref , rr .Name , rr .Type ), nil )
114114 }
115115
116116 // we check if NewRequestWithContext threw an error
0 commit comments