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

Unified Diff: milo/common/config.go

Issue 2955223002: Milo: Buildbucket PubSub ingestion outline (Closed)
Patch Set: rebase Created 3 years, 5 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 | « milo/buildsource/buildbucket/pubsub.go ('k') | milo/common/config_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/common/config.go
diff --git a/milo/common/config.go b/milo/common/config.go
index 360df2da73c7df0872e4d50a7e79606172386fa5..e8e9fa704f6b9d472a67ff6f1a4cef9f3c79d23d 100644
--- a/milo/common/config.go
+++ b/milo/common/config.go
@@ -110,7 +110,7 @@ func GetCurrentServiceConfig(c context.Context) (*ServiceConfig, error) {
// UpdateServiceConfig fetches the service config from luci-config
// and then stores a snapshot of the configuration in datastore.
-func UpdateServiceConfig(c context.Context) error {
+func UpdateServiceConfig(c context.Context) (*config.Settings, error) {
// Load the settings from luci-config.
cs := string(cfgclient.CurrentServiceConfigSet(c))
// Acquire the raw config client.
@@ -118,12 +118,13 @@ func UpdateServiceConfig(c context.Context) error {
// Our global config name is called settings.cfg.
cfg, err := lucicfg.GetConfig(c, cs, "settings.cfg", false)
if err != nil {
- return fmt.Errorf("could not load settings.cfg from luci-config: %s", err)
+ return nil, fmt.Errorf("could not load settings.cfg from luci-config: %s", err)
}
settings := &config.Settings{}
err = proto.UnmarshalText(cfg.Content, settings)
if err != nil {
- return fmt.Errorf("could not unmarshal proto from luci-config:\n%s", cfg.Content)
+ return nil, fmt.Errorf(
+ "could not unmarshal proto from luci-config:\n%s", cfg.Content)
}
newConfig := ServiceConfig{
ID: ServiceConfigID,
@@ -133,7 +134,7 @@ func UpdateServiceConfig(c context.Context) error {
}
newConfig.Data, err = proto.Marshal(settings)
if err != nil {
- return fmt.Errorf("could not marshal proto into binary\n%s", newConfig.Text)
+ return nil, fmt.Errorf("could not marshal proto into binary\n%s", newConfig.Text)
}
// Do the revision check & swap in a datastore transaction.
@@ -160,11 +161,11 @@ func UpdateServiceConfig(c context.Context) error {
}, nil)
if err != nil {
- return fmt.Errorf("failed to update config entry in transaction", err)
+ return nil, fmt.Errorf("failed to update config entry in transaction", err)
}
logging.Infof(c, "successfully updated to new config")
- return nil
+ return settings, nil
}
// UpdateProjectConfigs internal project configuration based off luci-config.
« no previous file with comments | « milo/buildsource/buildbucket/pubsub.go ('k') | milo/common/config_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698