forked from toolshed/abra
		
	fix: check if record already exists
This commit is contained in:
		@ -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
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user