Merge "builder: include environment when running an exec"

This commit is contained in:
Zuul 2019-12-12 23:41:30 +00:00 committed by Gerrit Code Review
commit 854de3e5e1
2 changed files with 3 additions and 0 deletions

View File

@ -276,6 +276,7 @@ class BaseBuilder(object):
cmd.append('--privileged=%s' % str(cconfig['privileged']).lower())
if 'user' in cconfig:
cmd.append('--user=%s' % cconfig['user'])
self.list_or_dict_arg(cconfig, cmd, 'environment', '--env')
command = self.command_argument(cconfig.get('command'))
# for exec, the first argument is the container name,
# make sure the correct one is used

View File

@ -585,6 +585,7 @@ three-12345678 three''', '', 0),
'one': {
'command': 'ls -l /foo',
'privileged': True,
'environment': {'FOO': 'BAR'},
'user': 'bar'
}
}
@ -596,6 +597,7 @@ three-12345678 three''', '', 0),
self.assertEqual(
['docker', 'exec',
'--privileged=true', '--user=bar',
'--env=FOO=BAR',
'one-12345678', '-l', '/foo'],
cmd
)