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

Unified Diff: logdog/appengine/coordinator/coordinatorTest/context.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/coordinatorTest/context.go
diff --git a/logdog/appengine/coordinator/coordinatorTest/context.go b/logdog/appengine/coordinator/coordinatorTest/context.go
index 4edf4b589ac4f73c763b8f8bdfd27ca37a8b525e..1161a572f9256828cd7196c37bcfc50d4b6a84aa 100644
--- a/logdog/appengine/coordinator/coordinatorTest/context.go
+++ b/logdog/appengine/coordinator/coordinatorTest/context.go
@@ -17,6 +17,7 @@ import (
"github.com/luci/luci-go/common/gcloud/gs"
"github.com/luci/luci-go/common/logging"
"github.com/luci/luci-go/common/logging/gologger"
+ configPB "github.com/luci/luci-go/common/proto/config"
"github.com/luci/luci-go/common/proto/google"
"github.com/luci/luci-go/logdog/api/config/svcconfig"
"github.com/luci/luci-go/logdog/appengine/coordinator"
@@ -26,6 +27,9 @@ import (
"github.com/luci/luci-go/server/auth"
"github.com/luci/luci-go/server/auth/authtest"
"github.com/luci/luci-go/server/auth/identity"
+ serverConfig "github.com/luci/luci-go/server/config"
+ "github.com/luci/luci-go/server/config/testconfig"
+ "github.com/luci/luci-go/server/config/textproto"
"github.com/luci/luci-go/server/settings"
"github.com/luci/luci-go/tumble"
@@ -50,9 +54,6 @@ type Environment struct {
// Config is the luci-config configuration map that is installed.
Config map[string]memory.ConfigSet
- // ConfigIface is a reference to the memory config.Interface that Config is
- // installed into.
- ConfigIface luciConfig.Interface
// Services is the set of installed Coordinator services.
Services Services
@@ -89,7 +90,6 @@ func (e *Environment) JoinGroup(g string) {
// LeaveAllGroups clears all auth groups that the user is currently a member of.
func (e *Environment) LeaveAllGroups() {
e.AuthState.IdentityGroups = nil
- e.JoinGroup("all")
}
// ClearCoordinatorConfig removes the Coordinator configuration entry,
@@ -123,30 +123,22 @@ func (e *Environment) ModProjectConfig(c context.Context, proj luciConfig.Projec
// IterateTumbleAll iterates all Tumble instances across all namespaces.
func (e *Environment) IterateTumbleAll(c context.Context) {
- projects, err := luciConfig.GetProjects(c)
+ projects, err := config.ActiveProjects(c)
if err != nil {
panic(err)
}
for _, proj := range projects {
- WithProjectNamespace(c, luciConfig.ProjectName(proj.ID), func(c context.Context) {
+ WithProjectNamespace(c, proj, func(c context.Context) {
e.Tumble.Iterate(c)
})
}
}
func (e *Environment) modTextProtobuf(c context.Context, configSet, path string, msg proto.Message, fn func()) {
- cfg, err := e.ConfigIface.GetConfig(c, configSet, path, false)
-
- switch err {
- case nil:
- if err := proto.UnmarshalText(cfg.Content, msg); err != nil {
- panic(err)
- }
-
- case luciConfig.ErrNoConfig:
+ switch err := serverConfig.Get(c, serverConfig.AsService, configSet, path, textproto.Message(msg), nil); err {
+ case nil, luciConfig.ErrNoConfig:
break
-
default:
panic(err)
}
@@ -224,14 +216,16 @@ func Install() (context.Context, *Environment) {
c = settings.Use(c, settings.New(&settings.MemoryStorage{}))
// Setup luci-config configuration.
- e.ConfigIface = memory.New(e.Config)
- c = luciConfig.SetImplementation(c, e.ConfigIface)
+ c = testconfig.WithCommonClient(c, memory.New(e.Config))
// luci-config: Projects.
projectName := info.AppID(c)
addProjectConfig := func(proj luciConfig.ProjectName, access ...string) {
+ projectAccesses := make([]string, len(access))
+
+ // Build our service config. Also builds "projectAccesses".
e.ModProjectConfig(c, proj, func(pcfg *svcconfig.ProjectConfig) {
- for _, a := range access {
+ for i, a := range access {
parts := strings.SplitN(a, ":", 2)
group, field := parts[0], &pcfg.ReaderAuthGroups
if len(parts) == 2 {
@@ -245,6 +239,15 @@ func Install() (context.Context, *Environment) {
}
}
*field = append(*field, group)
+ projectAccesses[i] = fmt.Sprintf("group:%s", group)
+ }
+ })
+
+ var pcfg configPB.ProjectCfg
+ e.modTextProtobuf(c, serverConfig.ProjectConfigSet(proj), serverConfig.ProjectConfigPath, &pcfg, func() {
+ pcfg = configPB.ProjectCfg{
+ Name: proto.String(string(proj)),
+ Access: projectAccesses,
}
})
}

Powered by Google App Engine
This is Rietveld 408576698