mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
Add Google Cloud DNS plugin (#3011)
Signed-off-by: Palash Nigam <npalash25@gmail.com> Closes: #2822
This commit is contained in:
32
plugin/clouddns/gcp.go
Normal file
32
plugin/clouddns/gcp.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package clouddns
|
||||
|
||||
import gcp "google.golang.org/api/dns/v1"
|
||||
|
||||
type gcpDNS interface {
|
||||
zoneExists(projectName, hostedZoneName string) error
|
||||
listRRSets(projectName, hostedZoneName string) (*gcp.ResourceRecordSetsListResponse, error)
|
||||
}
|
||||
|
||||
type gcpClient struct {
|
||||
*gcp.Service
|
||||
}
|
||||
|
||||
// zoneExists is a wrapper method around `gcp.Service.ManagedZones.Get`
|
||||
// it checks if the provided zone name for a given project exists.
|
||||
func (c gcpClient) zoneExists(projectName, hostedZoneName string) error {
|
||||
_, err := c.ManagedZones.Get(projectName, hostedZoneName).Do()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// listRRSets is a wrapper method around `gcp.Service.ResourceRecordSets.List`
|
||||
// it fetches and returns the record sets for a hosted zone.
|
||||
func (c gcpClient) listRRSets(projectName, hostedZoneName string) (*gcp.ResourceRecordSetsListResponse, error) {
|
||||
rr, err := c.ResourceRecordSets.List(projectName, hostedZoneName).Do()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rr, nil
|
||||
}
|
||||
Reference in New Issue
Block a user