k8s_cp - fix issue when directory contains space in its name (#552)

k8s_cp - fix issue when directory contains space in its name

Depends-On: #549
SUMMARY

There is a remaining issue not addressed by  #512 when copying directory from Pod to local filesystem, if the directory contains space into its name, the directory was not copied

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

k8s_cp
ADDITIONAL INFORMATION

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Bikouo Aubin <None>
This commit is contained in:
Bikouo Aubin
2022-12-15 19:17:21 +01:00
committed by GitHub
parent c073eea5b3
commit 42ee210ecf
4 changed files with 131 additions and 1 deletions

View File

@@ -144,7 +144,13 @@ class K8SCopyFromPod(K8SCopy):
return files
def listfile_with_echo(self, path):
echo_cmd = [self.pod_shell, "-c", "echo {path}/* {path}/.*".format(path=path)]
echo_cmd = [
self.pod_shell,
"-c",
"echo {path}/* {path}/.*".format(
path=path.translate(str.maketrans({" ": r"\ "}))
),
]
error, out, err = self._run_from_pod(cmd=echo_cmd)
if error.get("status") != "Success":
self.module.fail_json(msg=error.get("message"))