Skip to content

Commit

Permalink
Merge pull request #22 from aktsk/use-BQNOTIFY_PROJECT-environment-va…
Browse files Browse the repository at this point in the history
…riable

Use BQNOTIFY_PROJECT environment variable instead of the one defined in config.yaml
  • Loading branch information
mizzy authored Jun 30, 2020
2 parents a5c44c1 + 6a4d4e1 commit 9a503b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example/cloud-functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $ gcloud functions deploy BqNotify \
--runtime go113 \
--trigger-topic bqnotify \
--set-env-vars SLACK_WEBHOOK_URL=$SLACK_WEBHOOK_URL \
--set-env-vars GCP_PROJECT=mizzy-270104 # GCP_PRJOECT environment variable is not set on go1.13 runtime automatically
--set-env-vars BQNOTIFY_PROJECT=mizzy-270104

$ gcloud scheduler jobs create pubsub bqnotify \
--message-body {} \
Expand Down
4 changes: 2 additions & 2 deletions example/cloud-functions/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# If project is not defined, bqnotify uses the value of GCP_PROJECT
# environment variable
# If project is not defined, bqnotify uses the value of BQNOTIFY_PROJECT
# or GCP_PROJECT environment variable
project: mizzy-270104
queries:
- sql: |-
Expand Down
4 changes: 4 additions & 0 deletions lib/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func Parse(file string) (*Config, error) {
return nil, err
}

if conf.Project == "" {
conf.Project = os.Getenv("BQNOTIFY_PROJECT")
}

if conf.Project == "" {
conf.Project = os.Getenv("GCP_PROJECT")
}
Expand Down

0 comments on commit 9a503b7

Please sign in to comment.