@@ -452,7 +452,7 @@ def _run(**kwargs):
452
452
func_ret = _call_function (
453
453
_func , returner = kwargs .get ("returner" ), func_args = kwargs .get (func )
454
454
)
455
- if not _get_result (func_ret , ret [ "changes" ]. get ( "ret" , {}) ):
455
+ if not _get_result (func_ret ):
456
456
if isinstance (func_ret , dict ):
457
457
failures .append (
458
458
"'{}' failed: {}" .format (
@@ -658,31 +658,29 @@ def _legacy_run(name, **kwargs):
658
658
if kwargs ["returner" ] in returners :
659
659
returners [kwargs ["returner" ]](ret_ret )
660
660
ret ["comment" ] = f"Module function { name } executed"
661
- ret ["result" ] = _get_result (mret , ret [ "changes" ] )
661
+ ret ["result" ] = _get_result (mret )
662
662
663
663
return ret
664
664
665
665
666
- def _get_result (func_ret , changes ):
666
+ def _get_result (func_ret ):
667
667
res = True
668
- # if mret is a dict and there is retcode and its non-zero
669
- if isinstance (func_ret , dict ) and func_ret .get ("retcode" , 0 ) != 0 :
670
- res = False
671
- # if its a boolean, return that as the result
672
- elif isinstance (func_ret , bool ):
668
+ # if mret a boolean, return that as the result
669
+ if isinstance (func_ret , bool ):
673
670
res = func_ret
674
- else :
675
- changes_ret = changes .get ("ret" , {})
676
- if isinstance (changes_ret , dict ):
677
- if isinstance (changes_ret .get ("result" , {}), bool ):
678
- res = changes_ret .get ("result" , {})
679
- elif changes_ret .get ("retcode" , 0 ) != 0 :
680
- res = False
681
- # Explore dict in depth to determine if there is a
682
- # 'result' key set to False which sets the global
683
- # state result.
684
- else :
685
- res = _get_dict_result (changes_ret )
671
+ # if mret is a dict, check if certain keys exist
672
+ elif isinstance (func_ret , dict ):
673
+ # if return key exists and is is boolean, return that as the result
674
+ if isinstance (func_ret .get ("result" , {}), bool ):
675
+ res = func_ret .get ("result" , {})
676
+ # if retcode exists and it is non-zero, return False
677
+ elif func_ret .get ("retcode" , 0 ) != 0 :
678
+ res = False
679
+ # Explore dict in depth to determine if there is a
680
+ # 'result' key set to False which sets the global
681
+ # state result.
682
+ else :
683
+ res = _get_dict_result (func_ret )
686
684
687
685
return res
688
686
0 commit comments