| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package services | 5 package services |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "github.com/luci/luci-go/appengine/logdog/coordinator/config" | |
| 9 "github.com/luci/luci-go/common/api/logdog_coordinator/services/v1" | 8 "github.com/luci/luci-go/common/api/logdog_coordinator/services/v1" |
| 10 "github.com/luci/luci-go/common/grpcutil" | 9 "github.com/luci/luci-go/common/grpcutil" |
| 11 log "github.com/luci/luci-go/common/logging" | 10 log "github.com/luci/luci-go/common/logging" |
| 12 "github.com/luci/luci-go/common/proto/google" | 11 "github.com/luci/luci-go/common/proto/google" |
| 13 "golang.org/x/net/context" | 12 "golang.org/x/net/context" |
| 14 ) | 13 ) |
| 15 | 14 |
| 16 // GetConfig allows a service to retrieve the current service configuration | 15 // GetConfig allows a service to retrieve the current service configuration |
| 17 // parameters. | 16 // parameters. |
| 18 func (*Server) GetConfig(c context.Context, req *google.Empty) (*logdog.GetConfi
gResponse, error) { | 17 func (s *Server) GetConfig(c context.Context, req *google.Empty) (*logdog.GetCon
figResponse, error) { |
| 19 » if err := Auth(c); err != nil { | 18 » svc := s.GetServices() |
| 19 » if err := Auth(c, svc); err != nil { |
| 20 return nil, err | 20 return nil, err |
| 21 } | 21 } |
| 22 | 22 |
| 23 » cfg, err := config.LoadGlobalConfig(c) | 23 » gcfg, _, err := svc.Config(c) |
| 24 if err != nil { | 24 if err != nil { |
| 25 log.Fields{ | 25 log.Fields{ |
| 26 log.ErrorKey: err, | 26 log.ErrorKey: err, |
| 27 }.Errorf(c, "Failed to load configuration.") | 27 }.Errorf(c, "Failed to load configuration.") |
| 28 return nil, grpcutil.Internal | 28 return nil, grpcutil.Internal |
| 29 } | 29 } |
| 30 | 30 |
| 31 return &logdog.GetConfigResponse{ | 31 return &logdog.GetConfigResponse{ |
| 32 » » ConfigServiceUrl: cfg.ConfigServiceURL, | 32 » » ConfigServiceUrl: gcfg.ConfigServiceURL, |
| 33 » » ConfigSet: cfg.ConfigSet, | 33 » » ConfigSet: gcfg.ConfigSet, |
| 34 » » ConfigPath: cfg.ConfigPath, | 34 » » ConfigPath: gcfg.ConfigPath, |
| 35 }, nil | 35 }, nil |
| 36 } | 36 } |
| OLD | NEW |