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(
|
||||
mime_type=cmd_runner_fmt.as_list(),
|
||||
handler=cmd_runner_fmt.as_list(),
|
||||
version=cmd_runner_fmt.as_fixed('--version'),
|
||||
),
|
||||
**kwargs
|
||||
)
|
||||
|
|
|
@ -75,6 +75,12 @@ stderr:
|
|||
returned: failure
|
||||
type: str
|
||||
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
|
||||
|
@ -94,6 +100,9 @@ class GioMime(ModuleHelper):
|
|||
|
||||
def __init_module__(self):
|
||||
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)
|
||||
|
||||
def __run__(self):
|
||||
|
|
|
@ -13,9 +13,14 @@
|
|||
changed: true
|
||||
mocks:
|
||||
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}
|
||||
rc: 0
|
||||
out: "2.80.0\n"
|
||||
err: ""
|
||||
- command: [/testbin/gio, mime, x-scheme-handler/http]
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: ""
|
||||
err: >
|
||||
No default applications for “x-scheme-handler/http”
|
||||
|
@ -35,6 +40,11 @@
|
|||
skip: test helper does not support check mode yet
|
||||
mocks:
|
||||
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]
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
|
@ -55,6 +65,11 @@
|
|||
changed: false
|
||||
mocks:
|
||||
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]
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
|
|
Loading…
Reference in New Issue