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

Unified Diff: scheduler/appengine/catalog/catalog.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: scheduler/appengine/catalog/catalog.go
diff --git a/scheduler/appengine/catalog/catalog.go b/scheduler/appengine/catalog/catalog.go
index 40dd88a96a5ed9e30e9a1b2bdf2a01a9cec4b7c6..cdb5f4fdd3e978b3534805ab6fa930c5d44c16f3 100644
--- a/scheduler/appengine/catalog/catalog.go
+++ b/scheduler/appengine/catalog/catalog.go
@@ -18,8 +18,10 @@ import (
"golang.org/x/net/context"
"github.com/luci/gae/service/info"
- "github.com/luci/luci-go/common/config"
+ commonConfig "github.com/luci/luci-go/common/config"
"github.com/luci/luci-go/common/logging"
+ "github.com/luci/luci-go/server/config"
+ "github.com/luci/luci-go/server/config/textproto"
"github.com/luci/luci-go/scheduler/appengine/messages"
"github.com/luci/luci-go/scheduler/appengine/schedule"
@@ -164,25 +166,26 @@ func (cat *catalog) UnmarshalTask(task []byte) (proto.Message, error) {
func (cat *catalog) GetAllProjects(c context.Context) ([]string, error) {
// Enumerate all projects that have <config>.cfg. Do not fetch actual configs
// yet.
- cfgs, err := config.GetProjectConfigs(c, cat.configFile(c), true)
- if err != nil {
+ var metas []*config.Meta
+ if err := config.GetAll(c, config.AsService, config.Project, cat.configFile(c), nil, &metas); err != nil {
return nil, err
}
- out := make([]string, 0, len(cfgs))
- for _, cfg := range cfgs {
- // ConfigSet must be "projects/<project-id>". Verify that.
- chunks := strings.Split(cfg.ConfigSet, "/")
- if len(chunks) != 2 || chunks[0] != "projects" {
- logging.Warningf(c, "Unexpected ConfigSet: %s", cfg.ConfigSet)
+
+ out := make([]string, 0, len(metas))
+ for _, meta := range metas {
+ projectName, _, _ := config.ParseProjectConfigSet(meta.ConfigSet)
+ if projectName == "" {
+ logging.Warningf(c, "Unexpected ConfigSet: %s", meta.ConfigSet)
} else {
- out = append(out, chunks[1])
+ out = append(out, string(projectName))
}
}
return out, nil
}
func (cat *catalog) GetProjectJobs(c context.Context, projectID string) ([]Definition, error) {
- configSetURL, err := config.GetConfigSetLocation(c, "projects/"+projectID)
+ configSet := config.ProjectConfigSet(commonConfig.ProjectName(projectID))
+ configSetURL, err := config.GetConfigSetURL(c, config.AsService, configSet)
switch err {
case nil: // Continue
case config.ErrNoConfig:
@@ -191,21 +194,23 @@ func (cat *catalog) GetProjectJobs(c context.Context, projectID string) ([]Defin
return nil, err
}
- rawCfg, err := config.GetConfig(c, "projects/"+projectID, cat.configFile(c), false)
- if err == config.ErrNoConfig {
+ var (
+ cfg messages.ProjectConfig
+ meta config.Meta
+ )
+ switch err := config.Get(c, config.AsService, configSet, cat.configFile(c), textproto.Message(&cfg), &meta); err {
+ case nil:
+ break
+ case config.ErrNoConfig:
return nil, nil
- }
- if err != nil {
+ default:
return nil, err
}
- revisionURL := getRevisionURL(configSetURL, rawCfg.Revision, rawCfg.Path)
+
+ revisionURL := getRevisionURL(&configSetURL, meta.Revision, meta.Path)
if revisionURL != "" {
logging.Infof(c, "Importing %s", revisionURL)
}
- cfg := messages.ProjectConfig{}
- if err = proto.UnmarshalText(rawCfg.Content, &cfg); err != nil {
- return nil, err
- }
out := make([]Definition, 0, len(cfg.Job)+len(cfg.Trigger))
@@ -239,7 +244,7 @@ func (cat *catalog) GetProjectJobs(c context.Context, projectID string) ([]Defin
out = append(out, Definition{
JobID: fmt.Sprintf("%s/%s", projectID, job.Id),
Flavor: flavor,
- Revision: rawCfg.Revision,
+ Revision: meta.Revision,
RevisionURL: revisionURL,
Schedule: schedule,
Task: packed,
@@ -272,7 +277,7 @@ func (cat *catalog) GetProjectJobs(c context.Context, projectID string) ([]Defin
out = append(out, Definition{
JobID: fmt.Sprintf("%s/%s", projectID, trigger.Id),
Flavor: JobFlavorTrigger,
- Revision: rawCfg.Revision,
+ Revision: meta.Revision,
RevisionURL: revisionURL,
Schedule: schedule,
Task: packed,

Powered by Google App Engine
This is Rietveld 408576698