Index: appengine/logdog/coordinator/config/projects.go |
diff --git a/appengine/logdog/coordinator/config/projects.go b/appengine/logdog/coordinator/config/projects.go |
index 67e1f66570b8128ecf6039db677d1a78a5bb5df4..a039f31da2e5708776f89efcbe302200dd0586bc 100644 |
--- a/appengine/logdog/coordinator/config/projects.go |
+++ b/appengine/logdog/coordinator/config/projects.go |
@@ -14,6 +14,7 @@ import ( |
log "github.com/luci/luci-go/common/logging" |
"github.com/luci/luci-go/common/parallel" |
configProto "github.com/luci/luci-go/common/proto/config" |
+ "github.com/luci/luci-go/common/proto/logdog/svcconfig" |
"github.com/luci/luci-go/server/auth" |
"github.com/luci/luci-go/server/auth/identity" |
"golang.org/x/net/context" |
@@ -24,6 +25,36 @@ const maxProjectWorkers = 32 |
// ErrNoAccess is returned if the user has no access to the requested project. |
var ErrNoAccess = errors.New("no access") |
+// ProjectConfigPath returns the config set and path for project-specific |
+// configuration. |
+func ProjectConfigPath(project config.ProjectName) (string, string) { |
+ return fmt.Sprintf("projects/%s", project), svcconfig.ProjectConfigFilename |
+} |
+ |
+// ProjectConfig loads the the project config protobuf from the config service. |
nodir
2016/05/18 16:05:35
the the
dnj (Google)
2016/05/18 16:46:06
Done.
|
+// |
+// If the configuration was not present, config.ErrNoConfig will be returned. |
+func ProjectConfig(c context.Context, project config.ProjectName) (*svcconfig.ProjectConfig, error) { |
+ configSet, configPath := ProjectConfigPath(project) |
+ cfg, err := config.Get(c).GetConfig(configSet, configPath, false) |
+ if err != nil { |
+ return nil, err |
+ } |
+ |
+ var pcfg svcconfig.ProjectConfig |
+ if err := proto.UnmarshalText(cfg.Content, &pcfg); err != nil { |
+ log.Fields{ |
+ log.ErrorKey: err, |
+ "contentHash": cfg.ContentHash, |
+ "path": cfg.Path, |
+ "configSet": cfg.ConfigSet, |
nodir
2016/05/18 16:05:35
somewhat sort keys?
dnj (Google)
2016/05/18 16:46:06
I'll put them in a logically-useful order, so in t
|
+ }.Errorf(c, "Failed to unmarshal project configuration.") |
+ return nil, ErrInvalidConfig |
+ } |
+ |
+ return &pcfg, nil |
+} |
+ |
// Projects lists the registered LogDog projects. |
func Projects(c context.Context) ([]string, error) { |
projects, err := config.Get(c).GetProjects() |