Change inventory source factory defaults

Also set source_path to a newly merged test-playbooks script
  this gives similar behavior to the prior default script
This commit is contained in:
Alan Rominger 2021-04-05 15:12:13 -04:00
parent 4a8c63c579
commit 855cb162b7
No known key found for this signature in database
GPG Key ID: C2D7EAAA12B63559

View File

@ -359,7 +359,7 @@ class InventorySource(HasCreate, HasNotifications, UnifiedJobTemplate):
optional_dependencies = [Credential, InventoryScript, Project]
NATURAL_KEY = ('organization', 'name', 'inventory')
def payload(self, inventory, source='custom', credential=None, source_script=None, project=None, **kwargs):
def payload(self, inventory, source='scm', credential=None, source_script=None, project=None, **kwargs):
payload = PseudoNamespace(
name=kwargs.get('name') or 'InventorySource - {}'.format(random_title()),
description=kwargs.get('description') or random_title(10),
@ -391,12 +391,13 @@ class InventorySource(HasCreate, HasNotifications, UnifiedJobTemplate):
return payload
def create_payload(
self, name='', description='', source='custom', inventory=Inventory, credential=None, source_script=InventoryScript, project=None, **kwargs
self, name='', description='', source='scm', inventory=Inventory, credential=None, source_script=InventoryScript, project=None, **kwargs
):
if source != 'custom' and source_script == InventoryScript:
source_script = None
if source == 'scm':
kwargs.setdefault('overwrite_vars', True)
kwargs.setdefault('source_path', 'inventories/script_migrations/script_source.py')
if project is None:
project = Project
@ -425,7 +426,7 @@ class InventorySource(HasCreate, HasNotifications, UnifiedJobTemplate):
payload.ds = DSAdapter(self.__class__.__name__, self._dependency_store)
return payload
def create(self, name='', description='', source='custom', inventory=Inventory, credential=None, source_script=InventoryScript, project=None, **kwargs):
def create(self, name='', description='', source='scm', inventory=Inventory, credential=None, source_script=InventoryScript, project=None, **kwargs):
payload = self.create_payload(
name=name,
description=description,