mirror of
				https://github.com/ansible-collections/community.general.git
				synced 2025-10-25 05:23:58 -07:00 
			
		
		
		
	Save the command line arguments into a global context
* Once cli args are parsed, they're constant.  So, save the parsed args
  into the global context for everyone else to use them from now on.
* Port cli scripts to use the CLIARGS in the context
* Refactor call to parse cli args into the run() method
* Fix unittests for changes to the internals of CLI arg parsing
* Port callback plugins to use context.CLIARGS
  * Got rid of the private self._options attribute
  * Use context.CLIARGS in the individual callback plugins instead.
  * Also output positional arguments in default and unixy plugins
  * Code has been simplified since we're now dealing with a dict rather
    than Optparse.Value
	
	
This commit is contained in:
		
					parent
					
						
							
								c18da65089
							
						
					
				
			
			
				commit
				
					
						afdbb0d9d5
					
				
			
		
					 36 changed files with 1033 additions and 868 deletions
				
			
		|  | @ -21,6 +21,8 @@ __metaclass__ = type | |||
| 
 | ||||
| from units.compat import unittest | ||||
| from units.compat.mock import MagicMock | ||||
| 
 | ||||
| from ansible import arguments | ||||
| from ansible.executor.playbook_executor import PlaybookExecutor | ||||
| from ansible.playbook import Playbook | ||||
| from ansible.template import Templar | ||||
|  | @ -31,10 +33,12 @@ from units.mock.loader import DictDataLoader | |||
| class TestPlaybookExecutor(unittest.TestCase): | ||||
| 
 | ||||
|     def setUp(self): | ||||
|         pass | ||||
|         # Reset command line args for every test | ||||
|         arguments.CLIArgs._Singleton__instance = None | ||||
| 
 | ||||
|     def tearDown(self): | ||||
|         pass | ||||
|         # And cleanup after ourselves too | ||||
|         arguments.CLIArgs._Singleton__instance = None | ||||
| 
 | ||||
|     def test_get_serialized_batches(self): | ||||
|         fake_loader = DictDataLoader({ | ||||
|  | @ -77,11 +81,6 @@ class TestPlaybookExecutor(unittest.TestCase): | |||
|         mock_inventory = MagicMock() | ||||
|         mock_var_manager = MagicMock() | ||||
| 
 | ||||
|         # fake out options to use the syntax CLI switch, which will ensure | ||||
|         # the PlaybookExecutor doesn't create a TaskQueueManager | ||||
|         mock_options = MagicMock() | ||||
|         mock_options.syntax.value = True | ||||
| 
 | ||||
|         templar = Templar(loader=fake_loader) | ||||
| 
 | ||||
|         pbe = PlaybookExecutor( | ||||
|  | @ -89,7 +88,6 @@ class TestPlaybookExecutor(unittest.TestCase): | |||
|             inventory=mock_inventory, | ||||
|             variable_manager=mock_var_manager, | ||||
|             loader=fake_loader, | ||||
|             options=mock_options, | ||||
|             passwords=[], | ||||
|         ) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue