Port changes from main to refactored branch (#472)

Port changes from main to refactored branch

Depends-on: ansible/ansible-zuul-jobs#1563
SUMMARY

This PR contains several commits that complete the rebase of the 2.x-refactor branch onto main. Most of the changes here had to be manually backported after rebasing as the original changes were to code that will be deprecated. In addition, rather than trying to manually sort out conflicts and changes to the sanity ignores, I rewrote the refresh_ignore_files script to fully automate the management of ignore files. Previously, these files were both manually edited and auto-generated. This should no longer be the case, and these files should never be manually edited going forward.
For the purposes of reviewing and history, I kept all changes in separate commits tied to the original commit being backported.

ISSUE TYPE

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Jill R <None>
This commit is contained in:
Mike Graves
2022-06-09 11:20:48 -04:00
committed by GitHub
parent 25644ac192
commit 92785f58da
18 changed files with 827 additions and 1394 deletions

View File

@@ -191,9 +191,9 @@ def execute_module(module):
state = module.params.get("state")
if state == "to_pod":
k8s_copy = K8SCopyToPod(module, client)
k8s_copy = K8SCopyToPod(module, client.client)
else:
k8s_copy = K8SCopyFromPod(module, client)
k8s_copy = K8SCopyFromPod(module, client.client)
try:
k8s_copy.run()

View File

@@ -201,10 +201,8 @@ def execute_module(svc, params):
{"sinceSeconds": params["since_seconds"]}
)
if module.params.get("previous"):
kwargs.setdefault("query_params", {}).update(
{"previous": module.params["previous"]}
)
if params.get("previous"):
kwargs.setdefault("query_params", {}).update({"previous": params["previous"]})
response = resource.log.get(
name=name, namespace=namespace, serialize=False, **kwargs

View File

@@ -291,7 +291,9 @@ def execute_module(client, module):
if module.check_mode:
result["result"] = existing.to_dict()
else:
result["result"] = client.patch(resource, existing.to_dict()).to_dict()
result["result"] = client.patch(
resource, existing.to_dict()
).to_dict()
else:
try:
result = scale(
@@ -336,7 +338,14 @@ def argspec():
def scale(
client, module, resource, existing_object, replicas, wait, wait_time, wait_sleep,
client,
module,
resource,
existing_object,
replicas,
wait,
wait_time,
wait_sleep,
):
name = existing_object.metadata.name
namespace = existing_object.metadata.namespace
@@ -373,9 +382,12 @@ def scale(
k8s_obj = client.get(resource, name=name, namespace=namespace).to_dict()
result["result"] = k8s_obj
if wait:
waiter = get_waiter(svc.client, resource)
waiter = get_waiter(client, resource)
success, result["result"], result["duration"] = waiter.wait(
timeout=wait_time, sleep=wait_sleep, name=name, namespace=namespace,
timeout=wait_time,
sleep=wait_sleep,
name=name,
namespace=namespace,
)
if not success:
raise ResourceTimeout("Resource scaling timed out", **result)

View File

@@ -235,7 +235,7 @@ def perform_action(svc, resource, definition, params):
def execute_module(svc):
""" Module execution """
"""Module execution"""
module = svc.module
api_version = "v1"
selector = module.params.get("selector")
@@ -269,7 +269,9 @@ def execute_module(svc):
def main():
module = AnsibleK8SModule(
module_class=AnsibleModule, argument_spec=argspec(), supports_check_mode=True,
module_class=AnsibleModule,
argument_spec=argspec(),
supports_check_mode=True,
)
client = get_api_client(module=module)