Skip to content

Commit

Permalink
Azure-DNS: store values in TXT records without additional quotes
Browse files Browse the repository at this point in the history
```improvement operator
Azure-DNS: store values in TXT records without additional quotes
```
  • Loading branch information
MartinWeindel committed May 24, 2019
1 parent 20f3dfa commit e1bcad9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pkg/controller/provider/azure/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion pkg/controller/provider/azure/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"regexp"
"strconv"
"strings"

"github.com/gardener/controller-manager-library/pkg/logger"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit e1bcad9

Please sign in to comment.