From 7f1d9eeaecdfd4d2dbc1ce49526337f460fea93f Mon Sep 17 00:00:00 2001 From: decentral1se Date: Wed, 20 Oct 2021 16:56:34 +0200 Subject: [PATCH] fix: check if record already exists --- cli/domain/create.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cli/domain/create.go b/cli/domain/create.go index 3ca2670ea..4b88bffb6 100644 --- a/cli/domain/create.go +++ b/cli/domain/create.go @@ -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 }, }