mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-06 21:12:37 +00:00
Migrate k8s (#311)
* Use refactored module_utils Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Fix runner Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Fix runner Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Update runner.py * black runner Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Fix units Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Fix ResourceTimeout Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Attempt to fix 'Create custom resource' Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Update svc.find_resource(..., fail=True) Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Attempt to fix integration tests Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Fix apiVersion for Job Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Fix crd Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Add exception = None Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Fix apiVersion for definition Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Fix assert Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Fix returned results Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Update runner to return results accordingly Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Fix assert Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Add validate-missing Signed-off-by: Alina Buzachis <abuzachis@redhat.com> * Update client.py * Fix failures * Fix black formatting Co-authored-by: Mike Graves <mgraves@redhat.com>
This commit is contained in:
committed by
Mike Graves
parent
58a0fb1605
commit
3bf147580f
@@ -391,6 +391,12 @@ from ansible_collections.kubernetes.core.plugins.module_utils.args_common import
|
||||
RESOURCE_ARG_SPEC,
|
||||
DELETE_OPTS_ARG_SPEC,
|
||||
)
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
|
||||
AnsibleK8SModule,
|
||||
)
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.runner import (
|
||||
run_module,
|
||||
)
|
||||
|
||||
|
||||
def validate_spec():
|
||||
@@ -437,28 +443,6 @@ def argspec():
|
||||
return argument_spec
|
||||
|
||||
|
||||
def execute_module(module, k8s_ansible_mixin):
|
||||
k8s_ansible_mixin.module = module
|
||||
k8s_ansible_mixin.argspec = module.argument_spec
|
||||
k8s_ansible_mixin.check_mode = k8s_ansible_mixin.module.check_mode
|
||||
k8s_ansible_mixin.params = k8s_ansible_mixin.module.params
|
||||
k8s_ansible_mixin.fail_json = k8s_ansible_mixin.module.fail_json
|
||||
k8s_ansible_mixin.fail = k8s_ansible_mixin.module.fail_json
|
||||
k8s_ansible_mixin.exit_json = k8s_ansible_mixin.module.exit_json
|
||||
k8s_ansible_mixin.warn = k8s_ansible_mixin.module.warn
|
||||
k8s_ansible_mixin.warnings = []
|
||||
|
||||
k8s_ansible_mixin.kind = k8s_ansible_mixin.params.get("kind")
|
||||
k8s_ansible_mixin.api_version = k8s_ansible_mixin.params.get("api_version")
|
||||
k8s_ansible_mixin.name = k8s_ansible_mixin.params.get("name")
|
||||
k8s_ansible_mixin.generate_name = k8s_ansible_mixin.params.get("generate_name")
|
||||
k8s_ansible_mixin.namespace = k8s_ansible_mixin.params.get("namespace")
|
||||
|
||||
k8s_ansible_mixin.check_library_version()
|
||||
k8s_ansible_mixin.set_resource_definitions(module)
|
||||
k8s_ansible_mixin.execute_module()
|
||||
|
||||
|
||||
def main():
|
||||
mutually_exclusive = [
|
||||
("resource_definition", "src"),
|
||||
@@ -467,19 +451,14 @@ def main():
|
||||
("template", "src"),
|
||||
("name", "generate_name"),
|
||||
]
|
||||
module = AnsibleModule(
|
||||
|
||||
module = AnsibleK8SModule(
|
||||
module_class=AnsibleModule,
|
||||
argument_spec=argspec(),
|
||||
mutually_exclusive=mutually_exclusive,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||
K8sAnsibleMixin,
|
||||
get_api_client,
|
||||
)
|
||||
|
||||
k8s_ansible_mixin = K8sAnsibleMixin(module)
|
||||
k8s_ansible_mixin.client = get_api_client(module=module)
|
||||
execute_module(module, k8s_ansible_mixin)
|
||||
run_module(module)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user