Skip to content

Commit

Permalink
Merge pull request box#17 from skynet/fix-yaml-split
Browse files Browse the repository at this point in the history
Safely split yaml documents
  • Loading branch information
michaelansel authored and GitHub Enterprise committed Jun 13, 2017
2 parents 9b4f403 + b429a6e commit d4bb02c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion kubectl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ from __future__ import print_function
import argparse
import subprocess
import os
import re
import logging
import sys
import tempfile
Expand Down Expand Up @@ -97,7 +98,7 @@ def handle_apply_with_filename(params, other_params, filename):

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

apply_ok = [o for o in objs if not is_broken_with_apply(o)]
Expand Down
6 changes: 4 additions & 2 deletions test/KubectlWrapperTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"name": "skynet-tools-test-namespace"
"name": "skynet-tools-test-namespace",
"annotations": {
"embedded-dashes": "-------"
}
}
}
"""
Expand Down Expand Up @@ -131,4 +134,3 @@ def main():

if __name__=="__main__":
main()

0 comments on commit d4bb02c

Please sign in to comment.