Skip to content

Commit d4bb02c

Browse files
michaelanselGitHub Enterprise
authored and
GitHub Enterprise
committed
Merge pull request box#17 from skynet/fix-yaml-split
Safely split yaml documents
2 parents 9b4f403 + b429a6e commit d4bb02c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

kubectl

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ from __future__ import print_function
1010
import argparse
1111
import subprocess
1212
import os
13+
import re
1314
import logging
1415
import sys
1516
import tempfile
@@ -97,7 +98,7 @@ def handle_apply_with_filename(params, other_params, filename):
9798

9899
with open(p) as f:
99100
contents = f.read().strip()
100-
jsons = contents.split("---")
101+
jsons = re.compile("^---$", re.MULTILINE).split(contents)
101102
objs = [json.loads(j) for j in jsons if len(j)>0]
102103

103104
apply_ok = [o for o in objs if not is_broken_with_apply(o)]

test/KubectlWrapperTest.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
"apiVersion": "v1",
1818
"kind": "Namespace",
1919
"metadata": {
20-
"name": "skynet-tools-test-namespace"
20+
"name": "skynet-tools-test-namespace",
21+
"annotations": {
22+
"embedded-dashes": "-------"
23+
}
2124
}
2225
}
2326
"""
@@ -131,4 +134,3 @@ def main():
131134

132135
if __name__=="__main__":
133136
main()
134-

0 commit comments

Comments
 (0)