def main()

in dns/check-zone.py [0:0]


def main():
    """check-zone based on octodns config file and dns zone
    Will query all 4 DNS servers configured for the zone in GCP.
    """
    parser = ArgumentParser(description=__doc__.split('\n')[1])

    parser.add_argument('--config-file', required=True,
                        help='The OctoDNS configuration file to use')
    parser.add_argument('--zone', action='append', required=True, help='zone to check')

    args = parser.parse_args()

    manager = Manager(args.config_file)

    for zone_name in args.zone:
        print('Checking records for {}'.format(zone_name))
        zone = Zone(zone_name, manager.configured_sub_zones(zone_name))

        # Read our YAML configuration
        yaml_config = manager.providers['config']

        # Build a GCP provider in our project to read the nameservers from it
        gcp = manager.providers['gcp']
        project = gcp.gcloud_client.project
        
        # Retrieve the DNS Servers directly from the GCP configuration
        dns_servers = gcp.gcloud_zones[zone_name].name_servers

        # k8s.io resolvers for testing without access to gcp
        #dns_servers = ["NS-CLOUD-D1.GOOGLEDOMAINS.COM", "NS-CLOUD-D2.GOOGLEDOMAINS.COM", "NS-CLOUD-D3.GOOGLEDOMAINS.COM", "NS-CLOUD-D4.GOOGLEDOMAINS.COM"]
        print('Using GCP project {}'.format(project))
        print('name,type,ttl,{},consistent'.format(','.join(dns_servers)))
        
        # Populate the zone with those records defined in our YAML config
        yaml_config.populate(zone)

        # This would populate the zone with records already defined in Google Cloud DNS
        # gcp.populate(zone)

        # Configure Resolvers (one per DNS server)
        resolvers = configure_resolvers(dns_servers)

        # Populate the queries to make based on zone record configuration
        queries = {}
        for record in sorted(zone.records):
            queries[record] = [r.query(record.fqdn, record._type)
                               for r in resolvers]
        # No dns_error unless we find one
        dns_error = False

        dns_error = verify_dns(queries)

        if dns_error:
            sys.exit(1)

    sys.exit(0)