Skip to content

Commit

Permalink
infomaniak: fix subzone support (#1497)
Browse files Browse the repository at this point in the history
  • Loading branch information
L3o-pold committed Sep 30, 2021
1 parent 17f62b8 commit 1bd6638
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
1 change: 0 additions & 1 deletion docs/content/dns/zz_gen_infomaniak.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ More information [here](/lego/dns/#configuration-and-credentials).

Access token can be created at the url https://manager.infomaniak.com/v3/infomaniak-api.
You will need domain scope.
```



Expand Down
25 changes: 4 additions & 21 deletions providers/dns/infomaniak/infomaniak.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"net/http"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -113,11 +112,6 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
fqdn, value := dns01.GetRecord(domain, keyAuth)

authZone, err := getZone(fqdn)
if err != nil {
return fmt.Errorf("infomaniak: %w", err)
}

ikDomain, err := d.client.GetDomainByName(domain)
if err != nil {
return fmt.Errorf("infomaniak: could not get domain %q: %w", domain, err)
Expand All @@ -128,7 +122,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
d.domainIDsMu.Unlock()

record := internal.Record{
Source: extractRecordName(fqdn, authZone),
Source: extractRecordName(fqdn, ikDomain.CustomerName),
Target: value,
Type: "TXT",
TTL: d.config.TTL,
Expand Down Expand Up @@ -190,19 +184,8 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
return d.config.PropagationTimeout, d.config.PollingInterval
}

func getZone(fqdn string) (string, error) {
authZone, err := dns01.FindZoneByFqdn(fqdn)
if err != nil {
return "", err
}

return dns01.UnFqdn(authZone), nil
}

func extractRecordName(fqdn, zone string) string {
func extractRecordName(fqdn, domain string) string {
name := dns01.UnFqdn(fqdn)
if idx := strings.Index(name, "."+zone); idx != -1 {
return name[:idx]
}
return name

return name[:len(name)-len(domain)-1]
}
1 change: 0 additions & 1 deletion providers/dns/infomaniak/infomaniak.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Additional = '''
Access token can be created at the url https://manager.infomaniak.com/v3/infomaniak-api.
You will need domain scope.
```
'''

[Configuration]
Expand Down

0 comments on commit 1bd6638

Please sign in to comment.