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

Side by Side Diff: scripts/slave/recipes/infra/recipe_roll_tryjob.py

Issue 1853423002: Fix authutil call (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Whoops double call. Created 4 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 | « no previous file | scripts/slave/recipes/infra/recipe_roll_tryjob.expected/bad_patches.json » ('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 (c) 2014 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Rolls recipes.cfg dependencies.""" 5 """Rolls recipes.cfg dependencies."""
6 6
7 DEPS = [ 7 DEPS = [
8 'depot_tools/bot_update', 8 'depot_tools/bot_update',
9 'depot_tools/gclient', 9 'depot_tools/gclient',
10 'file', 10 'file',
(...skipping 14 matching lines...) Expand all
25 import json 25 import json
26 26
27 27
28 def get_auth_token(api): 28 def get_auth_token(api):
29 """ 29 """
30 Get an auth token; this assumes the user is logged in with the infra 30 Get an auth token; this assumes the user is logged in with the infra
31 authutil command line utility. 31 authutil command line utility.
32 """ 32 """
33 33
34 result = api.step('Get auth token', 34 result = api.step('Get auth token',
35 ['authutil', 'token',], 35 ['/opt/infra-tools/authutil', 'token',],
36 stdout=api.raw_io.output(), 36 stdout=api.raw_io.output(),
37 step_test_data=lambda: api.raw_io.test_api.stream_output('ya29.foobar')) 37 step_test_data=lambda: api.raw_io.test_api.stream_output('ya29.foobar'))
38 return result.stdout.strip() 38 return result.stdout.strip()
39 39
40 def parse_protobuf(lines): # pragma: no cover 40 def parse_protobuf(lines): # pragma: no cover
41 """Parse the protobuf text format just well enough to understand recipes.cfg. 41 """Parse the protobuf text format just well enough to understand recipes.cfg.
42 42
43 We don't use the protobuf library because we want to be as self-contained 43 We don't use the protobuf library because we want to be as self-contained
44 as possible in this bootstrap, so it can be simply vendored into a client 44 as possible in this bootstrap, so it can be simply vendored into a client
45 repo. 45 repo.
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 # apply. 336 # apply.
337 "rietveld": Property(kind=str, default="", 337 "rietveld": Property(kind=str, default="",
338 help="The Rietveld instance the issue is from"), 338 help="The Rietveld instance the issue is from"),
339 "issue": Property(kind=str, default=None, 339 "issue": Property(kind=str, default=None,
340 help="The Rietveld issue number to pull data from"), 340 help="The Rietveld issue number to pull data from"),
341 "patchset": Property(kind=str, default=None, 341 "patchset": Property(kind=str, default=None,
342 help="The patchset number for the supplied issue"), 342 help="The patchset number for the supplied issue"),
343 "patch_project": Property( 343 "patch_project": Property(
344 kind=str, default=None, 344 kind=str, default=None,
345 help="The luci-config name of the project this patch belongs to"), 345 help="The luci-config name of the project this patch belongs to"),
346
347 # To generate an auth token for running locally, run
348 # infra/go/bin/authutil login
349 'auth_token': Property(default=None),
346 } 350 }
347 351
348 def RunSteps(api, patches_raw, rietveld, issue, patchset, patch_project): 352 def RunSteps(api, patches_raw, rietveld, issue, patchset, patch_project,
353 auth_token):
349 # TODO(martiniss): use real types 354 # TODO(martiniss): use real types
350 issue = int(issue) if issue else None 355 issue = int(issue) if issue else None
351 patchset = int(patchset) if patchset else None 356 patchset = int(patchset) if patchset else None
352 357
353 headers = {'Authorization': 'Bearer %s' % get_auth_token(api)} 358 if not auth_token:
359 auth_token = get_auth_token(api)
360
361 headers = {'Authorization': 'Bearer %s' % auth_token}
354 362
355 patches = parse_patches( 363 patches = parse_patches(
356 api, patches_raw, rietveld, issue, patchset, patch_project) 364 api, patches_raw, rietveld, issue, patchset, patch_project)
357 365
358 root_dir = api.path['slave_build'] 366 root_dir = api.path['slave_build']
359 367
360 url_mapping = get_url_mapping(api, headers) 368 url_mapping = get_url_mapping(api, headers)
361 369
362 # luci config project name to recipe config namedtuple 370 # luci config project name to recipe config namedtuple
363 recipe_configs = {} 371 recipe_configs = {}
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 api.properties( 450 api.properties(
443 rietveld="https://fake.code.review", 451 rietveld="https://fake.code.review",
444 issue='12345678', 452 issue='12345678',
445 patchset='1', 453 patchset='1',
446 patch_project="build", 454 patch_project="build",
447 ) + 455 ) +
448 api.step_data("Get build deps", project('build', ['recipe_engine'])) + 456 api.step_data("Get build deps", project('build', ['recipe_engine'])) +
449 api.step_data("Get recipe_engine deps", project('recipe_engine')) 457 api.step_data("Get recipe_engine deps", project('recipe_engine'))
450 ) 458 )
451 459
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipes/infra/recipe_roll_tryjob.expected/bad_patches.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698