1 | # Licensed to the StackStorm, Inc ('StackStorm') under one or more |
||
0 ignored issues
–
show
|
|||
2 | # contributor license agreements. See the NOTICE file distributed with |
||
3 | # this work for additional information regarding copyright ownership. |
||
4 | # The ASF licenses this file to You under the Apache License, Version 2.0 |
||
5 | # (the "License"); you may not use this file except in compliance with |
||
6 | # the License. You may obtain a copy of the License at |
||
7 | # |
||
8 | # http://www.apache.org/licenses/LICENSE-2.0 |
||
9 | # |
||
10 | # Unless required by applicable law or agreed to in writing, software |
||
11 | # distributed under the License is distributed on an "AS IS" BASIS, |
||
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
13 | # See the License for the specific language governing permissions and |
||
14 | # limitations under the License. |
||
15 | |||
16 | from st2common import log as logging |
||
17 | from st2common.router import Response |
||
18 | from st2common.validators.workflow.mistral import v2 as mistral_validation_utils |
||
19 | |||
20 | |||
21 | LOG = logging.getLogger(__name__) |
||
22 | |||
23 | |||
24 | class MistralValidationController(object): |
||
25 | |||
26 | def __init__(self): |
||
27 | super(MistralValidationController, self).__init__() |
||
28 | self.validator = mistral_validation_utils.get_validator() |
||
29 | |||
30 | def post(self, def_yaml): |
||
31 | result = self.validator.validate(def_yaml) |
||
32 | |||
33 | for error in result: |
||
34 | if not error.get('path', None): |
||
35 | error['path'] = '' |
||
36 | |||
37 | return Response(json=result) |
||
38 | |||
39 | |||
40 | mistral_validation_controller = MistralValidationController() |
||
41 |
Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.