| 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 catalog implements a part that talks to luci-config service to fetch | 5 // Package catalog implements a part that talks to luci-config service to fetch |
| 6 // and parse job definitions. Catalog knows about all task types and can | 6 // and parse job definitions. Catalog knows about all task types and can |
| 7 // instantiate task.Manager's. | 7 // instantiate task.Manager's. |
| 8 package catalog | 8 package catalog |
| 9 | 9 |
| 10 import ( | 10 import ( |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if projectName == "" { | 177 if projectName == "" { |
| 178 logging.Warningf(c, "Unexpected ConfigSet: %s", meta.Con
figSet) | 178 logging.Warningf(c, "Unexpected ConfigSet: %s", meta.Con
figSet) |
| 179 } else { | 179 } else { |
| 180 out = append(out, string(projectName)) | 180 out = append(out, string(projectName)) |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 return out, nil | 183 return out, nil |
| 184 } | 184 } |
| 185 | 185 |
| 186 func (cat *catalog) GetProjectJobs(c context.Context, projectID string) ([]Defin
ition, error) { | 186 func (cat *catalog) GetProjectJobs(c context.Context, projectID string) ([]Defin
ition, error) { |
| 187 // TODO(vadimsh): This is a workaround for crbug.com/710619. Remove it o
nce |
| 188 // the bug is fixed. |
| 189 projects, err := cat.GetAllProjects(c) |
| 190 if err != nil { |
| 191 return nil, err |
| 192 } |
| 193 found := false |
| 194 for _, p := range projects { |
| 195 if p == projectID { |
| 196 found = true |
| 197 } |
| 198 } |
| 199 if !found { |
| 200 return nil, nil |
| 201 } |
| 202 |
| 187 configSet := cfgtypes.ProjectConfigSet(cfgtypes.ProjectName(projectID)) | 203 configSet := cfgtypes.ProjectConfigSet(cfgtypes.ProjectName(projectID)) |
| 188 configSetURL, err := cfgclient.GetConfigSetURL(c, cfgclient.AsService, c
onfigSet) | 204 configSetURL, err := cfgclient.GetConfigSetURL(c, cfgclient.AsService, c
onfigSet) |
| 189 switch err { | 205 switch err { |
| 190 case nil: // Continue | 206 case nil: // Continue |
| 191 case cfgclient.ErrNoConfig: | 207 case cfgclient.ErrNoConfig: |
| 192 return nil, nil | 208 return nil, nil |
| 193 default: | 209 default: |
| 194 return nil, err | 210 return nil, err |
| 195 } | 211 } |
| 196 | 212 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 field := v.Field(i) | 432 field := v.Field(i) |
| 417 if field.Type() == taskType { | 433 if field.Type() == taskType { |
| 418 field.Set(reflect.ValueOf(task)) | 434 field.Set(reflect.ValueOf(task)) |
| 419 return proto.Marshal(&wrapper) | 435 return proto.Marshal(&wrapper) |
| 420 } | 436 } |
| 421 } | 437 } |
| 422 // This can happen only if TaskDefWrapper wasn't updated when a new task
type | 438 // This can happen only if TaskDefWrapper wasn't updated when a new task
type |
| 423 // was added. This is a developer's mistake, not a config mistake. | 439 // was added. This is a developer's mistake, not a config mistake. |
| 424 return nil, fmt.Errorf("could not find a field of type %T in TaskDefWrap
per", task) | 440 return nil, fmt.Errorf("could not find a field of type %T in TaskDefWrap
per", task) |
| 425 } | 441 } |
| OLD | NEW |