Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1729f35

Browse filesBrowse files
Prevent ConstructorError when parsing YAML containing '=' scalars
pyyaml assignes '=' to tag:yaml.org,2002:value even though there's no constructor for it. Removing the implicit resolver for '=' fixes the issue.
1 parent 2f546b9 commit 1729f35
Copy full SHA for 1729f35

File tree

1 file changed

+6
-1
lines changed
Filter options

1 file changed

+6
-1
lines changed

‎kubernetes/utils/create_from_yaml.py

Copy file name to clipboardExpand all lines: kubernetes/utils/create_from_yaml.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,17 @@ def create_with(objects):
153153
raise FailToCreateError(failures)
154154
return k8s_objects
155155

156+
class Loader(yaml.loader.SafeLoader):
157+
yaml_implicit_resolvers = yaml.loader.SafeLoader.yaml_implicit_resolvers.copy()
158+
if "=" in yaml_implicit_resolvers:
159+
yaml_implicit_resolvers.pop("=")
160+
156161
if yaml_objects:
157162
yml_document_all = yaml_objects
158163
return create_with(yml_document_all)
159164
elif yaml_file:
160165
with open(os.path.abspath(yaml_file)) as f:
161-
yml_document_all = yaml.safe_load_all(f)
166+
yml_document_all = yaml.load_all(f, Loader=Loader)
162167
return create_with(yml_document_all)
163168
else:
164169
raise ValueError(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.