mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-08 22:12:44 +00:00
Migrate k8s_info (#310)
* Use refactored module_utils Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Update k8s_info.py * Fix assertion Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
This commit is contained in:
committed by
Mike Graves
parent
afa6a74178
commit
9aa20f0fbe
@@ -155,10 +155,19 @@ from ansible_collections.kubernetes.core.plugins.module_utils.args_common import
|
|||||||
AUTH_ARG_SPEC,
|
AUTH_ARG_SPEC,
|
||||||
WAIT_ARG_SPEC,
|
WAIT_ARG_SPEC,
|
||||||
)
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
|
||||||
|
AnsibleK8SModule,
|
||||||
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
||||||
|
get_api_client,
|
||||||
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import (
|
||||||
|
K8sService,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def execute_module(module, k8s_ansible_mixin):
|
def execute_module(module, svc):
|
||||||
facts = k8s_ansible_mixin.kubernetes_facts(
|
facts = svc.find(
|
||||||
module.params["kind"],
|
module.params["kind"],
|
||||||
module.params["api_version"],
|
module.params["api_version"],
|
||||||
name=module.params["name"],
|
name=module.params["name"],
|
||||||
@@ -190,19 +199,12 @@ def argspec():
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True)
|
module = AnsibleK8SModule(
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
module_class=AnsibleModule, argument_spec=argspec(), supports_check_mode=True
|
||||||
K8sAnsibleMixin,
|
|
||||||
get_api_client,
|
|
||||||
)
|
)
|
||||||
|
client = get_api_client(module)
|
||||||
k8s_ansible_mixin = K8sAnsibleMixin(module)
|
svc = K8sService(client, module)
|
||||||
k8s_ansible_mixin.client = get_api_client(module=module)
|
execute_module(module, svc)
|
||||||
k8s_ansible_mixin.fail_json = module.fail_json
|
|
||||||
k8s_ansible_mixin.fail = module.fail_json
|
|
||||||
k8s_ansible_mixin.exit_json = module.exit_json
|
|
||||||
k8s_ansible_mixin.warn = module.warn
|
|
||||||
execute_module(module, k8s_ansible_mixin)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -201,7 +201,7 @@
|
|||||||
- name: assert that task failed with proper message
|
- name: assert that task failed with proper message
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- '"kubernetes >= 17.17.0 is required" in _result.msg'
|
- '"kubernetes >= 17.17.0 is required" in _result.module_stderr'
|
||||||
when:
|
when:
|
||||||
- _stat.stat.exists
|
- _stat.stat.exists
|
||||||
- _stat.stat.readable
|
- _stat.stat.readable
|
||||||
|
|||||||
Reference in New Issue
Block a user