Read runtime configuration from datastore.
[kraftakt.git] / app / config.go
1 package app
2
3 import (
4         "context"
5
6         "google.golang.org/appengine/datastore"
7         "google.golang.org/appengine/log"
8 )
9
10 var Config struct {
11         ProjectNumber string
12
13         FitbitClientID       string
14         FitbitClientSecret   string
15         FitbitSubscriberCode string
16
17         GoogleClientID     string
18         GoogleClientSecret string
19 }
20
21 func LoadConfig(ctx context.Context) error {
22         key := datastore.NewKey(ctx, "Config", "Production", 0, nil)
23         if err := datastore.Get(ctx, key, &Config); err != nil {
24                 log.Errorf(ctx, `datastore.Get("Config", "Production") = %v`, err)
25                 return err
26         }
27         return nil
28 }