mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-04-10 19:01:03 +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,
|
||||
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):
|
||||
facts = k8s_ansible_mixin.kubernetes_facts(
|
||||
def execute_module(module, svc):
|
||||
facts = svc.find(
|
||||
module.params["kind"],
|
||||
module.params["api_version"],
|
||||
name=module.params["name"],
|
||||
@@ -190,19 +199,12 @@ def argspec():
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True)
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||
K8sAnsibleMixin,
|
||||
get_api_client,
|
||||
module = AnsibleK8SModule(
|
||||
module_class=AnsibleModule, argument_spec=argspec(), supports_check_mode=True
|
||||
)
|
||||
|
||||
k8s_ansible_mixin = K8sAnsibleMixin(module)
|
||||
k8s_ansible_mixin.client = get_api_client(module=module)
|
||||
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)
|
||||
client = get_api_client(module)
|
||||
svc = K8sService(client, module)
|
||||
execute_module(module, svc)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -201,7 +201,7 @@
|
||||
- name: assert that task failed with proper message
|
||||
assert:
|
||||
that:
|
||||
- '"kubernetes >= 17.17.0 is required" in _result.msg'
|
||||
- '"kubernetes >= 17.17.0 is required" in _result.module_stderr'
|
||||
when:
|
||||
- _stat.stat.exists
|
||||
- _stat.stat.readable
|
||||
|
||||
Reference in New Issue
Block a user