diff --git a/pkg/controller/provider/azure/execution.go b/pkg/controller/provider/azure/execution.go index 8addb985a..a14227eec 100644 --- a/pkg/controller/provider/azure/execution.go +++ b/pkg/controller/provider/azure/execution.go @@ -17,6 +17,7 @@ package azure import ( + "strconv" "strings" azure "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-03-01-preview/dns" @@ -106,7 +107,12 @@ func (exec *Execution) buildMappedRecordSet(name string, rset *dns.RecordSet) (b recordType = azure.TXT txtrecords := []azure.TxtRecord{} for _, r := range rset.Records { - txtrecords = append(txtrecords, azure.TxtRecord{Value: &[]string{r.Value}}) + // AzureDNS stores value as given, i.e. including quotes, so text value must be unquoted + unquoted, err := strconv.Unquote(r.Value) + if err != nil { + unquoted = r.Value + } + txtrecords = append(txtrecords, azure.TxtRecord{Value: &[]string{unquoted}}) } properties.TxtRecords = &txtrecords default: diff --git a/pkg/controller/provider/azure/handler.go b/pkg/controller/provider/azure/handler.go index b7da6c9d6..8a63f917e 100644 --- a/pkg/controller/provider/azure/handler.go +++ b/pkg/controller/provider/azure/handler.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "regexp" + "strconv" "strings" "github.com/gardener/controller-manager-library/pkg/logger" @@ -193,7 +194,12 @@ func (h *Handler) GetZoneState(zone provider.DNSHostedZone) (provider.DNSZoneSta if item.TxtRecords != nil { rs := dns.NewRecordSet(dns.RS_TXT, *item.TTL, nil) for _, record := range *item.TxtRecords { - rs.Add(&dns.Record{Value: strings.Join(*record.Value, "\n")}) + quoted := strings.Join(*record.Value, "\n") + // AzureDNS stores values unquoted, but it is expected to be quoted in dns.Record + if len(quoted) > 0 && quoted[0] != '"' && quoted[len(quoted)-1] != '"' { + quoted = strconv.Quote(quoted) + } + rs.Add(&dns.Record{Value: quoted}) } dnssets.AddRecordSetFromProvider(fullName, rs) }