fix: check if record already exists
continuous-integration/drone/push Build is passing Details

This commit is contained in:
decentral1se 2021-10-20 16:56:34 +02:00
parent 02d24104e1
commit 7f1d9eeaec
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with 15 additions and 1 deletions

View File

@ -100,6 +100,19 @@ Which means you can then deploy an app against "myapp.foo.com" successfully.
record.Priority = priority
}
records, err := provider.GetRecords(c.Context, zone)
if err != nil {
logrus.Fatal(err)
}
for _, existingRecord := range records {
if existingRecord.Type == record.Type &&
existingRecord.Name == record.Name &&
existingRecord.Value == record.Value {
logrus.Fatal("provider library reports that this record already exists?")
}
}
createdRecords, err := provider.SetRecords(
c.Context,
zone,
@ -128,9 +141,10 @@ Which means you can then deploy an app against "myapp.foo.com" successfully.
strconv.Itoa(createdRecord.Priority),
})
table.SetCaption(true, "record created")
table.Render()
logrus.Info("record created")
return nil
},
}