| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package config | 5 package config |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "net/url" | 8 "net/url" |
| 9 | 9 |
| 10 "github.com/luci/luci-go/common/errors" | 10 "github.com/luci/luci-go/common/errors" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // ConfigSet is the name of the service config set that is being used. | 33 // ConfigSet is the name of the service config set that is being used. |
| 34 ConfigSet cfgtypes.ConfigSet `json:"-"` | 34 ConfigSet cfgtypes.ConfigSet `json:"-"` |
| 35 // ServiceConfigPath is the path within ConfigSet of the service | 35 // ServiceConfigPath is the path within ConfigSet of the service |
| 36 // configuration. | 36 // configuration. |
| 37 ServiceConfigPath string `json:"-"` | 37 ServiceConfigPath string `json:"-"` |
| 38 } | 38 } |
| 39 | 39 |
| 40 // ServiceConfigPath returns the config set and path for this application's | 40 // ServiceConfigPath returns the config set and path for this application's |
| 41 // service configuration. | 41 // service configuration. |
| 42 func ServiceConfigPath(c context.Context) (cfgtypes.ConfigSet, string) { | 42 func ServiceConfigPath(c context.Context) (cfgtypes.ConfigSet, string) { |
| 43 » return cfgclient.CurrentServiceConfigSet(c), svcconfig.ServiceConfigFile
name | 43 » return cfgclient.CurrentServiceConfigSet(c), svcconfig.ServiceConfigPath |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Load loads the service configuration. This includes: | 46 // Load loads the service configuration. This includes: |
| 47 // - The config service settings. | 47 // - The config service settings. |
| 48 // - The service configuration, loaded from the config service. | 48 // - The service configuration, loaded from the config service. |
| 49 // - Additional Settings data from datastore via settings. | 49 // - Additional Settings data from datastore via settings. |
| 50 // | 50 // |
| 51 // The service config is minimally validated prior to being returned. | 51 // The service config is minimally validated prior to being returned. |
| 52 func Load(c context.Context) (*Config, error) { | 52 func Load(c context.Context) (*Config, error) { |
| 53 // Unmarshal the config into service configuration. | 53 // Unmarshal the config into service configuration. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 func validateServiceConfig(cc *svcconfig.Config) error { | 89 func validateServiceConfig(cc *svcconfig.Config) error { |
| 90 switch { | 90 switch { |
| 91 case cc == nil: | 91 case cc == nil: |
| 92 return errors.New("configuration is nil") | 92 return errors.New("configuration is nil") |
| 93 case cc.GetCoordinator() == nil: | 93 case cc.GetCoordinator() == nil: |
| 94 return errors.New("no Coordinator configuration") | 94 return errors.New("no Coordinator configuration") |
| 95 default: | 95 default: |
| 96 return nil | 96 return nil |
| 97 } | 97 } |
| 98 } | 98 } |
| OLD | NEW |