| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 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 client implements a config client backend for a configuration client. | 5 // Package client implements a config client backend for a configuration client. |
| 6 package client | 6 package client |
| 7 | 7 |
| 8 import ( | 8 import ( |
| 9 "fmt" | 9 "fmt" |
| 10 "net/http" | 10 "net/http" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 svc := be.GetConfigInterface(c, p.Authority) | 69 svc := be.GetConfigInterface(c, p.Authority) |
| 70 | 70 |
| 71 var fn func(context.Context, string, bool) ([]config.Config, error) | 71 var fn func(context.Context, string, bool) ([]config.Config, error) |
| 72 switch t { | 72 switch t { |
| 73 case backend.GetAllProject: | 73 case backend.GetAllProject: |
| 74 fn = svc.GetProjectConfigs | 74 fn = svc.GetProjectConfigs |
| 75 case backend.GetAllRef: | 75 case backend.GetAllRef: |
| 76 fn = svc.GetRefConfigs | 76 fn = svc.GetRefConfigs |
| 77 default: | 77 default: |
| 78 » » return nil, errors.Reason("unknown GetAllType: %(type)q").D("typ
e", t).Err() | 78 » » return nil, errors.Reason("unknown GetAllType: %q", t).Err() |
| 79 } | 79 } |
| 80 | 80 |
| 81 cfgs, err := fn(c, path, !p.Content) | 81 cfgs, err := fn(c, path, !p.Content) |
| 82 if err != nil || len(cfgs) == 0 { | 82 if err != nil || len(cfgs) == 0 { |
| 83 return nil, translateConfigErr(err) | 83 return nil, translateConfigErr(err) |
| 84 } | 84 } |
| 85 | 85 |
| 86 items := make([]*backend.Item, len(cfgs)) | 86 items := make([]*backend.Item, len(cfgs)) |
| 87 for i := range cfgs { | 87 for i := range cfgs { |
| 88 items[i] = makeItem(&cfgs[i]) | 88 items[i] = makeItem(&cfgs[i]) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 case backend.AsAnonymous: | 190 case backend.AsAnonymous: |
| 191 return auth.NoAuth | 191 return auth.NoAuth |
| 192 case backend.AsService: | 192 case backend.AsService: |
| 193 return auth.AsSelf | 193 return auth.AsSelf |
| 194 case backend.AsUser: | 194 case backend.AsUser: |
| 195 return auth.AsUser | 195 return auth.AsUser |
| 196 default: | 196 default: |
| 197 panic(fmt.Errorf("unknown config Authority (%d)", a)) | 197 panic(fmt.Errorf("unknown config Authority (%d)", a)) |
| 198 } | 198 } |
| 199 } | 199 } |
| OLD | NEW |