本文整理匯總了Golang中k8s/io/kubernetes/federation/pkg/dnsprovider.Zones.List方法的典型用法代碼示例。如果您正苦於以下問題:Golang Zones.List方法的具體用法?Golang Zones.List怎麽用?Golang Zones.List使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/federation/pkg/dnsprovider.Zones
的用法示例。
在下文中一共展示了Zones.List方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getDnsZones
// getDnsZones returns the DNS zones matching dnsZoneName and dnsZoneID (if specified)
func getDnsZones(dnsZoneName string, dnsZoneID string, dnsZonesInterface dnsprovider.Zones) ([]dnsprovider.Zone, error) {
// TODO: We need query-by-name and query-by-id functions
dnsZones, err := dnsZonesInterface.List()
if err != nil {
return nil, err
}
var matches []dnsprovider.Zone
findName := strings.TrimSuffix(dnsZoneName, ".")
for _, dnsZone := range dnsZones {
if dnsZoneID != "" {
if dnsZoneID != dnsZone.ID() {
continue
}
}
if findName != "" {
if strings.TrimSuffix(dnsZone.Name(), ".") != findName {
continue
}
}
matches = append(matches, dnsZone)
}
return matches, nil
}
示例2: getDnsZone
// getDnsZone is a hack around the fact that dnsprovider does not yet support a Get() method, only a List() method. TODO: Fix that.
func getDnsZone(dnsZoneName string, dnsZonesInterface dnsprovider.Zones) (dnsprovider.Zone, error) {
dnsZones, err := dnsZonesInterface.List()
if err != nil {
return nil, err
}
for _, dnsZone := range dnsZones {
if dnsZone.Name() == dnsZoneName {
return dnsZone, nil
}
}
return nil, fmt.Errorf("DNS zone %s not found.", dnsZoneName)
}
示例3: getDnsZone
// getDnsZone returns the zone, as identified by zoneName
func getDnsZone(dnsZoneName string, dnsZonesInterface dnsprovider.Zones) (dnsprovider.Zone, error) {
// TODO: We need query-by-name and query-by-id functions
dnsZones, err := dnsZonesInterface.List()
if err != nil {
return nil, err
}
findName := strings.TrimSuffix(dnsZoneName, ".")
for _, dnsZone := range dnsZones {
if findName != "" {
if strings.TrimSuffix(dnsZone.Name(), ".") == findName {
return dnsZone, nil
}
}
}
return nil, fmt.Errorf("DNS zone %s not found.", dnsZoneName)
}