Skip to content

Commit

Permalink
Auto-detect google-project if provider is Google and no project is su… (
Browse files Browse the repository at this point in the history
#492)

* Auto-detect google-project if provider is Google and no project is supplied.

* Add changelog entry.
  • Loading branch information
drzero42 authored and hjacobs committed Mar 13, 2018
1 parent 8989032 commit f2a4efb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Google Provider: Add auto-detection of Google Project when running on GCP (#492) @drzero42
- Add custom TTL support for DNSimple (#477) @jbowes
- Fix docker build and delete vendor files which were not deleted (#473) @njuettner
- DigitalOcean: DigitalOcean creates entries with host in them twice (#459) @njuettner
Expand Down
9 changes: 9 additions & 0 deletions provider/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"sort"
"strings"

"cloud.google.com/go/compute/metadata"
"github.com/linki/instrumented_http"
log "github.com/sirupsen/logrus"

Expand Down Expand Up @@ -133,6 +134,14 @@ func NewGoogleProvider(project string, domainFilter DomainFilter, zoneIDFilter Z
return nil, err
}

if project == "" {
mProject, mErr := metadata.ProjectID()
if mErr == nil {
log.Infof("Google project auto-detected: %s", mProject)
project = mProject
}
}

provider := &GoogleProvider{
project: project,
domainFilter: domainFilter,
Expand Down

0 comments on commit f2a4efb

Please sign in to comment.