Merge pull request #3342 from tommy31/improve/gandi_multi_rsetvalues

fix(gandi): allow grandi provider to support multiple TXT rsetvalues
This commit is contained in:
Kubernetes Prow Robot 2023-05-20 13:50:18 -07:00 committed by GitHub
commit ec644802af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 22 deletions

View File

@ -16,7 +16,6 @@ package gandi
import (
"context"
"errors"
"fmt"
"os"
"strings"
@ -121,11 +120,17 @@ func (p *GandiProvider) Records(ctx context.Context) ([]*endpoint.Endpoint, erro
name = zone
}
if len(r.RrsetValues) > 1 {
return nil, fmt.Errorf("can't handle multiple values for rrset %s", name)
}
for _, v := range r.RrsetValues {
log.WithFields(log.Fields{
"record": r.RrsetName,
"type": r.RrsetType,
"value": v,
"ttl": r.RrsetTTL,
"zone": zone,
}).Debug("Returning endpoint record")
endpoints = append(endpoints, endpoint.NewEndpoint(name, r.RrsetType, r.RrsetValues[0]))
endpoints = append(endpoints, endpoint.NewEndpoint(name, r.RrsetType, v))
}
}
}
}

View File

@ -18,7 +18,6 @@ import (
"fmt"
"os"
"reflect"
"strings"
"testing"
"github.com/go-gandi/go-gandi/domain"
@ -342,7 +341,7 @@ func TestGandiProvider_RecordsAppliesDomainFilter(t *testing.T) {
td.Cmp(t, expectedActions, mockedClient.Actions)
}
func TestGandiProvider_RecordsErrorOnMultipleValues(t *testing.T) {
func TestGandiProvider_RecordsWithMultipleValues(t *testing.T) {
mockedClient := mockGandiClientNewWithRecords([]livedns.DomainRecord{
{
RrsetValues: []string{"foo", "bar"},
@ -355,23 +354,11 @@ func TestGandiProvider_RecordsErrorOnMultipleValues(t *testing.T) {
LiveDNSClient: mockedClient,
}
expectedActions := []MockAction{
{
Name: "ListDomains",
},
{
Name: "GetDomainRecords",
FQDN: "example.com",
},
}
endpoints, err := mockedProvider.Records(context.Background())
if err == nil {
t.Errorf("expected to fail")
if err != nil {
t.Errorf("should not fail, %s", err)
}
assert.Equal(t, 0, len(endpoints))
assert.True(t, strings.HasPrefix(err.Error(), "can't handle multiple values for rrset"))
td.Cmp(t, expectedActions, mockedClient.Actions)
assert.Equal(t, 2, len(endpoints))
}
func TestGandiProvider_ApplyChangesEmpty(t *testing.T) {