@@ -4,6 +4,7 @@ package vinyldns
44import (
55 "errors"
66 "fmt"
7+ "strconv"
78 "time"
89
910 "github.com/go-acme/lego/v4/challenge"
@@ -17,9 +18,10 @@ import (
1718const (
1819 envNamespace = "VINYLDNS_"
1920
20- EnvAccessKey = envNamespace + "ACCESS_KEY"
21- EnvSecretKey = envNamespace + "SECRET_KEY"
22- EnvHost = envNamespace + "HOST"
21+ EnvAccessKey = envNamespace + "ACCESS_KEY"
22+ EnvSecretKey = envNamespace + "SECRET_KEY"
23+ EnvHost = envNamespace + "HOST"
24+ EnvQuoteValue = envNamespace + "QUOTE_VALUE"
2325
2426 EnvTTL = envNamespace + "TTL"
2527 EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT"
@@ -30,9 +32,11 @@ var _ challenge.ProviderTimeout = (*DNSProvider)(nil)
3032
3133// Config is used to configure the creation of the DNSProvider.
3234type Config struct {
33- AccessKey string
34- SecretKey string
35- Host string
35+ AccessKey string
36+ SecretKey string
37+ Host string
38+ QuoteValue bool
39+
3640 TTL int
3741 PropagationTimeout time.Duration
3842 PollingInterval time.Duration
@@ -66,6 +70,7 @@ func NewDNSProvider() (*DNSProvider, error) {
6670 config .AccessKey = values [EnvAccessKey ]
6771 config .SecretKey = values [EnvSecretKey ]
6872 config .Host = values [EnvHost ]
73+ config .QuoteValue = env .GetOrDefaultBool (EnvQuoteValue , false )
6974
7075 return NewDNSProviderConfig (config )
7176}
@@ -105,7 +110,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
105110 return fmt .Errorf ("vinyldns: %w" , err )
106111 }
107112
108- record := vinyldns.Record {Text : info .Value }
113+ value := d .formatValue (info .Value )
114+
115+ record := vinyldns.Record {Text : value }
109116
110117 if existingRecord == nil || existingRecord .ID == "" {
111118 err = d .createRecordSet (info .EffectiveFQDN , []vinyldns.Record {record })
@@ -117,7 +124,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
117124 }
118125
119126 for _ , i := range existingRecord .Records {
120- if i .Text == info . Value {
127+ if i .Text == value {
121128 return nil
122129 }
123130 }
@@ -146,9 +153,11 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
146153 return nil
147154 }
148155
156+ value := d .formatValue (info .Value )
157+
149158 var records []vinyldns.Record
150159 for _ , i := range existingRecord .Records {
151- if i .Text != info . Value {
160+ if i .Text != value {
152161 records = append (records , i )
153162 }
154163 }
@@ -175,3 +184,11 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
175184func (d * DNSProvider ) Timeout () (timeout , interval time.Duration ) {
176185 return d .config .PropagationTimeout , d .config .PollingInterval
177186}
187+
188+ func (d * DNSProvider ) formatValue (v string ) string {
189+ if d .config .QuoteValue {
190+ return strconv .Quote (v )
191+ }
192+
193+ return v
194+ }
0 commit comments