From 4b40cb3abbb788bee0e88db49122cbdfb2e0111a Mon Sep 17 00:00:00 2001 From: Rebeccah Date: Tue, 9 Feb 2021 11:40:44 -0500 Subject: [PATCH] changed the field name from 'container_options' to simply 'pull' --- awx/api/serializers.py | 2 +- ...126_executionenvironment_container_options.py | 4 ++-- awx/main/models/execution_environments.py | 6 +++--- .../ExecutionEnvironmentAdd.test.jsx | 4 ++-- .../ExecutionEnvironmentDetails.jsx | 16 +++------------- .../ExecutionEnvironmentEdit.test.jsx | 4 ++-- .../shared/ExecutionEnvironmentForm.jsx | 6 +++--- .../shared/ExecutionEnvironmentForm.test.jsx | 4 ++-- .../modules/tower_execution_environment.py | 11 +++++++++++ 9 files changed, 29 insertions(+), 28 deletions(-) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 941b465157..22b7ab3a7a 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1365,7 +1365,7 @@ class ExecutionEnvironmentSerializer(BaseSerializer): class Meta: model = ExecutionEnvironment - fields = ('*', 'organization', 'image', 'managed_by_tower', 'credential', 'container_options') + fields = ('*', 'organization', 'image', 'managed_by_tower', 'credential', 'pull') def get_related(self, obj): res = super(ExecutionEnvironmentSerializer, self).get_related(obj) diff --git a/awx/main/migrations/0126_executionenvironment_container_options.py b/awx/main/migrations/0126_executionenvironment_container_options.py index 27c667f9f0..c2fd2e77b5 100644 --- a/awx/main/migrations/0126_executionenvironment_container_options.py +++ b/awx/main/migrations/0126_executionenvironment_container_options.py @@ -12,7 +12,7 @@ class Migration(migrations.Migration): operations = [ migrations.AddField( model_name='executionenvironment', - name='container_options', - field=models.CharField(choices=[('always', 'Always pull container before running.'), ('missing', 'No pull option has been selected'), ('never', 'Never pull container before running')], default='missing', help_text='Pull image before running?', max_length=1024), + name='pull', + field=models.CharField(choices=[('always', 'Always pull container before running.'), ('missing', 'No pull option has been selected.'), ('never', 'Never pull container before running.')], default='missing', help_text='Pull image before running?', max_length=1024), ), ] diff --git a/awx/main/models/execution_environments.py b/awx/main/models/execution_environments.py index 353b6cdbc7..681cdf94db 100644 --- a/awx/main/models/execution_environments.py +++ b/awx/main/models/execution_environments.py @@ -14,8 +14,8 @@ class ExecutionEnvironment(CommonModel): PULL_CHOICES = [ ('always', _("Always pull container before running.")), - ('missing', _("No pull option has been selected")), - ('never', _("Never pull container before running")) + ('missing', _("No pull option has been selected.")), + ('never', _("Never pull container before running.")) ] organization = models.ForeignKey( @@ -41,7 +41,7 @@ class ExecutionEnvironment(CommonModel): default=None, on_delete=models.SET_NULL, ) - container_options = models.CharField( + pull = models.CharField( max_length=1024, choices=PULL_CHOICES, default='missing', diff --git a/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentAdd/ExecutionEnvironmentAdd.test.jsx b/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentAdd/ExecutionEnvironmentAdd.test.jsx index ede58e5d58..92f18c7d33 100644 --- a/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentAdd/ExecutionEnvironmentAdd.test.jsx +++ b/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentAdd/ExecutionEnvironmentAdd.test.jsx @@ -21,14 +21,14 @@ const executionEnvironmentData = { credential: 4, description: 'A simple EE', image: 'https://registry.com/image/container', - container_options: 'one', + pull: 'one', }; const mockOptions = { data: { actions: { POST: { - container_options: { + pull: { choices: [ ['one', 'One'], ['two', 'Two'], diff --git a/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentDetails/ExecutionEnvironmentDetails.jsx b/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentDetails/ExecutionEnvironmentDetails.jsx index 64925df1cb..866b74f5fb 100644 --- a/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentDetails/ExecutionEnvironmentDetails.jsx +++ b/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentDetails/ExecutionEnvironmentDetails.jsx @@ -18,13 +18,7 @@ import { ExecutionEnvironmentsAPI } from '../../../api'; function ExecutionEnvironmentDetails({ executionEnvironment, i18n }) { const history = useHistory(); - const { - id, - name, - image, - description, - container_options, - } = executionEnvironment; + const { id, name, image, description, pull } = executionEnvironment; const { request: deleteExecutionEnvironment, @@ -54,12 +48,8 @@ function ExecutionEnvironmentDetails({ executionEnvironment, i18n }) { /> {executionEnvironment.summary_fields.credential && ( ({ value, label, key: value }) ); @@ -168,7 +168,7 @@ function ExecutionEnvironmentForm({ const initialValues = { name: executionEnvironment.name || '', image: executionEnvironment.image || '', - container_options: executionEnvironment?.container_options || '', + pull: executionEnvironment?.pull || '', description: executionEnvironment.description || '', credential: executionEnvironment.summary_fields?.credential || null, organization: executionEnvironment.summary_fields?.organization || null, diff --git a/awx/ui_next/src/screens/ExecutionEnvironment/shared/ExecutionEnvironmentForm.test.jsx b/awx/ui_next/src/screens/ExecutionEnvironment/shared/ExecutionEnvironmentForm.test.jsx index 1253852640..cddef9ffce 100644 --- a/awx/ui_next/src/screens/ExecutionEnvironment/shared/ExecutionEnvironmentForm.test.jsx +++ b/awx/ui_next/src/screens/ExecutionEnvironment/shared/ExecutionEnvironmentForm.test.jsx @@ -19,7 +19,7 @@ const executionEnvironment = { id: 16, name: 'Test EE', type: 'execution_environment', - container_options: 'one', + pull: 'one', url: '/api/v2/execution_environments/16/', related: { created_by: '/api/v2/users/1/', @@ -48,7 +48,7 @@ const mockOptions = { data: { actions: { POST: { - container_options: { + pull: { choices: [ ['one', 'One'], ['two', 'Two'], diff --git a/awx_collection/plugins/modules/tower_execution_environment.py b/awx_collection/plugins/modules/tower_execution_environment.py index 280408f72a..862f4e3ab6 100644 --- a/awx_collection/plugins/modules/tower_execution_environment.py +++ b/awx_collection/plugins/modules/tower_execution_environment.py @@ -50,6 +50,12 @@ options: choices: ["present", "absent"] default: "present" type: str + pull: + description: + - determine image pull behavior + choices: ["always", "missing", "never"] + default: "missing" + type: str extends_documentation_fragment: awx.awx.auth ''' @@ -75,6 +81,7 @@ def main(): organization=dict(), credential=dict(default=''), state=dict(choices=['present', 'absent'], default='present'), + pull=dict(choices=['always', 'missing', 'never'], default='missing') ) # Create a module for ourselves @@ -85,6 +92,7 @@ def main(): image = module.params.get('image') description = module.params.get('description') state = module.params.get('state') + pull = module.params.get('pull') existing_item = module.get_one('execution_environments', name_or_id=name) @@ -98,6 +106,9 @@ def main(): if description: new_fields['description'] = description + if pull: + new_fields['pull'] = pull + # Attempt to look up the related items the user specified (these will fail the module if not found) organization = module.params.get('organization') if organization: