| 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 "fmt" | |
| 9 "sort" | 8 "sort" |
| 10 | 9 |
| 11 log "github.com/luci/luci-go/common/logging" | 10 log "github.com/luci/luci-go/common/logging" |
| 12 "github.com/luci/luci-go/logdog/api/config/svcconfig" | 11 "github.com/luci/luci-go/logdog/api/config/svcconfig" |
| 13 "github.com/luci/luci-go/luci_config/common/cfgtypes" | 12 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 14 "github.com/luci/luci-go/luci_config/server/cfgclient" | 13 "github.com/luci/luci-go/luci_config/server/cfgclient" |
| 15 "github.com/luci/luci-go/luci_config/server/cfgclient/textproto" | 14 "github.com/luci/luci-go/luci_config/server/cfgclient/textproto" |
| 16 | 15 |
| 17 "golang.org/x/net/context" | 16 "golang.org/x/net/context" |
| 18 ) | 17 ) |
| 19 | 18 |
| 20 // ProjectConfigPath returns the path of the project-specific configuration. | 19 // ProjectConfigPath returns the path of the project-specific configuration. |
| 21 // This path should be used with a project config set. | 20 // This path should be used with a project config set. |
| 22 // | 21 // |
| 23 // A given project's configuration is named after the current App ID. | 22 // A given project's configuration is named after the current App ID. |
| 24 func ProjectConfigPath(c context.Context) string { | 23 func ProjectConfigPath(c context.Context) string { |
| 25 » return fmt.Sprintf("%s.cfg", cfgclient.CurrentServiceName(c)) | 24 » return svcconfig.ProjectConfigPath(cfgclient.CurrentServiceName(c)) |
| 26 } | 25 } |
| 27 | 26 |
| 28 // ProjectConfig loads the project config protobuf from the config service. | 27 // ProjectConfig loads the project config protobuf from the config service. |
| 29 // | 28 // |
| 30 // This function will return: | 29 // This function will return: |
| 31 // - nil, if the project exists and the configuration successfully loaded | 30 // - nil, if the project exists and the configuration successfully loaded |
| 32 // - config.ErrNoConfig if the project configuration was not present. | 31 // - config.ErrNoConfig if the project configuration was not present. |
| 33 // - ErrInvalidConfig if the project configuration was present, but could n
ot | 32 // - ErrInvalidConfig if the project configuration was present, but could n
ot |
| 34 // be loaded. | 33 // be loaded. |
| 35 // - Some other error if an error occurred that does not fit one of the | 34 // - Some other error if an error occurred that does not fit one of the |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // The list will be alphabetically sorted. | 92 // The list will be alphabetically sorted. |
| 94 func ActiveUserProjects(c context.Context) ([]cfgtypes.ProjectName, error) { | 93 func ActiveUserProjects(c context.Context) ([]cfgtypes.ProjectName, error) { |
| 95 return ProjectNames(c, cfgclient.AsUser) | 94 return ProjectNames(c, cfgclient.AsUser) |
| 96 } | 95 } |
| 97 | 96 |
| 98 type projectNameSlice []cfgtypes.ProjectName | 97 type projectNameSlice []cfgtypes.ProjectName |
| 99 | 98 |
| 100 func (s projectNameSlice) Len() int { return len(s) } | 99 func (s projectNameSlice) Len() int { return len(s) } |
| 101 func (s projectNameSlice) Less(i, j int) bool { return s[i] < s[j] } | 100 func (s projectNameSlice) Less(i, j int) bool { return s[i] < s[j] } |
| 102 func (s projectNameSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } | 101 func (s projectNameSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } |
| OLD | NEW |