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

Side by Side Diff: recipe_modules/bot_update/api.py

Issue 2294413002: bot_update: add --auth-refresh-token-json passthrough for apply_issue (Closed)
Patch Set: More coverage Created 4 years, 3 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 | recipe_modules/bot_update/example.py » ('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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 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 5
6 """Recipe module to ensure a checkout is consistant on a bot.""" 6 """Recipe module to ensure a checkout is consistant on a bot."""
7 7
8 from recipe_engine import recipe_api 8 from recipe_engine import recipe_api
9 9
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 if gerrit_no_reset: 59 if gerrit_no_reset:
60 cmd.append('--gerrit_no_reset') 60 cmd.append('--gerrit_no_reset')
61 if gerrit_no_rebase_patch_ref: 61 if gerrit_no_rebase_patch_ref:
62 cmd.append('--gerrit_no_rebase_patch_ref') 62 cmd.append('--gerrit_no_rebase_patch_ref')
63 return self.m.python('apply_gerrit', apply_gerrit_path, cmd, **kwargs) 63 return self.m.python('apply_gerrit', apply_gerrit_path, cmd, **kwargs)
64 64
65 def ensure_checkout(self, gclient_config=None, suffix=None, 65 def ensure_checkout(self, gclient_config=None, suffix=None,
66 patch=True, update_presentation=True, 66 patch=True, update_presentation=True,
67 patch_root=None, no_shallow=False, 67 patch_root=None, no_shallow=False,
68 with_branch_heads=False, refs=None, 68 with_branch_heads=False, refs=None,
69 patch_oauth2=False, use_site_config_creds=True, 69 patch_oauth2=False, oauth2_json=False,
70 use_site_config_creds=True,
70 output_manifest=True, clobber=False, 71 output_manifest=True, clobber=False,
71 root_solution_revision=None, rietveld=None, issue=None, 72 root_solution_revision=None, rietveld=None, issue=None,
72 patchset=None, gerrit_no_reset=False, 73 patchset=None, gerrit_no_reset=False,
73 gerrit_no_rebase_patch_ref=False, **kwargs): 74 gerrit_no_rebase_patch_ref=False, **kwargs):
74 """ 75 """
75 Args: 76 Args:
76 use_site_config_creds: If the oauth2 credentials are in the buildbot 77 use_site_config_creds: If the oauth2 credentials are in the buildbot
77 site_config. See crbug.com/624212 for more information. 78 site_config. See crbug.com/624212 for more information.
78 gclient_config: The gclient configuration to use when running bot_update. 79 gclient_config: The gclient configuration to use when running bot_update.
79 If omitted, the current gclient configuration is used. 80 If omitted, the current gclient configuration is used.
80 rietveld: The rietveld server to use. If omitted, will infer from 81 rietveld: The rietveld server to use. If omitted, will infer from
81 the 'rietveld' property. 82 the 'rietveld' property.
82 issue: The rietveld issue number to use. If omitted, will infer from 83 issue: The rietveld issue number to use. If omitted, will infer from
83 the 'issue' property. 84 the 'issue' property.
84 patchset: The rietveld issue patchset to use. If omitted, will infer from 85 patchset: The rietveld issue patchset to use. If omitted, will infer from
85 the 'patchset' property. 86 the 'patchset' property.
86 """ 87 """
87 refs = refs or [] 88 refs = refs or []
88 # We can re-use the gclient spec from the gclient module, since all the 89 # We can re-use the gclient spec from the gclient module, since all the
89 # data bot_update needs is already configured into the gclient spec. 90 # data bot_update needs is already configured into the gclient spec.
90 cfg = gclient_config or self.m.gclient.c 91 cfg = gclient_config or self.m.gclient.c
91 assert cfg is not None, ( 92 assert cfg is not None, (
92 'missing gclient_config or forgot api.gclient.set_config(...) before?') 93 'missing gclient_config or forgot api.gclient.set_config(...) before?')
93 94
95 # Only one of these should exist.
96 assert not (oauth2_json and patch_oauth2)
97
94 # Construct our bot_update command. This basically be inclusive of 98 # Construct our bot_update command. This basically be inclusive of
95 # everything required for bot_update to know: 99 # everything required for bot_update to know:
96 root = patch_root 100 root = patch_root
97 if root is None: 101 if root is None:
98 root = self.m.gclient.calculate_patch_root( 102 root = self.m.gclient.calculate_patch_root(
99 self.m.properties.get('patch_project'), cfg) 103 self.m.properties.get('patch_project'), cfg)
100 104
101 if patch: 105 if patch:
102 issue = issue or self._issue 106 issue = issue or self._issue
103 patchset = patchset or self._patchset 107 patchset = patchset or self._patchset
(...skipping 12 matching lines...) Expand all
116 assert issue 120 assert issue
117 121
118 # The gerrit_ref and gerrit_repo must be together or not at all. If one is 122 # The gerrit_ref and gerrit_repo must be together or not at all. If one is
119 # missing, clear both of them. 123 # missing, clear both of them.
120 if not gerrit_ref or not gerrit_repo: 124 if not gerrit_ref or not gerrit_repo:
121 gerrit_repo = gerrit_ref = None 125 gerrit_repo = gerrit_ref = None
122 assert (gerrit_ref != None) == (gerrit_repo != None) 126 assert (gerrit_ref != None) == (gerrit_repo != None)
123 127
124 # Point to the oauth2 auth files if specified. 128 # Point to the oauth2 auth files if specified.
125 # These paths are where the bots put their credential files. 129 # These paths are where the bots put their credential files.
126 if patch_oauth2: 130 oauth2_json_file = email_file = key_file = None
131 if oauth2_json:
132 if self.m.platform.is_win:
133 oauth2_json_file = 'C:\\creds\\refresh_tokens\\rietveld.json'
134 else:
135 oauth2_json_file = '/creds/refresh_tokens/rietveld.json'
136 elif patch_oauth2:
127 # TODO(martiniss): remove this hack :(. crbug.com/624212 137 # TODO(martiniss): remove this hack :(. crbug.com/624212
128 if use_site_config_creds: 138 if use_site_config_creds:
129 email_file = self.m.path['build'].join( 139 email_file = self.m.path['build'].join(
130 'site_config', '.rietveld_client_email') 140 'site_config', '.rietveld_client_email')
131 key_file = self.m.path['build'].join( 141 key_file = self.m.path['build'].join(
132 'site_config', '.rietveld_secret_key') 142 'site_config', '.rietveld_secret_key')
133 else: #pragma: no cover 143 else: #pragma: no cover
134 #TODO(martiniss): make this use path.join, so it works on windows 144 #TODO(martiniss): make this use path.join, so it works on windows
135 email_file = '/creds/rietveld/client_email' 145 email_file = '/creds/rietveld/client_email'
136 key_file = '/creds/rietveld/secret_key' 146 key_file = '/creds/rietveld/secret_key'
137 else:
138 email_file = key_file = None
139 147
140 # Allow patch_project's revision if necessary. 148 # Allow patch_project's revision if necessary.
141 # This is important for projects which are checked out as DEPS of the 149 # This is important for projects which are checked out as DEPS of the
142 # gclient solution. 150 # gclient solution.
143 self.m.gclient.set_patch_project_revision( 151 self.m.gclient.set_patch_project_revision(
144 self.m.properties.get('patch_project'), cfg) 152 self.m.properties.get('patch_project'), cfg)
145 153
146 rev_map = cfg.got_revision_mapping.as_jsonish() 154 rev_map = cfg.got_revision_mapping.as_jsonish()
147 155
148 flags = [ 156 flags = [
149 # What do we want to check out (spec/root/rev/rev_map). 157 # What do we want to check out (spec/root/rev/rev_map).
150 ['--spec', self.m.gclient.config_to_pythonish(cfg)], 158 ['--spec', self.m.gclient.config_to_pythonish(cfg)],
151 ['--patch_root', root], 159 ['--patch_root', root],
152 ['--revision_mapping_file', self.m.json.input(rev_map)], 160 ['--revision_mapping_file', self.m.json.input(rev_map)],
153 ['--git-cache-dir', cfg.cache_dir], 161 ['--git-cache-dir', cfg.cache_dir],
154 162
155 # How to find the patch, if any (issue/patchset). 163 # How to find the patch, if any (issue/patchset).
156 ['--issue', issue], 164 ['--issue', issue],
157 ['--patchset', patchset], 165 ['--patchset', patchset],
158 ['--rietveld_server', rietveld or self._rietveld], 166 ['--rietveld_server', rietveld or self._rietveld],
159 ['--gerrit_repo', gerrit_repo], 167 ['--gerrit_repo', gerrit_repo],
160 ['--gerrit_ref', gerrit_ref], 168 ['--gerrit_ref', gerrit_ref],
161 ['--apply_issue_email_file', email_file], 169 ['--apply_issue_email_file', email_file],
162 ['--apply_issue_key_file', key_file], 170 ['--apply_issue_key_file', key_file],
171 ['--apply_issue_oauth2_file', oauth2_json_file],
163 172
164 # Hookups to JSON output back into recipes. 173 # Hookups to JSON output back into recipes.
165 ['--output_json', self.m.json.output()],] 174 ['--output_json', self.m.json.output()],]
166 175
167 176
168 # Collect all fixed revisions to simulate them in the json output. 177 # Collect all fixed revisions to simulate them in the json output.
169 # Fixed revision are the explicit input revisions of bot_update.py, i.e. 178 # Fixed revision are the explicit input revisions of bot_update.py, i.e.
170 # every command line parameter "--revision name@value". 179 # every command line parameter "--revision name@value".
171 fixed_revisions = {} 180 fixed_revisions = {}
172 181
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 292
284 # bot_update actually just sets root to be the folder name of the 293 # bot_update actually just sets root to be the folder name of the
285 # first solution. 294 # first solution.
286 if step_result.json.output['did_run']: 295 if step_result.json.output['did_run']:
287 co_root = step_result.json.output['root'] 296 co_root = step_result.json.output['root']
288 cwd = kwargs.get('cwd', self.m.path['slave_build']) 297 cwd = kwargs.get('cwd', self.m.path['slave_build'])
289 if 'checkout' not in self.m.path: 298 if 'checkout' not in self.m.path:
290 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) 299 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep))
291 300
292 return step_result 301 return step_result
OLDNEW
« no previous file with comments | « no previous file | recipe_modules/bot_update/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698