| Index: appengine/logdog/coordinator/coordinatorTest/context.go
|
| diff --git a/appengine/logdog/coordinator/coordinatorTest/context.go b/appengine/logdog/coordinator/coordinatorTest/context.go
|
| index c2327641bad6b7cb944ac921933d79368e07e1ce..6b52e16c377c0ad3b6f1d9f34cfbc4c783a7e0c5 100644
|
| --- a/appengine/logdog/coordinator/coordinatorTest/context.go
|
| +++ b/appengine/logdog/coordinator/coordinatorTest/context.go
|
| @@ -19,7 +19,6 @@ import (
|
| "github.com/luci/luci-go/common/gcloud/gs"
|
| "github.com/luci/luci-go/common/logging"
|
| "github.com/luci/luci-go/common/logging/gologger"
|
| - 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/authtest"
|
| @@ -88,6 +87,17 @@ func (e *Environment) ModServiceConfig(c context.Context, fn func(*svcconfig.Coo
|
| })
|
| }
|
|
|
| +// ModProjectConfig loads the current configuration for the named project,
|
| +// invokes the callback with its contents, and writes the result back to config.
|
| +func (e *Environment) ModProjectConfig(proj luciConfig.ProjectName, fn func(*svcconfig.ProjectConfig)) {
|
| + configSet, configPath := config.ProjectConfigPath(proj)
|
| +
|
| + var pcfg svcconfig.ProjectConfig
|
| + e.modTextProtobuf(configSet, configPath, &pcfg, func() {
|
| + fn(&pcfg)
|
| + })
|
| +}
|
| +
|
| // DrainTumbleAll drains all Tumble instances across all namespaces.
|
| func (e *Environment) DrainTumbleAll(c context.Context) {
|
| projects, err := luciConfig.Get(c).GetProjects()
|
| @@ -119,13 +129,16 @@ func (e *Environment) modTextProtobuf(configSet, path string, msg proto.Message,
|
| }
|
|
|
| fn()
|
| + e.addConfigEntry(configSet, path, proto.MarshalTextString(msg))
|
| +}
|
|
|
| +func (e *Environment) addConfigEntry(configSet, path, content string) {
|
| cset := e.Config[configSet]
|
| if cset == nil {
|
| cset = make(map[string]string)
|
| e.Config[configSet] = cset
|
| }
|
| - cset[path] = proto.MarshalTextString(msg)
|
| + cset[path] = content
|
| }
|
|
|
| // Install creates a testing Context and installs common test facilities into
|
| @@ -183,18 +196,18 @@ func Install() (context.Context, *Environment) {
|
| e.ConfigIface = luciConfig.Get(c)
|
|
|
| // luci-config: Projects.
|
| - addProjectConfig := func(name luciConfig.ProjectName, localName string, access ...string) {
|
| - var cfg configProto.ProjectCfg
|
| - e.modTextProtobuf(fmt.Sprintf("projects/%s", name), "project.cfg", &cfg, func() {
|
| - cfg.Name = &localName
|
| - cfg.Access = access
|
| + addProjectConfig := func(proj luciConfig.ProjectName, access ...string) {
|
| + e.ModProjectConfig(proj, func(pcfg *svcconfig.ProjectConfig) {
|
| + pcfg.ReaderAuthGroups = access
|
| })
|
| }
|
| - addProjectConfig("proj-foo", "Foo Project", "group:all")
|
| - addProjectConfig("proj-bar", "Bar Project", "group:all")
|
| - addProjectConfig("proj-baz", "Baz Project", "group:all")
|
| - addProjectConfig("proj-qux", "Qux Project", "group:all")
|
| - addProjectConfig("proj-exclusive", "Exclusive Project", "group:auth")
|
| + addProjectConfig("proj-foo", "all")
|
| + addProjectConfig("proj-bar", "all")
|
| + addProjectConfig("proj-exclusive", "auth")
|
| +
|
| + // Add a project without a LogDog project config.
|
| + e.addConfigEntry("projects/proj-unconfigured", "not-logdog.cfg", "junk")
|
| + e.addConfigEntry("projects/proj-malformed", svcconfig.ProjectConfigFilename, "!!! not a text protobuf !!!")
|
|
|
| // luci-config: Coordinator Defaults
|
| e.ModServiceConfig(c, func(cfg *svcconfig.Coordinator) {
|
|
|