[backport/2.2] Fix for common non-ASCII characters in CRDs (#334)

Co-authored-by: Alessandro Rossi <4215912+kubealex@users.noreply.github.com>
This commit is contained in:
Mike Graves
2022-01-13 21:19:37 -05:00
committed by GitHub
parent d8538ffed3
commit eaffde63bb
2 changed files with 3 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
bugfixes:
- module_utils.common - change default opening mode to read-bytes to avoid bad interpretation of non ascii characters and strings, often present in 3rd party manifests.

View File

@@ -331,7 +331,7 @@ class K8sAnsibleMixin(object):
if not os.path.exists(path):
self.fail(msg="Error accessing {0}. Does the file exist?".format(path))
try:
with open(path, 'r') as f:
with open(path, "rb") as f:
result = list(yaml.safe_load_all(f))
except (IOError, yaml.YAMLError) as exc:
self.fail(msg="Error loading resource_definition: {0}".format(exc))