OLD | NEW |
1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 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 import collections | 5 import collections |
6 import contextlib | 6 import contextlib |
7 import imp | 7 import imp |
8 import inspect | 8 import inspect |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 return self._recipe_globals['PROPERTIES'] | 61 return self._recipe_globals['PROPERTIES'] |
62 | 62 |
63 @property | 63 @property |
64 def LOADED_DEPS(self): | 64 def LOADED_DEPS(self): |
65 return self._recipe_globals['LOADED_DEPS'] | 65 return self._recipe_globals['LOADED_DEPS'] |
66 | 66 |
67 @property | 67 @property |
68 def RETURN_SCHEMA(self): | 68 def RETURN_SCHEMA(self): |
69 return self._recipe_globals.get('RETURN_SCHEMA') | 69 return self._recipe_globals.get('RETURN_SCHEMA') |
70 | 70 |
71 def run(self, api, properties): | 71 def run(self, api, rt): |
72 """ | 72 """ |
73 Run this recipe, with the given api and property arguments. | 73 Run this recipe, with the given api and property arguments. |
74 Check the return value, if we have a RETURN_SCHEMA. | 74 Check the return value, if we have a RETURN_SCHEMA. |
75 """ | 75 """ |
76 recipe_result = invoke_with_properties( | 76 recipe_result = invoke_with_properties( |
77 self.run_steps, properties, self.PROPERTIES, api=api) | 77 self.run_steps, rt.mutable_properties(), self.PROPERTIES, api=api) |
78 | 78 |
79 if self.RETURN_SCHEMA: | 79 if self.RETURN_SCHEMA: |
80 if not recipe_result: | 80 if not recipe_result: |
81 raise ValueError("Recipe %s did not return a value." % self.name) | 81 raise ValueError("Recipe %s did not return a value." % self.name) |
82 return recipe_result.as_jsonish(True) | 82 return recipe_result.as_jsonish(True) |
83 else: | 83 else: |
84 return None | 84 return None |
85 | 85 |
86 @classmethod | 86 @classmethod |
87 def from_script_path(cls, script_path, universe_view): | 87 def from_script_path(cls, script_path, universe_view): |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 for k,v in toplevel_deps.iteritems(): | 589 for k,v in toplevel_deps.iteritems(): |
590 setattr(api, k, mapper.instantiate(v)) | 590 setattr(api, k, mapper.instantiate(v)) |
591 return api | 591 return api |
592 | 592 |
593 | 593 |
594 def _resolve_requirement(req, engine): | 594 def _resolve_requirement(req, engine): |
595 if req._typ == 'client': | 595 if req._typ == 'client': |
596 return engine._get_client(req._name) | 596 return engine._get_client(req._name) |
597 else: | 597 else: |
598 raise ValueError('Unknown requirement type [%s]' % (req._typ,)) | 598 raise ValueError('Unknown requirement type [%s]' % (req._typ,)) |
OLD | NEW |