Fix secret location with absolute paths

Signed-off-by: Andrea Giardini <contact@andreagiardini.com>
This commit is contained in:
Andrea Giardini 2017-09-20 23:05:29 +02:00 committed by Joffrey F
parent 8c38651196
commit 18df4915f2
1 changed files with 6 additions and 3 deletions

View File

@ -881,9 +881,12 @@ class Service(object):
def get_secret_volumes(self):
def build_spec(secret):
target = '{}/{}'.format(
const.SECRETS_PATH,
secret['secret'].target or secret['secret'].source)
if secret['secret'].target is not None and secret['secret'].target.startswith('/'):
target = secret['secret'].target
else:
target = '{}/{}'.format(
const.SECRETS_PATH,
secret['secret'].target or secret['secret'].source)
return VolumeSpec(secret['file'], target, 'ro')
return [build_spec(secret) for secret in self.secrets]