in pkg/config/config.go [112:155]
func (c *Config) ParseAndValidateZoneIDs(zonesString string) error {
c.PrivateZoneConfig = DnsZoneConfig{}
c.PublicZoneConfig = DnsZoneConfig{}
DNSZoneIDs := strings.Split(zonesString, ",")
for _, zoneId := range DNSZoneIDs {
parsedZone, err := azure.ParseResourceID(zoneId)
if err != nil {
return fmt.Errorf("while parsing dns zone resource ID %s: %s", zoneId, err)
}
switch strings.ToLower(parsedZone.ResourceType) {
case PrivateZoneType:
// it's a private zone
if err := ValidateProviderSubAndRg(parsedZone, c.PrivateZoneConfig.Subscription, c.PrivateZoneConfig.ResourceGroup); err != nil {
return err
}
c.PrivateZoneConfig.Subscription = parsedZone.SubscriptionID
c.PrivateZoneConfig.ResourceGroup = parsedZone.ResourceGroup
if c.PrivateZoneConfig.ZoneIds == nil {
c.PrivateZoneConfig.ZoneIds = map[string]struct{}{}
}
c.PrivateZoneConfig.ZoneIds[strings.ToLower(zoneId)] = struct{}{} // azure resource names are case insensitive
case PublicZoneType:
// it's a public zone
if err := ValidateProviderSubAndRg(parsedZone, c.PublicZoneConfig.Subscription, c.PublicZoneConfig.ResourceGroup); err != nil {
return err
}
c.PublicZoneConfig.Subscription = parsedZone.SubscriptionID
c.PublicZoneConfig.ResourceGroup = parsedZone.ResourceGroup
if c.PublicZoneConfig.ZoneIds == nil {
c.PublicZoneConfig.ZoneIds = map[string]struct{}{}
}
c.PublicZoneConfig.ZoneIds[strings.ToLower(zoneId)] = struct{}{} // azure resource names are case insensitive
default:
return fmt.Errorf("while parsing dns zone resource ID %s: detected invalid resource type %s", zoneId, parsedZone.ResourceType)
}
}
return nil
}