| 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) {
|
|
|