From b1361c8fe28a3682b1d27e652eb9acc6f4716f52 Mon Sep 17 00:00:00 2001 From: Rebeccah Date: Tue, 16 Feb 2021 17:41:44 -0500 Subject: [PATCH] edit original migration file, add blank string as acceptable to model --- ...6_executionenvironment_container_options.py | 2 +- .../0128_set_default_pull_to_none.py | 18 ------------------ awx/main/models/execution_environments.py | 5 +++-- .../modules/tower_execution_environment.py | 2 +- .../awxkit/api/pages/execution_environments.py | 6 +++--- 5 files changed, 8 insertions(+), 25 deletions(-) delete mode 100644 awx/main/migrations/0128_set_default_pull_to_none.py diff --git a/awx/main/migrations/0126_executionenvironment_container_options.py b/awx/main/migrations/0126_executionenvironment_container_options.py index c2fd2e77b5..d26fcb9298 100644 --- a/awx/main/migrations/0126_executionenvironment_container_options.py +++ b/awx/main/migrations/0126_executionenvironment_container_options.py @@ -13,6 +13,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='executionenvironment', 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), + field=models.CharField(choices=[('always', 'Always pull container before running.'), ('missing', 'No pull option has been selected.'), ('never', 'Never pull container before running.')], blank=True, default='', help_text='Pull image before running?', max_length=16), ), ] diff --git a/awx/main/migrations/0128_set_default_pull_to_none.py b/awx/main/migrations/0128_set_default_pull_to_none.py deleted file mode 100644 index 3643c610e1..0000000000 --- a/awx/main/migrations/0128_set_default_pull_to_none.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.16 on 2021-02-16 20:38 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('main', '0127_reset_pod_spec_override'), - ] - - operations = [ - migrations.AlterField( - model_name='executionenvironment', - 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=None, 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 cddd8c41e5..eabd0cce7c 100644 --- a/awx/main/models/execution_environments.py +++ b/awx/main/models/execution_environments.py @@ -42,9 +42,10 @@ class ExecutionEnvironment(CommonModel): on_delete=models.SET_NULL, ) pull = models.CharField( - max_length=1024, + max_length=16, choices=PULL_CHOICES, - default=None, + blank=True, + default='', help_text=_('Pull image before running?'), ) diff --git a/awx_collection/plugins/modules/tower_execution_environment.py b/awx_collection/plugins/modules/tower_execution_environment.py index e738f9a3bf..320141721d 100644 --- a/awx_collection/plugins/modules/tower_execution_environment.py +++ b/awx_collection/plugins/modules/tower_execution_environment.py @@ -54,7 +54,7 @@ options: description: - determine image pull behavior choices: ["always", "missing", "never"] - default: None + default: '' type: str extends_documentation_fragment: awx.awx.auth ''' diff --git a/awxkit/awxkit/api/pages/execution_environments.py b/awxkit/awxkit/api/pages/execution_environments.py index 11e3e2f881..94f53c1094 100644 --- a/awxkit/awxkit/api/pages/execution_environments.py +++ b/awxkit/awxkit/api/pages/execution_environments.py @@ -21,7 +21,7 @@ class ExecutionEnvironment(HasCreate, base.Base): NATURAL_KEY = ('name',) # fields are name, image, organization, managed_by_tower, credential - def create(self, name='', image='quay.io/ansible/ansible-runner:devel', credential=None, pull=None, **kwargs): + def create(self, name='', image='quay.io/ansible/ansible-runner:devel', credential=None, pull='', **kwargs): # we do not want to make a credential by default payload = self.create_payload(name=name, image=image, credential=credential, pull=pull, **kwargs) ret = self.update_identity(ExecutionEnvironments(self.connection).post(payload)) @@ -33,13 +33,13 @@ class ExecutionEnvironment(HasCreate, base.Base): payload.ds = DSAdapter(self.__class__.__name__, self._dependency_store) return payload - def payload(self, name='', image=None, organization=None, credential=None, pull=None, **kwargs): + def payload(self, name='', image=None, organization=None, credential=None, pull='', **kwargs): payload = PseudoNamespace( name=name or "EE - {}".format(random_title()), image=image or random_title(10), organization=organization.id if organization else None, credential=credential.id if credential else None, - pull=pull if pull else None, + pull=pull, **kwargs )