django_command/django_check/django_createcachetable: add return value version (#9063)
* add return value version * add changelog frag * reformat yamlpull/9067/head
parent
39f3b151e8
commit
107df41d9c
|
@ -0,0 +1,5 @@
|
||||||
|
minor_changes:
|
||||||
|
- django module utils - always retrieve version (https://github.com/ansible-collections/community.general/pull/9063).
|
||||||
|
- django_check - add return value ``version`` (https://github.com/ansible-collections/community.general/pull/9063).
|
||||||
|
- django_command - add return value ``version`` (https://github.com/ansible-collections/community.general/pull/9063).
|
||||||
|
- django_createcachetable - add return value ``version`` (https://github.com/ansible-collections/community.general/pull/9063).
|
|
@ -32,6 +32,7 @@ _django_std_arg_fmts = dict(
|
||||||
verbosity=cmd_runner_fmt.as_opt_val("--verbosity"),
|
verbosity=cmd_runner_fmt.as_opt_val("--verbosity"),
|
||||||
no_color=cmd_runner_fmt.as_fixed("--no-color"),
|
no_color=cmd_runner_fmt.as_fixed("--no-color"),
|
||||||
skip_checks=cmd_runner_fmt.as_bool("--skip-checks"),
|
skip_checks=cmd_runner_fmt.as_bool("--skip-checks"),
|
||||||
|
version=cmd_runner_fmt.as_fixed("--version"),
|
||||||
)
|
)
|
||||||
|
|
||||||
_django_database_args = dict(
|
_django_database_args = dict(
|
||||||
|
@ -60,6 +61,9 @@ class _DjangoRunner(PythonRunner):
|
||||||
)
|
)
|
||||||
return super(_DjangoRunner, self).__call__(args_order, output_process, ignore_value_none, check_mode_skip, check_mode_return, **kwargs)
|
return super(_DjangoRunner, self).__call__(args_order, output_process, ignore_value_none, check_mode_skip, check_mode_return, **kwargs)
|
||||||
|
|
||||||
|
def bare_context(self, *args, **kwargs):
|
||||||
|
return super(_DjangoRunner, self).__call__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class DjangoModuleHelper(ModuleHelper):
|
class DjangoModuleHelper(ModuleHelper):
|
||||||
module = {}
|
module = {}
|
||||||
|
@ -98,16 +102,20 @@ class DjangoModuleHelper(ModuleHelper):
|
||||||
arg_formats=self.arg_formats,
|
arg_formats=self.arg_formats,
|
||||||
venv=self.vars.venv,
|
venv=self.vars.venv,
|
||||||
check_rc=True)
|
check_rc=True)
|
||||||
with runner() as ctx:
|
|
||||||
run_params = self.vars.as_dict()
|
run_params = self.vars.as_dict()
|
||||||
if self._check_mode_arg:
|
if self._check_mode_arg:
|
||||||
run_params.update({self._check_mode_arg: self.check_mode})
|
run_params.update({self._check_mode_arg: self.check_mode})
|
||||||
|
|
||||||
|
rc, out, err = runner.bare_context("version").run()
|
||||||
|
self.vars.version = out.strip()
|
||||||
|
|
||||||
|
with runner() as ctx:
|
||||||
results = ctx.run(**run_params)
|
results = ctx.run(**run_params)
|
||||||
self.vars.stdout = ctx.results_out
|
self.vars.stdout = ctx.results_out
|
||||||
self.vars.stderr = ctx.results_err
|
self.vars.stderr = ctx.results_err
|
||||||
self.vars.cmd = ctx.cmd
|
self.vars.cmd = ctx.cmd
|
||||||
if self.verbosity >= 3:
|
self.vars.set("run_info", ctx.run_info, verbosity=3)
|
||||||
self.vars.run_info = ctx.run_info
|
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ from __future__ import absolute_import, division, print_function
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
DOCUMENTATION = """
|
DOCUMENTATION = """
|
||||||
|
---
|
||||||
module: django_check
|
module: django_check
|
||||||
author:
|
author:
|
||||||
- Alexei Znamensky (@russoz)
|
- Alexei Znamensky (@russoz)
|
||||||
|
@ -58,6 +59,7 @@ attributes:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
---
|
||||||
- name: Check the entire project
|
- name: Check the entire project
|
||||||
community.general.django_check:
|
community.general.django_check:
|
||||||
settings: myproject.settings
|
settings: myproject.settings
|
||||||
|
@ -73,10 +75,17 @@ EXAMPLES = """
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
---
|
||||||
run_info:
|
run_info:
|
||||||
description: Command-line execution information.
|
description: Command-line execution information.
|
||||||
type: dict
|
type: dict
|
||||||
returned: success and C(verbosity) >= 3
|
returned: success and C(verbosity) >= 3
|
||||||
|
version:
|
||||||
|
description: Version of Django.
|
||||||
|
type: str
|
||||||
|
returned: always
|
||||||
|
sample: 5.1.2
|
||||||
|
version_added: 10.0.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.django import DjangoModuleHelper
|
from ansible_collections.community.general.plugins.module_utils.django import DjangoModuleHelper
|
||||||
|
|
|
@ -8,6 +8,7 @@ from __future__ import absolute_import, division, print_function
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
DOCUMENTATION = """
|
DOCUMENTATION = """
|
||||||
|
---
|
||||||
module: django_command
|
module: django_command
|
||||||
author:
|
author:
|
||||||
- Alexei Znamensky (@russoz)
|
- Alexei Znamensky (@russoz)
|
||||||
|
@ -37,6 +38,7 @@ options:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
---
|
||||||
- name: Check the project
|
- name: Check the project
|
||||||
community.general.django_command:
|
community.general.django_command:
|
||||||
command: check
|
command: check
|
||||||
|
@ -51,10 +53,17 @@ EXAMPLES = """
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
---
|
||||||
run_info:
|
run_info:
|
||||||
description: Command-line execution information.
|
description: Command-line execution information.
|
||||||
type: dict
|
type: dict
|
||||||
returned: success and O(verbosity) >= 3
|
returned: success and O(verbosity) >= 3
|
||||||
|
version:
|
||||||
|
description: Version of Django.
|
||||||
|
type: str
|
||||||
|
returned: always
|
||||||
|
sample: 5.1.2
|
||||||
|
version_added: 10.0.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import shlex
|
import shlex
|
||||||
|
|
|
@ -8,6 +8,7 @@ from __future__ import absolute_import, division, print_function
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
DOCUMENTATION = """
|
DOCUMENTATION = """
|
||||||
|
---
|
||||||
module: django_createcachetable
|
module: django_createcachetable
|
||||||
author:
|
author:
|
||||||
- Alexei Znamensky (@russoz)
|
- Alexei Znamensky (@russoz)
|
||||||
|
@ -27,6 +28,7 @@ attributes:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
---
|
||||||
- name: Create cache table in the default database
|
- name: Create cache table in the default database
|
||||||
community.general.django_createcachetable:
|
community.general.django_createcachetable:
|
||||||
settings: myproject.settings
|
settings: myproject.settings
|
||||||
|
@ -40,10 +42,17 @@ EXAMPLES = """
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
---
|
||||||
run_info:
|
run_info:
|
||||||
description: Command-line execution information.
|
description: Command-line execution information.
|
||||||
type: dict
|
type: dict
|
||||||
returned: success and O(verbosity) >= 3
|
returned: success and O(verbosity) >= 3
|
||||||
|
version:
|
||||||
|
description: Version of Django.
|
||||||
|
type: str
|
||||||
|
returned: always
|
||||||
|
sample: 5.1.2
|
||||||
|
version_added: 10.0.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.django import DjangoModuleHelper
|
from ansible_collections.community.general.plugins.module_utils.django import DjangoModuleHelper
|
||||||
|
|
|
@ -7,11 +7,18 @@
|
||||||
- id: success
|
- id: success
|
||||||
input:
|
input:
|
||||||
settings: whatever.settings
|
settings: whatever.settings
|
||||||
|
output:
|
||||||
|
version: "5.1.2"
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
- command: [/testbin/python, -m, django, check, --no-color, --settings=whatever.settings]
|
- command: [/testbin/python, -m, django, --version]
|
||||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||||
rc: 0
|
rc: 0
|
||||||
|
out: "5.1.2\n"
|
||||||
|
err: ""
|
||||||
|
- command: [/testbin/python, -m, django, check, --no-color, --settings=whatever.settings]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
out: "whatever\n"
|
out: "whatever\n"
|
||||||
err: ""
|
err: ""
|
||||||
- id: multiple_databases
|
- id: multiple_databases
|
||||||
|
@ -20,8 +27,15 @@
|
||||||
database:
|
database:
|
||||||
- abc
|
- abc
|
||||||
- def
|
- def
|
||||||
|
output:
|
||||||
|
version: "5.1.2"
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/python, -m, django, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: "5.1.2\n"
|
||||||
|
err: ""
|
||||||
- command: [/testbin/python, -m, django, check, --no-color, --settings=whatever.settings, --database, abc, --database, def]
|
- command: [/testbin/python, -m, django, check, --no-color, --settings=whatever.settings, --database, abc, --database, def]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 0
|
rc: 0
|
||||||
|
|
|
@ -15,9 +15,14 @@
|
||||||
settings: whatever.settings
|
settings: whatever.settings
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
- command: [/testbin/python, -m, django, check, --no-color, --settings=whatever.settings, babaloo, yaba, daba, doo]
|
- command: [/testbin/python, -m, django, --version]
|
||||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||||
rc: 0
|
rc: 0
|
||||||
|
out: "5.1.2\n"
|
||||||
|
err: ""
|
||||||
|
- command: [/testbin/python, -m, django, check, --no-color, --settings=whatever.settings, babaloo, yaba, daba, doo]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
out: "whatever\n"
|
out: "whatever\n"
|
||||||
err: ""
|
err: ""
|
||||||
- id: command_fail
|
- id: command_fail
|
||||||
|
@ -33,6 +38,11 @@
|
||||||
failed: true
|
failed: true
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/python, -m, django, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: "5.1.2\n"
|
||||||
|
err: ""
|
||||||
- command: [/testbin/python, -m, django, check, --no-color, --settings=whatever.settings, babaloo, yaba, daba, doo]
|
- command: [/testbin/python, -m, django, check, --no-color, --settings=whatever.settings, babaloo, yaba, daba, doo]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 1
|
rc: 1
|
||||||
|
|
|
@ -9,8 +9,13 @@
|
||||||
settings: whatever.settings
|
settings: whatever.settings
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/python, -m, django, --version]
|
||||||
|
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||||
|
rc: 0
|
||||||
|
out: "5.1.2\n"
|
||||||
|
err: ""
|
||||||
- command: [/testbin/python, -m, django, createcachetable, --no-color, --settings=whatever.settings, --noinput, --database=default]
|
- command: [/testbin/python, -m, django, createcachetable, --no-color, --settings=whatever.settings, --noinput, --database=default]
|
||||||
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
environ: *env-def
|
||||||
rc: 0
|
rc: 0
|
||||||
out: "whatever\n"
|
out: "whatever\n"
|
||||||
err: ""
|
err: ""
|
||||||
|
|
Loading…
Reference in New Issue