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 ( import (
"context" "context"
"errors" "errors"
"fmt"
"os" "os"
"strings" "strings"
@ -121,11 +120,17 @@ func (p *GandiProvider) Records(ctx context.Context) ([]*endpoint.Endpoint, erro
name = zone name = zone
} }
if len(r.RrsetValues) > 1 { for _, v := range r.RrsetValues {
return nil, fmt.Errorf("can't handle multiple values for rrset %s", name) 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" "fmt"
"os" "os"
"reflect" "reflect"
"strings"
"testing" "testing"
"github.com/go-gandi/go-gandi/domain" "github.com/go-gandi/go-gandi/domain"
@ -342,7 +341,7 @@ func TestGandiProvider_RecordsAppliesDomainFilter(t *testing.T) {
td.Cmp(t, expectedActions, mockedClient.Actions) td.Cmp(t, expectedActions, mockedClient.Actions)
} }
func TestGandiProvider_RecordsErrorOnMultipleValues(t *testing.T) { func TestGandiProvider_RecordsWithMultipleValues(t *testing.T) {
mockedClient := mockGandiClientNewWithRecords([]livedns.DomainRecord{ mockedClient := mockGandiClientNewWithRecords([]livedns.DomainRecord{
{ {
RrsetValues: []string{"foo", "bar"}, RrsetValues: []string{"foo", "bar"},
@ -355,23 +354,11 @@ func TestGandiProvider_RecordsErrorOnMultipleValues(t *testing.T) {
LiveDNSClient: mockedClient, LiveDNSClient: mockedClient,
} }
expectedActions := []MockAction{
{
Name: "ListDomains",
},
{
Name: "GetDomainRecords",
FQDN: "example.com",
},
}
endpoints, err := mockedProvider.Records(context.Background()) endpoints, err := mockedProvider.Records(context.Background())
if err == nil { if err != nil {
t.Errorf("expected to fail") t.Errorf("should not fail, %s", err)
} }
assert.Equal(t, 0, len(endpoints)) assert.Equal(t, 2, len(endpoints))
assert.True(t, strings.HasPrefix(err.Error(), "can't handle multiple values for rrset"))
td.Cmp(t, expectedActions, mockedClient.Actions)
} }
func TestGandiProvider_ApplyChangesEmpty(t *testing.T) { func TestGandiProvider_ApplyChangesEmpty(t *testing.T) {