| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 from recipe_engine import recipe_api | 5 from recipe_engine import recipe_api |
| 6 | 6 |
| 7 | 7 |
| 8 class CIPDApi(recipe_api.RecipeApi): | 8 class CIPDApi(recipe_api.RecipeApi): |
| 9 """CIPDApi provides support for CIPD.""" | 9 """CIPDApi provides support for CIPD.""" |
| 10 def __init__(self, *args, **kwargs): | 10 def __init__(self, *args, **kwargs): |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 """Ensures the client is installed. | 35 """Ensures the client is installed. |
| 36 | 36 |
| 37 If you specify version as a hash, make sure its correct platform. | 37 If you specify version as a hash, make sure its correct platform. |
| 38 """ | 38 """ |
| 39 # TODO(seanmccullough): clean up older CIPD installations. | 39 # TODO(seanmccullough): clean up older CIPD installations. |
| 40 step = self.m.python( | 40 step = self.m.python( |
| 41 name=step_name, | 41 name=step_name, |
| 42 script=self.resource('bootstrap.py'), | 42 script=self.resource('bootstrap.py'), |
| 43 args=[ | 43 args=[ |
| 44 '--platform', self.platform_suffix(), | 44 '--platform', self.platform_suffix(), |
| 45 '--dest-directory', self.m.infra_paths['slave_build'].join('cipd'), | 45 '--dest-directory', self.m.path['slave_build'].join('cipd'), |
| 46 '--json-output', self.m.json.output(), | 46 '--json-output', self.m.json.output(), |
| 47 ] + | 47 ] + |
| 48 (['--version', version] if version else []), | 48 (['--version', version] if version else []), |
| 49 step_test_data=lambda: self.test_api.example_install_client(version) | 49 step_test_data=lambda: self.test_api.example_install_client(version) |
| 50 ) | 50 ) |
| 51 self._cipd_executable = step.json.output['executable'] | 51 self._cipd_executable = step.json.output['executable'] |
| 52 self._cipd_instance_id = step.json.output['instance_id'] | 52 self._cipd_instance_id = step.json.output['instance_id'] |
| 53 | 53 |
| 54 step.presentation.step_text = ( | 54 step.presentation.step_text = ( |
| 55 'cipd instance_id: %s' % self._cipd_instance_id) | 55 'cipd instance_id: %s' % self._cipd_instance_id) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 * version could be either instance_id, or ref, or unique tag. | 106 * version could be either instance_id, or ref, or unique tag. |
| 107 | 107 |
| 108 If installing a package requires credentials, call | 108 If installing a package requires credentials, call |
| 109 ``set_service_account_credentials`` before calling this function. | 109 ``set_service_account_credentials`` before calling this function. |
| 110 """ | 110 """ |
| 111 assert self._cipd_executable | 111 assert self._cipd_executable |
| 112 | 112 |
| 113 package_list = ['%s %s' % (name, version) | 113 package_list = ['%s %s' % (name, version) |
| 114 for name, version in sorted(packages.items())] | 114 for name, version in sorted(packages.items())] |
| 115 list_data = self.m.raw_io.input('\n'.join(package_list)) | 115 list_data = self.m.raw_io.input('\n'.join(package_list)) |
| 116 bin_path = self.m.infra_paths['slave_build'].join('cipd') | 116 bin_path = self.m.path['slave_build'].join('cipd') |
| 117 cmd = [ | 117 cmd = [ |
| 118 self._cipd_executable, | 118 self._cipd_executable, |
| 119 'ensure', | 119 'ensure', |
| 120 '--root', root, | 120 '--root', root, |
| 121 '--list', list_data, | 121 '--list', list_data, |
| 122 '--json-output', self.m.json.output(), | 122 '--json-output', self.m.json.output(), |
| 123 ] | 123 ] |
| 124 if self._cipd_credentials: | 124 if self._cipd_credentials: |
| 125 cmd.extend(['--service-account-json', self._cipd_credentials]) | 125 cmd.extend(['--service-account-json', self._cipd_credentials]) |
| 126 return self.m.step( | 126 return self.m.step( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 206 |
| 207 return self.m.step( | 207 return self.m.step( |
| 208 'cipd describe %s' % package_name, | 208 'cipd describe %s' % package_name, |
| 209 cmd, | 209 cmd, |
| 210 step_test_data=lambda: self.test_api.example_describe( | 210 step_test_data=lambda: self.test_api.example_describe( |
| 211 package_name, version, | 211 package_name, version, |
| 212 test_data_refs=test_data_refs, | 212 test_data_refs=test_data_refs, |
| 213 test_data_tags=test_data_tags | 213 test_data_tags=test_data_tags |
| 214 ) | 214 ) |
| 215 ) | 215 ) |
| OLD | NEW |