Skip to content

Commit d8e3fa3

Browse files
authored
Merge pull request #13 from silinternational/feature/dns-cleanup
assorted fixes in the "multiregion dns" command
2 parents 8cf4353 + c914ca5 commit d8e3fa3

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

cmd/cli/multiregion/dns.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ func InitDnsCmd(parentCmd *cobra.Command) {
5656
func runDnsCommand(failback bool) {
5757
pFlags := getPersistentFlags()
5858

59+
if pFlags.readOnlyMode {
60+
fmt.Println("-- Read-only mode enabled --")
61+
}
62+
5963
d := newDnsCommand(pFlags, failback)
6064

6165
d.setDnsRecordValues(pFlags.idp)
@@ -129,15 +133,13 @@ func (d *DnsCommand) setDnsRecordValues(idpKey string) {
129133
{supportBotName, supportBotName + "-" + region},
130134

131135
// ECS services
132-
{idpKey + "-email", idpKey + "-email-" + region},
133-
{idpKey + "-broker", idpKey + "-broker-" + region},
134136
{idpKey + "-pw-api", idpKey + "-pw-api-" + region},
135137
{idpKey, idpKey + "-" + region},
136138
{idpKey + "-sync", idpKey + "-sync-" + region},
137139
}
138140

139141
for _, record := range dnsRecords {
140-
d.setCloudflareCname(record.name, record.value)
142+
d.setCloudflareCname(record.name, record.value+"."+d.domainName)
141143
}
142144
}
143145

@@ -153,10 +155,12 @@ func (d *DnsCommand) setCloudflareCname(name, value string) {
153155

154156
r, _, err := d.cfClient.ListDNSRecords(ctx, d.cfZone, cloudflare.ListDNSRecordsParams{Name: name + "." + d.domainName})
155157
if err != nil {
156-
log.Fatalf("error finding DNS record %s: %s", name, err)
158+
fmt.Printf("Error: Cloudflare API call failed to find DNS record %s: %s\n", name, err)
159+
return
157160
}
158161
if len(r) != 1 {
159-
log.Fatalf("did not find DNS record %s", name)
162+
fmt.Printf("Error: did not find DNS record %q in domain %q\n", name, d.domainName)
163+
return
160164
}
161165

162166
if r[0].Content == value {
@@ -179,8 +183,9 @@ func (d *DnsCommand) setCloudflareCname(name, value string) {
179183
Type: "CNAME",
180184
Name: name,
181185
Content: value,
186+
Comment: r[0].Comment,
182187
})
183188
if err != nil {
184-
log.Fatalf("error updating DNS record %s: %s", name, err)
189+
fmt.Printf("error updating DNS record %s: %s\n", name, err)
185190
}
186191
}

cmd/cli/multiregion/failover.go

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ func InitFailoverCmd(parentCmd *cobra.Command) {
6565
func runFailover() {
6666
pFlags := getPersistentFlags()
6767

68+
if pFlags.readOnlyMode {
69+
fmt.Println("-- Read-only mode enabled --")
70+
}
71+
6872
lib.SetToken(pFlags.tfcToken)
6973

7074
answer := simplePrompt(`Please confirm activation of failover mode. Type "yes" to continue.`)

cmd/cli/multiregion/setup.go

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ func InitSetupCmd(parentCmd *cobra.Command) {
2929
func runSetup() {
3030
pFlags := getPersistentFlags()
3131

32+
if pFlags.readOnlyMode {
33+
fmt.Println("-- Read-only mode enabled --")
34+
}
35+
3236
lib.SetToken(pFlags.tfcToken)
3337

3438
createSecondaryWorkspaces(pFlags)

0 commit comments

Comments
 (0)