changed the field name from 'container_options' to simply 'pull'

This commit is contained in:
Rebeccah
2021-02-09 11:40:44 -05:00
committed by Shane McDonald
parent b0265b060b
commit 4b40cb3abb
9 changed files with 29 additions and 28 deletions

View File

@@ -1365,7 +1365,7 @@ class ExecutionEnvironmentSerializer(BaseSerializer):
class Meta: class Meta:
model = ExecutionEnvironment model = ExecutionEnvironment
fields = ('*', 'organization', 'image', 'managed_by_tower', 'credential', 'container_options') fields = ('*', 'organization', 'image', 'managed_by_tower', 'credential', 'pull')
def get_related(self, obj): def get_related(self, obj):
res = super(ExecutionEnvironmentSerializer, self).get_related(obj) res = super(ExecutionEnvironmentSerializer, self).get_related(obj)

View File

@@ -12,7 +12,7 @@ class Migration(migrations.Migration):
operations = [ operations = [
migrations.AddField( migrations.AddField(
model_name='executionenvironment', model_name='executionenvironment',
name='container_options', 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.')], default='missing', help_text='Pull image before running?', max_length=1024),
), ),
] ]

View File

@@ -14,8 +14,8 @@ class ExecutionEnvironment(CommonModel):
PULL_CHOICES = [ PULL_CHOICES = [
('always', _("Always pull container before running.")), ('always', _("Always pull container before running.")),
('missing', _("No pull option has been selected")), ('missing', _("No pull option has been selected.")),
('never', _("Never pull container before running")) ('never', _("Never pull container before running."))
] ]
organization = models.ForeignKey( organization = models.ForeignKey(
@@ -41,7 +41,7 @@ class ExecutionEnvironment(CommonModel):
default=None, default=None,
on_delete=models.SET_NULL, on_delete=models.SET_NULL,
) )
container_options = models.CharField( pull = models.CharField(
max_length=1024, max_length=1024,
choices=PULL_CHOICES, choices=PULL_CHOICES,
default='missing', default='missing',

View File

@@ -21,14 +21,14 @@ const executionEnvironmentData = {
credential: 4, credential: 4,
description: 'A simple EE', description: 'A simple EE',
image: 'https://registry.com/image/container', image: 'https://registry.com/image/container',
container_options: 'one', pull: 'one',
}; };
const mockOptions = { const mockOptions = {
data: { data: {
actions: { actions: {
POST: { POST: {
container_options: { pull: {
choices: [ choices: [
['one', 'One'], ['one', 'One'],
['two', 'Two'], ['two', 'Two'],

View File

@@ -18,13 +18,7 @@ import { ExecutionEnvironmentsAPI } from '../../../api';
function ExecutionEnvironmentDetails({ executionEnvironment, i18n }) { function ExecutionEnvironmentDetails({ executionEnvironment, i18n }) {
const history = useHistory(); const history = useHistory();
const { const { id, name, image, description, pull } = executionEnvironment;
id,
name,
image,
description,
container_options,
} = executionEnvironment;
const { const {
request: deleteExecutionEnvironment, request: deleteExecutionEnvironment,
@@ -54,12 +48,8 @@ function ExecutionEnvironmentDetails({ executionEnvironment, i18n }) {
/> />
<Detail label={i18n._(t`Description`)} value={description} /> <Detail label={i18n._(t`Description`)} value={description} />
<Detail <Detail
label={i18n._(t`Container Options`)} label={i18n._(t`Pull`)}
value={ value={pull === '' ? i18n._(t`Missing`) : toTitleCase(pull)}
container_options === ''
? i18n._(t`Missing`)
: toTitleCase(container_options)
}
/> />
{executionEnvironment.summary_fields.credential && ( {executionEnvironment.summary_fields.credential && (
<Detail <Detail

View File

@@ -19,7 +19,7 @@ const executionEnvironmentData = {
credential: { id: 4 }, credential: { id: 4 },
description: 'A simple EE', description: 'A simple EE',
image: 'https://registry.com/image/container', image: 'https://registry.com/image/container',
container_options: 'one', pull: 'one',
name: 'Test EE', name: 'Test EE',
}; };
@@ -32,7 +32,7 @@ const mockOptions = {
data: { data: {
actions: { actions: {
POST: { POST: {
container_options: { pull: {
choices: [ choices: [
['one', 'One'], ['one', 'One'],
['two', 'Two'], ['two', 'Two'],

View File

@@ -52,10 +52,10 @@ function ExecutionEnvironmentFormFields({
containerOptionsMeta, containerOptionsMeta,
containerOptionsHelpers, containerOptionsHelpers,
] = useField({ ] = useField({
name: 'container_options', name: 'pull',
}); });
const containerPullChoices = options?.actions?.POST?.container_options?.choices.map( const containerPullChoices = options?.actions?.POST?.pull?.choices.map(
([value, label]) => ({ value, label, key: value }) ([value, label]) => ({ value, label, key: value })
); );
@@ -168,7 +168,7 @@ function ExecutionEnvironmentForm({
const initialValues = { const initialValues = {
name: executionEnvironment.name || '', name: executionEnvironment.name || '',
image: executionEnvironment.image || '', image: executionEnvironment.image || '',
container_options: executionEnvironment?.container_options || '', pull: executionEnvironment?.pull || '',
description: executionEnvironment.description || '', description: executionEnvironment.description || '',
credential: executionEnvironment.summary_fields?.credential || null, credential: executionEnvironment.summary_fields?.credential || null,
organization: executionEnvironment.summary_fields?.organization || null, organization: executionEnvironment.summary_fields?.organization || null,

View File

@@ -19,7 +19,7 @@ const executionEnvironment = {
id: 16, id: 16,
name: 'Test EE', name: 'Test EE',
type: 'execution_environment', type: 'execution_environment',
container_options: 'one', pull: 'one',
url: '/api/v2/execution_environments/16/', url: '/api/v2/execution_environments/16/',
related: { related: {
created_by: '/api/v2/users/1/', created_by: '/api/v2/users/1/',
@@ -48,7 +48,7 @@ const mockOptions = {
data: { data: {
actions: { actions: {
POST: { POST: {
container_options: { pull: {
choices: [ choices: [
['one', 'One'], ['one', 'One'],
['two', 'Two'], ['two', 'Two'],

View File

@@ -50,6 +50,12 @@ options:
choices: ["present", "absent"] choices: ["present", "absent"]
default: "present" default: "present"
type: str type: str
pull:
description:
- determine image pull behavior
choices: ["always", "missing", "never"]
default: "missing"
type: str
extends_documentation_fragment: awx.awx.auth extends_documentation_fragment: awx.awx.auth
''' '''
@@ -75,6 +81,7 @@ def main():
organization=dict(), organization=dict(),
credential=dict(default=''), credential=dict(default=''),
state=dict(choices=['present', 'absent'], default='present'), state=dict(choices=['present', 'absent'], default='present'),
pull=dict(choices=['always', 'missing', 'never'], default='missing')
) )
# Create a module for ourselves # Create a module for ourselves
@@ -85,6 +92,7 @@ def main():
image = module.params.get('image') image = module.params.get('image')
description = module.params.get('description') description = module.params.get('description')
state = module.params.get('state') state = module.params.get('state')
pull = module.params.get('pull')
existing_item = module.get_one('execution_environments', name_or_id=name) existing_item = module.get_one('execution_environments', name_or_id=name)
@@ -98,6 +106,9 @@ def main():
if description: if description:
new_fields['description'] = 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) # Attempt to look up the related items the user specified (these will fail the module if not found)
organization = module.params.get('organization') organization = module.params.get('organization')
if organization: if organization: