Skip to content

Commit c96948c

Browse files
committed
simplify some things and expand error messages
1 parent 38dc450 commit c96948c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

cmd/cli/multiregion/dns.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ type DnsCommand struct {
2121
domainName string
2222
tfcOrg string
2323
tfcToken string
24-
dnsValues AlbDnsValues
2524
testMode bool
2625
}
2726

@@ -100,13 +99,12 @@ func newDnsCommand(pFlags PersistentFlags) *DnsCommand {
10099
}
101100

102101
func (d *DnsCommand) setDnsRecordValues(idpKey string, dnsValues AlbDnsValues, failback bool) {
103-
primaryOrSecondary := "secondary"
104102
if failback {
105-
primaryOrSecondary = "primary"
103+
fmt.Println("Setting DNS records to primary region...")
104+
} else {
105+
fmt.Println("Setting DNS records to secondary region...")
106106
}
107107

108-
fmt.Printf("Setting DNS records to %s...\n", primaryOrSecondary)
109-
110108
dnsRecords := []struct {
111109
name string
112110
optionValue string
@@ -187,19 +185,19 @@ func (d *DnsCommand) getAlbDnsValuesFromTfc(workspaceName string) (values AlbDns
187185

188186
client, err := tfe.NewClient(config)
189187
if err != nil {
190-
log.Fatal(err)
188+
log.Fatalf("Error creating Terraform client: %s", err)
191189
}
192190

193191
ctx := context.Background()
194192

195193
w, err := client.Workspaces.Read(ctx, d.tfcOrg, workspaceName)
196194
if err != nil {
197-
log.Fatal(err)
195+
log.Fatalf("Error reading Terraform workspace %s: %s", workspaceName, err)
198196
}
199197

200198
outputs, err := client.StateVersionOutputs.ReadCurrent(ctx, w.ID)
201199
if err != nil {
202-
return
200+
log.Fatalf("Error reading Terraform state outputs on workspace %s: %s", workspaceName, err)
203201
}
204202

205203
for _, item := range outputs.Items {

0 commit comments

Comments
 (0)