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

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

Issue 1971623002: LogDog: Enable Coordinator to load project configs (Closed) Base URL: https://github.com/luci/luci-go@logdog-project-config
Patch Set: rebase (auto) Created 4 years, 7 months 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
« no previous file with comments | « appengine/logdog/coordinator/coordinatorTest/service.go ('k') | appengine/logdog/coordinator/service.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/logdog/coordinator/project.go
diff --git a/appengine/logdog/coordinator/project.go b/appengine/logdog/coordinator/project.go
index eefe3ca00f5b69658bab857c2ad1c57d2d513840..0553620a5bfe27caa9a059bcde0c247b9fd94e46 100644
--- a/appengine/logdog/coordinator/project.go
+++ b/appengine/logdog/coordinator/project.go
@@ -8,7 +8,9 @@ import (
"strings"
"github.com/luci/gae/service/datastore/meta"
+ "github.com/luci/gae/service/info"
"github.com/luci/luci-go/common/config"
+ "github.com/luci/luci-go/common/proto/logdog/svcconfig"
"golang.org/x/net/context"
)
@@ -34,6 +36,27 @@ func ProjectFromNamespace(ns string) config.ProjectName {
return config.ProjectName(ns[len(projectNamespacePrefix):])
}
+// CurrentProject returns the current project based on the currently-loaded
+// namespace.
+//
+// If there is no current namespace, or if the current namespace is not a valid
+// project namespace, an empty string will be returned.
+func CurrentProject(c context.Context) config.ProjectName {
+ if ns, ok := info.Get(c).GetNamespace(); ok {
+ return ProjectFromNamespace(ns)
+ }
+ return ""
+}
+
+// CurrentProjectConfig returns the project-specific configuration for the
+// current project.
+//
+// If there is no current project namespace, or if the current project has no
+// configuration, config.ErrInvalidConfig will be returned.
+func CurrentProjectConfig(c context.Context) (*svcconfig.ProjectConfig, error) {
+ return GetServices(c).ProjectConfig(c, CurrentProject(c))
+}
+
// AllProjectsWithNamespaces scans current namespaces and returns those that
// belong to LUCI projects.
func AllProjectsWithNamespaces(c context.Context) ([]config.ProjectName, error) {
« no previous file with comments | « appengine/logdog/coordinator/coordinatorTest/service.go ('k') | appengine/logdog/coordinator/service.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698