Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(778)

Unified Diff: logdog/appengine/coordinator/config/config.go

Issue 2575383002: Add server/cache support to gaeconfig. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: logdog/appengine/coordinator/config/config.go
diff --git a/logdog/appengine/coordinator/config/config.go b/logdog/appengine/coordinator/config/config.go
index 0939fcdf1e6d5da5bbc5967abcff27994b788082..880538c8d53fc765b40308e3fffd5c92499527a7 100644
--- a/logdog/appengine/coordinator/config/config.go
+++ b/logdog/appengine/coordinator/config/config.go
@@ -5,15 +5,14 @@
package config
import (
- "fmt"
"net/url"
- "github.com/golang/protobuf/proto"
- "github.com/luci/gae/service/info"
- "github.com/luci/luci-go/common/config"
"github.com/luci/luci-go/common/errors"
log "github.com/luci/luci-go/common/logging"
"github.com/luci/luci-go/logdog/api/config/svcconfig"
+ "github.com/luci/luci-go/server/config"
+ "github.com/luci/luci-go/server/config/textproto"
+
"golang.org/x/net/context"
)
@@ -40,8 +39,7 @@ type Config struct {
// ServiceConfigPath returns the config set and path for this application's
// service configuration.
func ServiceConfigPath(c context.Context) (string, string) {
- appID := info.AppID(c)
- return fmt.Sprintf("services/%s", appID), svcconfig.ServiceConfigFilename
+ return config.CurrentServiceConfigSet(c), svcconfig.ServiceConfigFilename
}
// Load loads the service configuration. This includes:
@@ -51,33 +49,22 @@ func ServiceConfigPath(c context.Context) (string, string) {
//
// The service config is minimally validated prior to being returned.
func Load(c context.Context) (*Config, error) {
- configSet, configPath := ServiceConfigPath(c)
- serviceCfg, err := config.GetConfig(c, configSet, configPath, false)
- if err != nil {
- log.Fields{
- log.ErrorKey: err,
- "configSet": configSet,
- "configPath": configPath,
- }.Errorf(c, "Failed to load configuration from config service.")
- return nil, err
- }
-
// Unmarshal the config into service configuration.
cfg := Config{
- ConfigServiceURL: config.ServiceURL(c),
- ConfigSet: serviceCfg.ConfigSet,
- ServiceConfigPath: serviceCfg.Path,
+ ConfigServiceURL: config.ServiceURL(c),
}
+ cfg.ConfigSet, cfg.ServiceConfigPath = ServiceConfigPath(c)
+
+ // Load our service-level config.
+ if err := config.Get(c, config.AsService, cfg.ConfigSet, cfg.ServiceConfigPath,
+ textproto.Message(&cfg.Config), nil); err != nil {
- if err := proto.UnmarshalText(serviceCfg.Content, &cfg.Config); err != nil {
log.Fields{
- log.ErrorKey: err,
- "size": len(serviceCfg.Content),
- "contentHash": serviceCfg.ContentHash,
- "configSet": serviceCfg.ConfigSet,
- "revision": serviceCfg.Revision,
- }.Errorf(c, "Failed to unmarshal configuration protobuf.")
- return nil, ErrInvalidConfig
+ log.ErrorKey: err,
+ "configSet": cfg.ConfigSet,
+ "configPath": cfg.ServiceConfigPath,
+ }.Errorf(c, "Failed to load configuration from config service.")
+ return nil, err
}
// Validate the configuration.

Powered by Google App Engine
This is Rietveld 408576698