mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Implement populate exists for GoogleCloudProvider
This commit is contained in:
@@ -202,11 +202,14 @@ class GoogleCloudProvider(BaseProvider):
|
||||
|
||||
self.log.debug('populate: name=%s, target=%s, lenient=%s', zone.name,
|
||||
target, lenient)
|
||||
|
||||
exists = False
|
||||
before = len(zone.records)
|
||||
|
||||
gcloud_zone = self.gcloud_zones.get(zone.name)
|
||||
|
||||
if gcloud_zone:
|
||||
exists = True
|
||||
for gcloud_record in self._get_gcloud_records(gcloud_zone):
|
||||
if gcloud_record.record_type.upper() not in self.SUPPORTS:
|
||||
continue
|
||||
@@ -227,7 +230,9 @@ class GoogleCloudProvider(BaseProvider):
|
||||
record = Record.new(zone, record_name, data, source=self)
|
||||
zone.add_record(record)
|
||||
|
||||
self.log.info('populate: found %s records', len(zone.records) - before)
|
||||
self.log.info('populate: found %s records, exists=%s',
|
||||
len(zone.records) - before, exists)
|
||||
return exists
|
||||
|
||||
def _data_for_A(self, gcloud_record):
|
||||
return {
|
||||
|
@@ -359,7 +359,8 @@ class TestGoogleCloudProvider(TestCase):
|
||||
"unit.tests.")
|
||||
|
||||
test_zone = Zone('unit.tests.', [])
|
||||
provider.populate(test_zone)
|
||||
exists = provider.populate(test_zone)
|
||||
self.assertTrue(exists)
|
||||
|
||||
# test_zone gets fed the same records as zone does, except it's in
|
||||
# the format returned by google API, so after populate they should look
|
||||
@@ -367,7 +368,8 @@ class TestGoogleCloudProvider(TestCase):
|
||||
self.assertEqual(test_zone.records, zone.records)
|
||||
|
||||
test_zone2 = Zone('nonexistant.zone.', [])
|
||||
provider.populate(test_zone2, False, False)
|
||||
exists = provider.populate(test_zone2, False, False)
|
||||
self.assertFalse(exists)
|
||||
|
||||
self.assertEqual(len(test_zone2.records), 0,
|
||||
msg="Zone should not get records from wrong domain")
|
||||
|
Reference in New Issue
Block a user