Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: milo/appengine/swarming/buildinfo.go

Issue 2765383002: Milo: Move instance configuration to luci-config (Closed)
Patch Set: Review Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « milo/appengine/swarming/build.go ('k') | milo/appengine/swarming/html.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The LUCI Authors. All rights reserved. 1 // Copyright 2017 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 swarming 5 package swarming
6 6
7 import ( 7 import (
8 "strconv" 8 "strconv"
9 "strings" 9 "strings"
10 "unicode/utf8" 10 "unicode/utf8"
(...skipping 19 matching lines...) Expand all
30 bl buildLoader 30 bl buildLoader
31 31
32 // swarmingServiceFunc returns a swarmingService instance for the suppli ed 32 // swarmingServiceFunc returns a swarmingService instance for the suppli ed
33 // parameters. 33 // parameters.
34 // 34 //
35 // If nil, a production fetcher will be generated. 35 // If nil, a production fetcher will be generated.
36 swarmingServiceFunc func(c context.Context, host string) (swarmingServic e, error) 36 swarmingServiceFunc func(c context.Context, host string) (swarmingServic e, error)
37 } 37 }
38 38
39 func (p *BuildInfoProvider) newSwarmingService(c context.Context, host string) ( swarmingService, error) { 39 func (p *BuildInfoProvider) newSwarmingService(c context.Context, host string) ( swarmingService, error) {
40 » fn := p.swarmingServiceFunc 40 » if p.swarmingServiceFunc == nil {
41 » if fn == nil { 41 » » return newProdService(c, host)
42 » » fn = getSwarmingService
43 } 42 }
44 » return fn(c, host) 43 » return p.swarmingServiceFunc(c, host)
45 } 44 }
46 45
47 // GetBuildInfo resolves a Milo protobuf Step for a given Swarming task. 46 // GetBuildInfo resolves a Milo protobuf Step for a given Swarming task.
48 func (p *BuildInfoProvider) GetBuildInfo(c context.Context, req *milo.BuildInfoR equest_Swarming, 47 func (p *BuildInfoProvider) GetBuildInfo(c context.Context, req *milo.BuildInfoR equest_Swarming,
49 projectHint cfgtypes.ProjectName) (*milo.BuildInfoResponse, error) { 48 projectHint cfgtypes.ProjectName) (*milo.BuildInfoResponse, error) {
50 49
51 // Load the Swarming task (no log content). 50 // Load the Swarming task (no log content).
52 sf, err := p.newSwarmingService(c, req.Host) 51 sf, err := p.newSwarmingService(c, req.Host)
53 if err != nil { 52 if err != nil {
54 logging.WithError(err).Errorf(c, "Failed to create Swarming fetc her.") 53 logging.WithError(err).Errorf(c, "Failed to create Swarming fetc her.")
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 lastChar, lastCharSize := utf8.DecodeLastRuneInString(taskID) 267 lastChar, lastCharSize := utf8.DecodeLastRuneInString(taskID)
269 v, err := strconv.ParseUint(string(lastChar), 16, 8) 268 v, err := strconv.ParseUint(string(lastChar), 16, 8)
270 if err != nil { 269 if err != nil {
271 return "", errors.Annotate(err).Reason("failed to parse hex from rune: %(rune)r"). 270 return "", errors.Annotate(err).Reason("failed to parse hex from rune: %(rune)r").
272 D("rune", lastChar). 271 D("rune", lastChar).
273 Err() 272 Err()
274 } 273 }
275 274
276 return taskID[:len(taskID)-lastCharSize] + strconv.FormatUint((v|uint64( tryNumber)), 16), nil 275 return taskID[:len(taskID)-lastCharSize] + strconv.FormatUint((v|uint64( tryNumber)), 16), nil
277 } 276 }
OLDNEW
« no previous file with comments | « milo/appengine/swarming/build.go ('k') | milo/appengine/swarming/html.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698