docker: Use a standard escaping function.

The outer double-quotes (") were breaking things on some versions
of Docker, such as the one currently available on Travis.
This commit is contained in:
The Fox in the Shell 2016-08-13 01:09:17 +02:00
parent 765430bfad
commit eca54d6c21
No known key found for this signature in database
GPG key ID: 25C4AC4F5F6ED2D6

View file

@ -50,15 +50,9 @@ class PopulateLabels(Task):
for label, value in info.manifest.provider['labels'].items():
labels[label] = value.format(**info.manifest_vars)
# pipes.quote converts newlines into \n rather than just prefixing
# it with a backslash, so we need to escape manually
def escape(value):
value = value.replace('"', '\\"')
value = value.replace('\n', '\\\n')
value = '"' + value + '"'
return value
from pipes import quote
for label, value in labels.items():
info._docker['dockerfile'].append('LABEL {}={}'.format(label, escape(value)))
info._docker['dockerfile'].append('LABEL {}={}'.format(label, quote(value)))
class AppendManifestDockerfile(Task):