gio_mime: add return value version (#9067)
* add return value version * add changelog fragpull/9085/head
parent
c71f662d55
commit
e63c2f54cf
|
@ -0,0 +1,3 @@
|
||||||
|
minor_changes:
|
||||||
|
- gio_mime module utils - add argument formatter ``version`` (https://github.com/ansible-collections/community.general/pull/9067).
|
||||||
|
- gio_mime - add return value ``version`` (https://github.com/ansible-collections/community.general/pull/9067).
|
|
@ -16,6 +16,7 @@ def gio_mime_runner(module, **kwargs):
|
||||||
arg_formats=dict(
|
arg_formats=dict(
|
||||||
mime_type=cmd_runner_fmt.as_list(),
|
mime_type=cmd_runner_fmt.as_list(),
|
||||||
handler=cmd_runner_fmt.as_list(),
|
handler=cmd_runner_fmt.as_list(),
|
||||||
|
version=cmd_runner_fmt.as_fixed('--version'),
|
||||||
),
|
),
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
|
@ -75,6 +75,12 @@ stderr:
|
||||||
returned: failure
|
returned: failure
|
||||||
type: str
|
type: str
|
||||||
sample: 'gio: Failed to load info for handler "never-existed.desktop"'
|
sample: 'gio: Failed to load info for handler "never-existed.desktop"'
|
||||||
|
version:
|
||||||
|
description: Version of gio.
|
||||||
|
type: str
|
||||||
|
returned: always
|
||||||
|
sample: "2.80.0"
|
||||||
|
version_added: 10.0.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper
|
from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper
|
||||||
|
@ -94,6 +100,9 @@ class GioMime(ModuleHelper):
|
||||||
|
|
||||||
def __init_module__(self):
|
def __init_module__(self):
|
||||||
self.runner = gio_mime_runner(self.module, check_rc=True)
|
self.runner = gio_mime_runner(self.module, check_rc=True)
|
||||||
|
with self.runner("version") as ctx:
|
||||||
|
rc, out, err = ctx.run()
|
||||||
|
self.vars.version = out.strip()
|
||||||
self.vars.set_meta("handler", initial_value=gio_mime_get(self.runner, self.vars.mime_type), diff=True, change=True)
|
self.vars.set_meta("handler", initial_value=gio_mime_get(self.runner, self.vars.mime_type), diff=True, change=True)
|
||||||
|
|
||||||
def __run__(self):
|
def __run__(self):
|
||||||
|
|
|
@ -13,9 +13,14 @@
|
||||||
changed: true
|
changed: true
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
- command: [/testbin/gio, mime, x-scheme-handler/http]
|
- command: [/testbin/gio, mime, --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: "2.80.0\n"
|
||||||
|
err: ""
|
||||||
|
- command: [/testbin/gio, mime, x-scheme-handler/http]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
out: ""
|
out: ""
|
||||||
err: >
|
err: >
|
||||||
No default applications for “x-scheme-handler/http”
|
No default applications for “x-scheme-handler/http”
|
||||||
|
@ -35,6 +40,11 @@
|
||||||
skip: test helper does not support check mode yet
|
skip: test helper does not support check mode yet
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/gio, mime, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: "2.80.0\n"
|
||||||
|
err: ""
|
||||||
- command: [/testbin/gio, mime, x-scheme-handler/http]
|
- command: [/testbin/gio, mime, x-scheme-handler/http]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 0
|
rc: 0
|
||||||
|
@ -55,6 +65,11 @@
|
||||||
changed: false
|
changed: false
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/gio, mime, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: "2.80.0\n"
|
||||||
|
err: ""
|
||||||
- command: [/testbin/gio, mime, x-scheme-handler/http]
|
- command: [/testbin/gio, mime, x-scheme-handler/http]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 0
|
rc: 0
|
||||||
|
|
Loading…
Reference in New Issue