mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-03-26 21:33:02 +00:00
fix: kustomize plugin fails with deprecation warnings (#728)
SUMMARY error judgments are based on the exit codes of command execution, where 0 represents success and non-zero represents failure. Optimize the run_command function to return a tuple like the run_command method of AnsibleModule. Fixes #639 ISSUE TYPE Bugfix Pull Request COMPONENT NAME kustomize lookup plugin ADDITIONAL INFORMATION Reviewed-by: Mike Graves <mgraves@redhat.com> Reviewed-by: QCU
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- kustomize - kustomize plugin fails with deprecation warnings (https://github.com/ansible-collections/kubernetes.core/issues/639).
|
||||||
@@ -94,7 +94,8 @@ def get_binary_from_path(name, opt_dirs=None):
|
|||||||
|
|
||||||
def run_command(command):
|
def run_command(command):
|
||||||
cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
return cmd.communicate()
|
stdout, stderr = cmd.communicate()
|
||||||
|
return cmd.returncode, stdout, stderr
|
||||||
|
|
||||||
|
|
||||||
class LookupModule(LookupBase):
|
class LookupModule(LookupBase):
|
||||||
@@ -140,9 +141,18 @@ class LookupModule(LookupBase):
|
|||||||
if enable_helm:
|
if enable_helm:
|
||||||
command += ["--enable-helm"]
|
command += ["--enable-helm"]
|
||||||
|
|
||||||
(out, err) = run_command(command)
|
(ret, out, err) = run_command(command)
|
||||||
if err:
|
if ret != 0:
|
||||||
raise AnsibleLookupError(
|
if err:
|
||||||
"kustomize command failed with: {0}".format(err.decode("utf-8"))
|
raise AnsibleLookupError(
|
||||||
)
|
"kustomize command failed. exit code: {0}, error: {1}".format(
|
||||||
|
ret, err.decode("utf-8")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise AnsibleLookupError(
|
||||||
|
"kustomize command failed with unknown error. exit code: {0}".format(
|
||||||
|
ret
|
||||||
|
)
|
||||||
|
)
|
||||||
return [out.decode("utf-8")]
|
return [out.decode("utf-8")]
|
||||||
|
|||||||
Reference in New Issue
Block a user