Skip to content

Commit

Permalink
Make sure no end-of-document is produced
Browse files Browse the repository at this point in the history
Technically it's correct to add an end-of-document mark to
the output. However, `kubectl` and `Flux` (before
fluxcd/flux#1931 ) choke on it.
  • Loading branch information
Alfonso Acosta committed Apr 13, 2019
1 parent 0504a78 commit 91bdcb0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions kubeyaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,31 @@ def note(s):
def yaml():
y = YAML()
y.explicit_start = True
y.explicit_end = False
y.preserve_quotes = True
return y

def bail(reason):
sys.stderr.write(reason); sys.stderr.write('\n')
sys.exit(2)

class AlwaysFalse(object):
def __init__(self):
pass

def __get__(self, instance, owner):
return False

def __set__(self, instance, value):
pass

def apply_to_yaml(fn, infile, outfile):
# fn :: iterator a -> iterator b
y = yaml()
# Hack to make sure no end-of-document ("...") is ever added
y.Emitter.open_ended = AlwaysFalse()
docs = y.load_all(infile)
for doc in fn(docs):
y.dump(doc, outfile)
y.dump_all(fn(docs), outfile)

def update_image(args, docs):
"""Update the manifest specified by args, in the stream of docs"""
Expand Down

0 comments on commit 91bdcb0

Please sign in to comment.